Back to models
Forecaster

VARReduce

Categorical in XInsamplePred int insampleMultivariate

Generalized VAR forecaster using tabularized regression.

As special cases, can be used to construct classical L1 (Lasso) or elastic VAR forecasting models.

VARReduce is constructed with a tabular scikit-learn regressor (e.g., Lasso, Ridge, etc.) and is designed to be used with multivariate time series data.

The input data Y_in is a multivariate time series data containing n time series. An example with n = 2:

index

ts1

ts2

1

11

6

2

12

7

3

13

8

4

14

9

5

15

10

Fitting proceeds in two steps:

  1. Tabularization:

    For each time step and each time series within Y_in, lagged values X are generated. The number of lagged values are determined by the lags parameters.

    Below is the X for the sample Y_in with lags = 2. Note the absence of the earliest 2 timesteps as no corresponding lag value is available.

    index

    ts1_lag1

    ts2_lag1

    ts1_lag2

    ts2_lag2

    3

    12

    7

    11

    6

    4

    13

    8

    12

    7

    5

    14

    9

    13

    8

  2. Regression:

    The chosen regressor is fitted with `Y_in` as a target and X as predictors. Care is taken to first remove the first lags data points in `Y_in` as they do not have corresponding indices in X (i.e. the first two data points in the above example).

For forecasting, the last lags observations in Y_in are reframed as lagged predictors X_forecast and passed to the trained regressor to obtain the forecasts. X_forecast is shown below.

index

ts1_lag1

ts2_lag1

ts1_lag2

ts2_lag2

6

15

10

14

9

By default, LinearRegression is used, yielding results equivalent to a traditional VAR model. Alternatively, any scikit-learn compatible regressor can be used to introduce regularization and/or non-linearity.

For example:

  • VARReduce(regressor = Ridge()) is equivalent to VAR with L2 regularization.

  • VARReduce(regressor = Lasso()) is equivalent to VAR with L1 regularization.

  • VARReduce(regressor = ElasticNet()) is equivalent to elastic VAR.

These specific models are well-known classical generalizations of VAR. They can be used to incorporate regularization and prevent overfitting when the input data contain a large number of individual time series relative to data points.

Quickstart

python
from sktime.forecasting.var_reduce import VARReduce

estimator = VARReduce(lags=1, regressor=None)

Parameters(2)

lagsint, optional, default=1
The number of lagged values to include in the model.
regressorobject, optional (default=LinearRegression())
The regressor to use for fitting the model. Must be scikit-learn-compatible.

Examples

>>> from sktime.forecasting.var_reduce import VARReduce
>>> from sklearn.linear_model import Lasso
>>> from sktime.datasets import load_longley
>>> _, y = load_longley ()
>>> forecaster = VARReduce (regressor = Lasso ())
>>> forecaster. fit (y) VARReduce(
... )
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])