VARX#

class cultivars.multivariate.reduced_form.vector_autoregression.VARX(endog, exog, *, order, exog_order=0, trend='c', names=None, exog_names=None)[source]

Bases: _ExogenousVectorAutoRegressionModel[VARXResult]

Vector autoregression with exogenous regressors, estimated by least squares.

The design gains one (m,) block per exogenous lag, placed after the endogenous lags so that every offset the base computes stays correct without an override. The constructor is inherited from _ExogenousVectorAutoRegressionModel; the exogenous sample must be aligned with the endogenous one row for row and the two label sets may not overlap. No prior is accepted here.

Parameters:
  • endog (ArrayLike) – The (nobs, k) endogenous panel.

  • exog (ArrayLike) – The (nobs, m) exogenous block, aligned on the same index.

  • order (int) – Endogenous autoregressive order p.

  • exog_order (int) – Exogenous lags s beyond the contemporaneous term. Defaults to zero.

  • trend (Literal['n', 'c', 'ct']) – "n", "c" (default) or "ct".

  • names (Sequence[str] | None) – Endogenous labels. Defaults to y1 ... yk.

  • exog_names (Sequence[str] | None) – Exogenous labels. Defaults to x1 ... xm.

Raises:
  • SpecificationError – If exog_order is malformed, the labels are malformed, or an endogenous and an exogenous label collide.

  • DimensionError – If the two samples are not aligned or the sample is too short for the specification.

Variables:
  • _endog – The validated (nobs, k) endogenous panel.

  • _exog – The validated (nobs, m) exogenous block.

  • _names – The resolved endogenous labels.

  • _exog_names – The resolved exogenous labels.

  • _order – The endogenous order.

  • _exog_order – The exogenous order.

  • _trend – The validated trend code.

  • _prior – Always _NoPrior.

See also

  • VARXResult – the record fit() returns.

  • VAR – the model without the exogenous block.

  • VECMX – the exogenous block under a cointegration restriction.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> x = rng.standard_normal((200, 1))
>>> y = np.column_stack([x[:, 0] + rng.standard_normal(200), rng.standard_normal(200)])
>>> res = VARX(y, x, order=1, exog_order=1).fit()
>>> res.forecast(3, exog_future=np.zeros((3, 1))).shape
(3, 2)
>>> VARX(y, x, order=1, names=("a", "b"), exog_names=("a",))
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: names and exog_names must not overlap, ...