forecast_univariate: Forecast with univariate models

Description Usage Arguments Value Examples

View source: R/forecast_univariate.R

Description

A function to estimate univariate forecasts out-of-sample. Methods available include all forecast methods from the forecast package. See package website for most up-to-date list of available models.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
forecast_univariate(
  Data,
  forecast.dates,
  methods,
  horizon,
  recursive = TRUE,
  rolling.window = NA,
  freq,
  outlier.clean = FALSE,
  outlier.variables = NULL,
  outlier.bounds = c(0.05, 0.95),
  outlier.trim = FALSE,
  outlier.cross_section = FALSE,
  impute.missing = FALSE,
  impute.method = "kalman",
  impute.variables = NULL,
  impute.verbose = FALSE,
  parallel.dates = NULL,
  return.models = FALSE,
  return.data = FALSE
)

Arguments

Data

data.frame: data frame of variable to forecast and a date column; may alternatively be a ts, xts, or zoo object to forecast

forecast.dates

date: dates forecasts are created

methods

string: models to estimate forecasts

horizon

int: number of periods to forecast

recursive

boolean: use sequential one-step-ahead forecast if TRUE, use direct projections if FALSE

rolling.window

int: size of rolling window, NA if expanding window is used

freq

string: time series frequency; day, week, month, quarter, year

outlier.clean

boolean: if TRUE then clean outliers

outlier.variables

string: vector of variables to purge of outliers, default is all but 'date' column

outlier.bounds

double: vector of winsorizing minimum and maximum bounds, c(min percentile, max percentile)

outlier.trim

boolean: if TRUE then replace outliers with NA instead of winsorizing bound

outlier.cross_section

boolean: if TRUE then remove outliers based on cross-section (row-wise) instead of historical data (column-wise)

impute.missing

boolean: if TRUE then impute missing values

impute.method

string: select which method to use from the imputeTS package; 'interpolation', 'kalman', 'locf', 'ma', 'mean', 'random', 'remove','replace', 'seadec', 'seasplit'

impute.variables

string: vector of variables to impute missing values, default is all numeric columns

impute.verbose

boolean: show start-up status of impute.missing.routine

parallel.dates

int: the number of cores available for parallel estimation

return.models

boolean: if TRUE then return list of models estimated each forecast.date

return.data

boolean: if True then return list of information.set for each forecast.date

Value

data.frame with a row for each forecast by model and forecasted date

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 # simple time series
 A = c(1:100) + rnorm(100)
 date = seq.Date(from = as.Date('2000-01-01'), by = 'month', length.out = 100)
 Data = data.frame(date = date, A)

 # estiamte univariate forecasts
 forecast.uni =
     forecast_univariate(
       Data = Data,
       forecast.dates = tail(Data$date,5),
       method = c('naive','auto.arima', 'ets'),
       horizon = 1,
       recursive = FALSE,
       # information set
       rolling.window = NA,
       freq = 'month',
       # data prep
       outlier.clean = TRUE,
       impute.missing = TRUE)

tylerJPike/OOS documentation built on March 20, 2021, 3:20 a.m.