model: Direct Model

Description Usage Arguments Details Value See Also Examples

View source: R/model.R

Description

This function estimates a direct least square horizon-specific model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
model(
  df,
  lags,
  .h,
  ic = BIC,
  .var = "all",
  .diff = FALSE,
  wav = FALSE,
  xreg = NULL,
  ...
)

Arguments

df

A data frame. The first column of the data frame must be the base variable for constructing the dependent variable, the multiperiod ahead value to be forecasted, x_{t + h}. If wav = TRUE, ncol of df can be equal to one (just the dependent variable), otherwise, ncol(df) must be greater than one, even if .var = "ar".

lags

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

.h

h step-ahead.

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.

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

General OLS regression model is writting as:

x_{t + h} = α + \mathbf{{β}}'\mathbf{x}_t + \mathbf{{γ}}'\mathbf{z}_t + \mathbf{{θ}}'\mathbf{d}_t + ε_{t + h},

where variables are explained in wavdrcast-package details section. Arguments .var, .diff and wav allow one to estimate subsets of this general model, as discussed in wavdrcast-package. If .var = "all", the general model is estimated (unless xreg = NULL, so that \mathbf{d} is out). If .var = "ar", \mathbf{z} terms are excluded (not \mathbf{d}, if included). Finally, if .var = "ar_out", the model is estimated without \mathbf{x} regressors.

Value

A list with the following elements:

xreg

A tibble with the data regressors used to run the model choosed by the information criterion. This can be a different data set from that one returned by the lm object.

model

An object of class lm.

See Also

fcast

Examples

1
2
3
4
5
6
model(df = inf, lags = c(2, 0), .h = 2, .var = "ar")
model(df = inf, lags = c(2, 2), .h = 2)
model(df = inf[1], lags = c(2, 2), .h = 2, wav = TRUE)
model(df = gdp, lags = c(2, 2), .h = 2, .diff = TRUE)
model(df = gdp[1], lags = c(2, 2), .h = 2, .diff = TRUE, wav = TRUE)
model(df = gdp[1], lags = c(0, 0), .h = 2, .diff = TRUE, wav = TRUE, .var = "ar_out")

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