error_vin: Forecast Error of the Direct Forecast From Vintage

Description Usage Arguments Details Value See Also Examples

View source: R/error.R

Description

Compute the root-mean-squared forecast error (RMSE) or mean absolute forecast error (MAE) of the direct forecast from vintage. This dataset is defined as the sequence of values that represent the latest estimate of the data at a particular moment in time.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
error_vin(
  .vin,
  lags,
  .H,
  .K,
  ic = BIC,
  .var = "all",
  .diff = FALSE,
  dev = "RMSE",
  wav = FALSE,
  xreg = NULL,
  ...
)

Arguments

.vin

List of data vintages (data frame) for each variable. The first vintage is related to the dependent variable and the number of columns of each data frame must be the same as the number of the out-of-sample forecasts (.K). The latest observation must be the last column of the data frame. If wav = TRUE, the length of the list can be one, otherwise, must be greater than one.

lags

A integer vector defining the lags of the regressors. If wav = FALSE, the length of the vector lags have to be the same as the length of .vin. However, if wav = TRUE, an additional element in lags must be add such that the last element in the vector lags is the lag of the wavelet regressor.

.H

An integer representing the maximum horizon step.

.K

An integer, the number of pseudo-out-of-sample forecasts.

ic

Information criterion, BIC or AIC. When searching for the best model the dataset is adjusted so that every model have the same data length for appropriate comparasion.

.var

A string to determine how the model will be specificated: "all" (default), "ar" or "ar_out".

.diff

Logical FALSE or TRUE. If TRUE, the dependent variable is differentiated. See wavdrcast-package for the implication on the model specification and wavelet variable.

dev

A string, "RMSE" or "MAE".

wav

Logical. If TRUE, a wavelet-based signal is add to df, where the signal is related to the explained variable, the first column of df.

xreg

Data frame. Exogeunous variable not subjected to be lagged. The number of rows must be the same as in df.

...

Further arguments passed to wavsigmap::signal.

Details

See wavdrcast-package and model.

Value

A double vector with forecasts error (RMSE or MAE) from 1 to .H step-ahead.

See Also

model, fcast, error

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
set.seed(1)

v1 <- tibble::tibble(v1_t1 = c(sample(100, 98, replace = TRUE), NA, NA),
                     v1_t2 = c(v1_t1[1:98], 500, NA),
                     v1_t3 = c(v1_t2[1:99], 280))

 set.seed(1)
v2 <- tibble::tibble(v2_t1 = 0.4 * v1[["v1_t1"]] + rnorm(100),
                     v2_t2 = c(v2_t1[1:98], 500 + rnorm(1), NA),
                     v2_t3 = c(v2_t2[1:99], 600 + rnorm(1)))

error_vin(list(v1, v2), lags = c(2, 2), .H = 3, .K = 3)
error_vin(list(v1), lags = c(2, 2), .H = 3, .K = 3, wav = TRUE)

nelson16silva/wavdrcast documentation built on April 25, 2021, 7:03 a.m.