Back to models
Forecaster

VAR

VAR model from statsmodels.

Direct interface to statsmodels.tsa.vector_ar.

A VAR model is a generalisation of the univariate autoregressive model to multivariate time series, see [1]_.

Quickstart

python
from sktime.forecasting.var import VAR

estimator = VAR(maxlags=None, method='ols', verbose=False, trend='c', missing='none', dates=None, freq=None, ic=None, random_state=None)

Parameters(9)

maxlags: int or None (default=None)
Maximum number of lags to check for order selection, defaults to 12 * (nobs/100.)**(1./4)
methodstr {“ols”} (default=”ols”)

Estimation method to use. "ols" is the only estimation method offered by statsmodels.

verbosebool (default=False)
Print order selection output to the screen
trendstr {“c”, “ct”, “ctt”, “n”} (default=”c”)
  • “c” - add constant

  • “ct” - constant and trend

  • “ctt” - constant, linear and quadratic trend

  • “n” - co constant, no trend

Note that these are prepended to the columns of the dataset.

missingstr {“none”, “drop”, “raise”} (default=”none”)

A string specifying how missing values are handled.

  • "none" - no nan checking is done

  • "drop" - any observations with nans are dropped

  • "raise" - an error is raised if nans are present

freqstr, tuple, datetime.timedelta, DateOffset or None, optional (default=None)

A frequency specification for either dates or the row labels from the endog / exog data. A pandas offset, or one of the strings

  • "B" - business day

  • "D" - calendar day

  • "W" - weekly

  • "M" - monthly

  • "A" - annual

  • "Q" - quarterly

This is optional if dates are provided.

datesarray_like of datetime, optional (default=None)

An array like object containing datetime objects, which must match the number of rows of the endogenous data. If a pandas object with a DatetimeIndex is passed as data, that index is used, and this argument can be left as None.

ic: One of {‘aic’, ‘fpe’, ‘hqic’, ‘bic’, None} (default=None)

Information criterion to use for VAR order selection.

  • “aic”: Akaike

  • “fpe”: Final prediction error

  • “hqic”: Hannan-Quinn

  • “bic”: Bayesian a.k.a. Schwarz

random_stateint, RandomState instance or None, optional,
default=None - If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.

Examples

>>> from sktime.forecasting.var import VAR
>>> from sktime.datasets import load_longley
>>> _, y = load_longley ()
>>> forecaster = VAR ()
>>> forecaster. fit (y) VAR(
... )
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])

References

  1. [1] Athanasopoulos, G., Poskitt, D. S., & Vahid, F. (2012). Two canonical VARMA forms: Scalar component models vis-à-vis the echelon form. Econometric Reviews, 31(1), 60-83, 2012.