Takes in the data from a tidy_
distribution function and applies
a random walk calculation of either cum_prod
or cum_sum
to y
.
tidy_random_walk(
.data,
.initial_value = 0,
.sample = FALSE,
.replace = FALSE,
.value_type = "cum_prod"
)
An ungrouped tibble.
The data that is being passed from a tidy_
distribution
function.
The default is 0, this can be set to whatever you want.
This is a boolean value TRUE/FALSE. The default is FALSE. If
set to TRUE then the y
value from the tidy_
distribution function is
sampled.
This is a boolean value TRUE/FALSE. The default is FALSE. If
set to TRUE AND .sample
is set to TRUE then the replace parameter of the
sample function will be set to TRUE.
This can take one of three different values for now. These are the following:
"cum_prod" - This will take the cumprod of y
"cum_sum" - This will take the cumsum of y
Steven P. Sanderson II, MPH
Monte Carlo simulations were first formally designed in the 1940’s while developing nuclear weapons, and since have been heavily used in various fields to use randomness solve problems that are potentially deterministic in nature. In finance, Monte Carlo simulations can be a useful tool to give a sense of how assets with certain characteristics might behave in the future. While there are more complex and sophisticated financial forecasting methods such as ARIMA (Auto-Regressive Integrated Moving Average) and GARCH (Generalised Auto-Regressive Conditional Heteroskedasticity) which attempt to model not only the randomness but underlying macro factors such as seasonality and volatility clustering, Monte Carlo random walks work surprisingly well in illustrating market volatility as long as the results are not taken too seriously.
tidy_normal(.sd = .1, .num_sims = 25) %>%
tidy_random_walk()
Run the code above in your browser using DataLab