Skip to contents

Create a Geometric Brownian Motion.

Usage

geometric_brownian_motion(
  .num_walks = 25,
  .n = 100,
  .mu = 0,
  .sigma = 0.1,
  .initial_value = 100,
  .delta_time = 0.003,
  .return_tibble = TRUE
)

Arguments

.num_walks

Total number of simulations.

.n

Total time of the simulation, how many n points in time.

.mu

Expected return

.sigma

Volatility

.initial_value

Integer representing the initial value.

.delta_time

Time step size.

.return_tibble

The default is TRUE. If set to FALSE then an object of class matrix will be returned.

Value

A tibble/matrix

Details

Geometric Brownian Motion (GBM) is a statistical method for modeling the evolution of a given financial asset over time. It is a type of stochastic process, which means that it is a system that undergoes random changes over time.

GBM is widely used in the field of finance to model the behavior of stock prices, foreign exchange rates, and other financial assets. It is based on the assumption that the asset's price follows a random walk, meaning that it is influenced by a number of unpredictable factors such as market trends, news events, and investor sentiment.

The equation for GBM is:

 dS/S = mdt + sdW

where S is the price of the asset, t is time, m is the expected return on the asset, s is the volatility of the asset, and dW is a small random change in the asset's price.

GBM can be used to estimate the likelihood of different outcomes for a given asset, and it is often used in conjunction with other statistical methods to make more accurate predictions about the future performance of an asset.

This function provides the ability of simulating and estimating the parameters of a GBM process. It can be used to analyze the behavior of financial assets and to make informed investment decisions.

See also

Author

Steven P. Sanderson II, MPH

Examples

library(ggplot2)

set.seed(123)
geometric_brownian_motion()
#> # A tibble: 2,525 × 6
#>    walk_number     x     y cum_min cum_max cum_mean
#>    <fct>       <int> <dbl>   <dbl>   <dbl>    <dbl>
#>  1 1               1 100      200     200      200 
#>  2 1               2  99.7    200.    200      200.
#>  3 1               3  99.6    200.    200      200.
#>  4 1               4 100.     200.    200.     200.
#>  5 1               5 100.     200.    200.     200.
#>  6 1               6 101.     200.    201.     200.
#>  7 1               7 101.     200.    201.     200.
#>  8 1               8 102.     200.    202.     200.
#>  9 1               9 101.     200.    202.     201.
#> 10 1              10 101.     200.    202.     201.
#> # ℹ 2,515 more rows

set.seed(123)
geometric_brownian_motion() |>
  ggplot(aes(x = x, y = y, group = walk_number, color = walk_number)) +
  geom_line() +
  labs(title = "Geometric Brownian Motion", x = "Time", y = "Value") +
  theme_minimal() +
  theme(legend.position = "none")