Learn R Programming

RandomWalker (version 1.1.0)

geometric_brownian_motion: Geometric Brownian Motion

Description

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,
  .dimensions = 1
)

Value

A tibble containing the generated random walks with columns depending on the number of dimensions:

  • walk_number: Factor representing the walk number.

  • step_number: Step index.

  • y: If .dimensions = 1, the value of the walk at each step.

  • x, y: If .dimensions = 2, the values of the walk in two dimensions.

  • x, y, z: If .dimensions = 3, the values of the walk in three dimensions.

The following are also returned based upon how many dimensions there are and could be any of x, y and or z:

  • cum_sum: Cumulative sum of dplyr::all_of(.dimensions).

  • cum_prod: Cumulative product of dplyr::all_of(.dimensions).

  • cum_min: Cumulative minimum of dplyr::all_of(.dimensions).

  • cum_max: Cumulative maximum of dplyr::all_of(.dimensions).

  • cum_mean: Cumulative mean of dplyr::all_of(.dimensions).

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.

.dimensions

The default is 1. Allowable values are 1, 2 and 3.

Author

Steven P. Sanderson II, MPH

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

Other Generator Functions: brownian_motion(), custom_walk(), discrete_walk(), double_pendulum_walk(), random_beta_walk(), random_binomial_walk(), random_cauchy_walk(), random_chisquared_walk(), random_displacement_walk(), random_exponential_walk(), random_f_walk(), random_gamma_walk(), random_geometric_walk(), random_hypergeometric_walk(), random_logistic_walk(), random_lognormal_walk(), random_multinomial_walk(), random_negbinomial_walk(), random_normal_drift_walk(), random_normal_walk(), random_poisson_walk(), random_smirnov_walk(), random_t_walk(), random_uniform_walk(), random_weibull_walk(), random_wilcox_walk(), random_wilcoxon_sr_walk()

Other Continuous Distribution: brownian_motion(), double_pendulum_walk(), random_beta_walk(), random_cauchy_walk(), random_chisquared_walk(), random_exponential_walk(), random_f_walk(), random_gamma_walk(), random_logistic_walk(), random_lognormal_walk(), random_normal_drift_walk(), random_normal_walk(), random_t_walk(), random_uniform_walk(), random_weibull_walk()

Examples

Run this code

set.seed(123)
geometric_brownian_motion()

set.seed(123)
geometric_brownian_motion(.dimensions = 3) |>
  head() |>
  t()

Run the code above in your browser using DataLab