ts_forecast_simulator | R Documentation |
Creating different forecast paths for forecast objects (when applicable),
by utilizing the underlying model distribution with the simulate
function.
ts_forecast_simulator(
.model,
.data,
.ext_reg = NULL,
.frequency = NULL,
.bootstrap = TRUE,
.horizon = 4,
.iterations = 25,
.sim_color = "steelblue",
.alpha = 0.05
)
.model |
A forecasting model of one of the following from the
|
.data |
The data that is used for the |
.ext_reg |
A |
.frequency |
This is for the conversion of an internal table and should match the time frequency of the data. |
.bootstrap |
A boolean value of TRUE/FALSE. From |
.horizon |
An integer defining the forecast horizon. |
.iterations |
An integer, set the number of iterations of the simulation. |
.sim_color |
Set the color of the simulation paths lines. |
.alpha |
Set the opacity level of the simulation path lines. |
This function expects to take in a model of either Arima
,
auto.arima
, ets
or nnetar
from the forecast
package. You can supply a
forecasting horizon, iterations and a few other items. You may also specify
an Arima() model using xregs.
The original time series, the simulated values and a some plots
Steven P. Sanderson II, MPH
Other Simulator:
ts_arima_simulator()
suppressPackageStartupMessages(library(forecast))
suppressPackageStartupMessages(library(dplyr))
# Create a model
fit <- auto.arima(AirPassengers)
data_tbl <- ts_to_tbl(AirPassengers)
# Simulate 50 possible forecast paths, with .horizon of 12 months
output <- ts_forecast_simulator(
.model = fit
, .horizon = 12
, .iterations = 50
, .data = data_tbl
)
output$ggplot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.