xregExpander: Exogenous variables expander

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/xregExpander.R

Description

Function expands the provided matrix or vector of variables, producing values with lags and leads specified by lags variable.

Usage

1
2
3
xregExpander(xreg, lags = c(-frequency(xreg):frequency(xreg)),
  silent = TRUE, gaps = c("auto", "NAs", "zero", "naive",
  "extrapolate"), ...)

Arguments

xreg

Vector / matrix / data.frame, containing variables that need to be expanded. In case of vector / matrix it is recommended to provide ts object, so the frequency of the data is taken into account.

lags

Vector of lags / leads that we need to have. Negative values mean lags, positive ones mean leads.

silent

If silent=FALSE, then the progress is printed out. Otherwise the function won't print anything in the console.

gaps

Defines how to fill in the gaps in the data. "NAs" will leave missing values, "zero" will substitute them by zeroes, "naive" will use the last / the first actual value, while "extrapolate" will use es function from smooth package (if present, otherwise - naive) in order to fill in values. Finally, "auto" will let the function select between "extrapolate" and "NAs" depending on the length of series.

...

This is temporary and is needed in order to capture "silent" parameter if it is provided.

Details

This function could be handy when you want to check if lags and leads of a variable influence the dependent variable. Can be used together with xregDo="select" in es, ces, gum and ssarima. All the missing values in the beginning and at the end of lagged series are substituted by mean forecasts produced using es.

Value

ts matrix with the expanded variables is returned.

Author(s)

Ivan Svetunkov, [email protected]

See Also

es, stepwise

Examples

1
2
3
4
# Create matrix of two variables, make it ts object and expand it
x <- cbind(rnorm(100,100,1),rnorm(100,50,3))
x <- ts(x,frequency=12)
xregExpander(x)

greybox documentation built on Dec. 11, 2019, 1:08 a.m.