auto_forecast: Automatic forecasting from univariate time series

Description Usage Arguments Details Value Author(s) Examples

View source: R/auto_forecast.R

Description

This function provides an algorithm to compute the best possible forecast from the available set of univariate time series. Additionaly, bootstrap methods are employed to both refine point forecasts and compute confidence intervals.

Usage

1
2
auto_forecast(data, h = 12, h_cv = 1, window = NULL, acc = "MAE",
  n = 10, level = 0.05, exclude = NULL, test = NULL)

Arguments

data

univariate time series (ts object).

h

forecast horizon.

h_cv

forecast horizon to compute accuracy by cross-validation.

window

length of the rolling window for cross-validation. If NULL, a rolling window will not be used.

acc

accuracy measure to determine the best model. Either "MAE" for mean absolute error, "RMSE" for root mean squared error or "dir" for directional.

n

number of bootstrap simulations used to compute both mean forecasts (bagging) and confidence intervals.

level

confidence level for prediction intervals.

exclude

one or more models to exclude from evaluation, eg. "auto.arima" or c("tbats", "nnetar").

test

first observation in the test set. Either a single number or a vector of two integers. If not NULL, overrides cross-validation arguments.

Details

Available models are: "auto.arima", "tbats", "ets", "nnetar", "hw", "arfima", "holt", "thetaf", "ses", "meanf", "splinef", "StrucTS", "elm". For more details about these models, see the documentation from forecast and nnfor packages.

Value

An object of class list containing the following elements:

fc

A tibble containing point forecasts and lower/upper limits from the bootstrapped distribution.

error

A tibble containing out-of-sample forecast errors.

acc

A tibble containing RMSE and MAE values for each model ordered according to the selected criteria.

dir

A tibble containing the ordered directional accuracy for each model.

model

Character vector with the selected model.

plot

A ggplot object with graphical representation of both the point forecasts and confidence intervals.

Author(s)

J. Renato Leripio

Examples

1
2
3
4
5
## Not run: 
library(rafa)
auto_forecast(USAccDeaths, test = c(1976,12))

## End(Not run)

leripio/rafa documentation built on Aug. 21, 2019, 8:19 p.m.