onlineVAR (version 0.1-1)

onlineVAR: Online Fitting of Time-Adaptive Lasso Vector Auto Regression.

Description

Recursive fitting of time-adaptive lasso vector auto regressive models with an online cyclic coordinate descent algorithm.

Usage

onlineVAR(y, nu = 1, lags = NULL, ahead = NULL, lambda.ratio = NULL, 
  burnin = NULL, control = onlineVAR.control(lambda.ratio, …), …)

onlineVAR.fit(x, y, nu, lags, ahead, lambda.ratio, fit, burnin, control = onlineVAR.control())

Arguments

y

Vector time series with columns for each variable and rows for each time step.

x

Lagged time series data. Columns 1 to ncol(y) contain lag-1 data, columns ncol(y)+1 to 2*ncol(y) lag-2 data and so on.

nu

Forgetting factor for exponential forgetting.

lags

Number of considered lags. Order of VAR model.

ahead

Look ahead time for predictions. Most recent data that are available. The fitted model only considers lags larger than ahead.

lambda.ratio

Vector of penalization parameters as fractions of the minimum lambda for which all coefficients are zero. If not specified a sequence of lambda values is used. See onlineVAR.control for details.

burnin

Burn-in period, i.e., the number of time steps that are used to stabilize the model fit. This is particularly important for selecting the optimum lambda. Default is the effective training data length 1/(1-nu) for a vector of lambda.ratio and 0 for a single valued lambda.ratio.

control

A list of control parameters. Default is onlineVAR.control(lambda.ratio).

fit

List of various starting values that are used for the online updating algorithm.

Arguments to be used to form the default control argument if it is not supplied directly.

Value

An object of class "onlineVAR", i.e., a list with the following elements.

coef

List of intercept vector and coefficient matrices for the different lags.

fit

List of various values that are used for the online updating algorithm. This is mainly used as starting values for further updates.

nu

Forgetting factor for exponential forgetting.

pred

Predictions. Matrix of the same size as the input data but with predictions from adaptive lasso VAR. The first burnin+ahead+lags rows are filled with NA

predall

If predall=TRUE in control predictions for all penalization parameters in lambda.ratio. Else NULL

residuals

Prediction errors.

lags

Number of considered lags. Order of VAR model.

ahead

Look ahead time for predictions.

lambda.ratio

Sequence of lasso penalization parameters

trace

If trace=TRUE a list of coefficient estimates for each time step. Else FALSE

burnin

Burn-in period, i.e., the number of data that are used to stabilize the model fit.

call

Function call.

Details

onlineVAR recursively fits time-adaptive lasso vector auto regressive models with an online coordinate descent algorithm that updates the model fit at each time step. By default these models are fitted for a sequence of lasso penalization parameters and predictions are generated for each time step with the parameter with the smallest weighted mean squared error.

onlineVAR.fit is the lower level function where the actual fitting takes place.

References

Messner JW, Pinson P (2016). Online Adaptive LASSO Estimation in Vector Auto Regressive Models for Wind Power Forecasting in High Dimension. International Journal of Forecasting, in press. http://pierrepinson.com/docs/MessnerPinson18.pdf.

See Also

predict.onlineVAR, plot.onlineVAR

Examples

Run this code
# NOT RUN {
data(aemo)

## use only subset of first 8000 time steps
y <- aemo[1:8000,]

## fit online lasso VAR
onlinefit <- onlineVAR(y, nu = 0.99, lags = 1, ahead = 1)

## plot coefficient matrix from last update
plot(onlinefit)

## compare mean root mean squared error to persistence 
c(onlinefit   = mean(sqrt(apply((predict(onlinefit)-y)^2, 2, 
    mean, na.rm = TRUE))),
  persistence = mean(sqrt(apply((aemo[1000:7999,]-y[1001:8000,])^2, 2, 
    mean))))
# }

Run the code above in your browser using DataLab