VARResult#

class cultivars.multivariate.reduced_form.vector_autoregression.VARResult(*, endog, names, order, trend, sigma_u, sigma_ml, resid, fittedvalues, design, llf, nobs, n_params, posterior=None, prior_label='none', coefficients, deterministic)[source]

Bases: _VectorResult, _SummaryMixin, _ComparisonMixin, _VectorInferenceMixin, _VectorPropagationMixin

A fitted reduced-form vector autoregression.

The estimated system is

\[y_t = D d_t + A_1 y_{t-1} + \cdots + A_p y_{t-p} + u_t, \qquad u_t \sim (0, \Sigma_u),\]

solved by multivariate least squares, which under Gaussian innovations is the maximum-likelihood estimator of \((D, A_1, \dots, A_p)\) and equation-by-equation OLS at the same time. The record carries the coefficient stack, both residual covariances, the residuals and the regressor matrix; everything else on the surface – forecasts, impulse responses, variance and historical decompositions, Granger causality, stability, residual diagnostics, coefficient inference – is inherited from the mixins and computed from those arrays on demand.

Note

Two residual covariances are stored and they are not interchangeable. sigma_u divides by \(T - kp - d\) and feeds every inferential quantity: standard errors, Wald tests, the Cholesky impact matrix. sigma_ml divides by \(T\) and feeds the likelihood and the information criteria, where the correction does not belong. Substituting one for the other biases either the criteria or the standard errors and nothing raises when it happens.

Warning

Orthogonalized impulse responses and the variance decomposition use the Cholesky factor of sigma_u, which imposes the recursive ordering of names as an identifying restriction. Permute the variables and the answer changes. The summary says so on every fit; a declared identification scheme lives in structural.

Variables:
  • endog – The (n, k) sample as supplied.

  • names – Variable labels, in Cholesky order.

  • order – Autoregressive order p.

  • trend – "n", "c" or "ct".

  • coefficients – (p, k, k) stack of A_1, ..., A_p.

  • deterministic – (d, k) deterministic coefficients, one row per term; zero rows when trend == "n".

  • sigma_u – Residual covariance with the degrees-of-freedom correction.

  • sigma_ml – Residual covariance divided by the effective sample.

  • resid – (nobs, k) residuals over the effective sample.

  • fittedvalues – (nobs, k) one-step conditional means.

  • design – (nobs, d + kp) regressor matrix as estimated.

  • llf – Gaussian log-likelihood at sigma_ml.

  • nobs – Effective sample size n - p.

  • n_params – Free parameters, covariance included.

  • posterior – Posterior coefficient inference when the model carried a prior; None for least squares.

  • prior_label – What the prior was, for the summary; "none" for least squares.

See also

  • VAR – the model whose fit() returns this record.

  • VARXResult – the same surface with a distributed lag of exogenous regressors appended to the design.

  • VECMResult – the same surface under a reduced-rank restriction on the levels.

  • structural – where the Cholesky ordering becomes a declared identification.

References

Sims, C. A. (1980). Macroeconomics and reality. Econometrica, 48(1), 1-48.

Lütkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer. Chapters 2-4.

Example

A bivariate VAR(1) with a one-way spillover. Least squares recovers the matrices, the Granger test finds the channel that is there and not the one that is not, and the one-step forecast is the fitted equation applied to the last observation:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> A = np.array([[0.5, 0.2], [0.0, 0.4]])
>>> y = np.zeros((202, 2))
>>> for t in range(1, 202):
...     y[t] = np.array([1.0, -0.5]) + A @ y[t - 1] + rng.standard_normal(2)
>>> res = VAR(y[2:], order=1, names=("a", "b")).fit()
>>> res.coefficients.shape, res.deterministic.shape, res.nobs, res.n_params
((1, 2, 2), (1, 2), 199, 9.0)
>>> bool(np.abs(res.coefficients[0] - A).max() < 0.15)
True
>>> res.granger_causality("b", "a").reject(), res.granger_causality("a", "b").reject()
(True, False)
>>> hand = res.deterministic[0] + res.coefficients[0] @ y[-1]
>>> bool(np.allclose(res.forecast(1)[0], hand))
True
>>> res.is_stable, res.irf(4).shape, res.fevd(4).shape
(True, (5, 2, 2), (5, 2, 2))

Private methods#

_comparison_label()

Short specification label for a ranking table.

_from_fit(fit, model)

Assemble the public result from the internal fit and its model.

_summary_table()

Structured summary rendered by every display path.