get_models: Extract in-sample statistics estimated in "real-time"

Description Usage Arguments Details Value See Also Examples

Description

get_models() recursively estimates time-series models by using rolling and expanding time windows.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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, ...)

## S3 method for class 'tbl_time'
get_models(.tbl, .group, .col, .initial, .assess,
  .cumulative, .fun, ...)

Arguments

.tbl

A tidy tibble or an object of the tbl_time class.

.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 TRUE forecasts accumulate from the origin of each split. If FALSE forecasts are evaluated in a rolling windown. The default is TRUE.

.fun

Currently supports only a forecasting function from the forecast package.

...

Additional parameters to be passed to .fun.

Details

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.

Value

A tidy tibble contaning the following in-sample statistics for each period:

See Also

sw_tidy() sw_glance() rolling_origin()

Examples

 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)

Reckziegel/YahooTickers documentation built on May 28, 2019, noon