Description Usage Arguments Details Value See Also Examples
get_models() recursively estimates time-series models by using rolling and expanding time windows.
1 2 3 4 5 6 7 | get_models(.tbl, .group, .col, .initial, .assess, .cumulative, .fun, ...)
## Default S3 method:
get_models(.tbl, .group, .col, .initial, .assess, .cumulative, .fun, ...)
## S3 method for class 'tbl_df'
get_models(.tbl, .group, .col, .initial, .assess, .cumulative, .fun, ...)
|
.tbl |
A tidy |
.group |
The column in which the data should be grouped. This will often be a column with stock tickers or stocks names. |
.col |
The reference column in which the operations should be based on. |
.initial |
The number of periods used to train the model in each split. |
.assess |
The forecast horizon. |
.cumulative |
If |
.fun |
Currently supports only a forecasting function from the |
... |
Additional parameters to be passed to |
Under the hood, get_forecasts uses rsample infrastructure to sequentially access the model passed to .fun. The data y1, y2, ..., yt is fitted and the process repeats itself for each stock in the .group column.
A tidy tibble contaning the following in-sample statistics for each period:
term: The parameters estimated by .fun
estimate: The values of the estimated parameters
model.desc: A description of the model including the three integer components (p, d, q) are the AR order, the degree of differencing, and the MA order.
sigma: The square root of the estimated residual variance
logLik: The data's log-likelihood under the model
AIC: The Akaike Information Criterion
BIC: The Bayesian Information Criterion
ME: Mean error
RMSE: Root mean squared error
MAE: Mean absolute error
MPE: Mean percentage error
MAPE: Mean absolute percentage error
MASE: Mean absolute scaled error
ACF1: Autocorrelation of errors at lag 1
sw_tidy() sw_glance() rolling_origin() forecast
1 2 3 4 5 6 7 8 9 10 11 12 | library(YahooTickers)
library(dplyr)
library(forecast)
# Download and forecast time series using the "auto.arima" function
# from the forecast package
get_tickers(dow) %>%
slice(1:2) %>%
get_stocks(., periodicity = "monthly") %>%
get_returns(., tickers, arithmetic, TRUE, ret_adj = adjusted) %>%
get_models(., tickers, ret_adj, 60, 1, FALSE, auto.arima,
seasonal = FALSE, stationary = TRUE,
max.p = 1, max.q = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.