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]#

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))

Attributes#

coefficients

The (p, k, k) autoregressive stack A_1, ..., A_p; coefficients[i][r, c] is the effect of variable c at lag i + 1 on equation r.

deterministic

The (d, k) deterministic coefficients, one row per term in the order constant, trend.

bse

Standard errors, keyed identically to params.

coefficient_covariance

Covariance of the coefficient matrix, sampling or posterior.

companion

The (kp, kp) companion matrix of the autoregressive block.

design

endog

fittedvalues

information_criteria

AIC, BIC, and HQIC derived from the likelihood and parameter count.

is_stable

Whether every companion eigenvalue lies inside the unit circle.

k_endog

Number of endogenous variables.

llf

n_params

names

nobs

order

params

Every coefficient, keyed "{equation}: {regressor}".

posterior

prior_label

pvalues

Two-sided p-values against zero, keyed identically to params.

resid

sigma_ml

sigma_u

trend

tvalues

Normal test statistics against zero, keyed identically to params.

Methods#

arch_test(variable[, lags])

Engle's LM test for conditional heteroskedasticity in one equation.

compare(*others[, criterion])

Rank this result against others by an information criterion.

conf_int(*[, alpha])

Confidence bounds for every coefficient.

equation(name)

The coefficients of one equation, keyed by regressor.

fevd([horizon])

Forecast-error variance decomposition.

forecast([steps])

Deterministic multi-step forecasts from the end of the sample.

generalized_fevd([horizon])

Variance shares from the generalized responses, normalized to sum to one.

generalized_irf([horizon, cumulative])

Pesaran-Shin impulse responses, which do not depend on variable order.

granger_causality(cause, effect)

Wald test that one variable's lags are jointly zero in another equation.

historical_decomposition()

Attribute each observation to the shocks that produced it.

identify(strategy)

Declare an identification scheme and return the structural view.

irf([horizon, orthogonalized, cumulative])

Impulse responses to a one-standard-deviation shock.

likelihood_ratio_test(unrestricted)

Test this result as the restricted model against a nesting one.

ma_representation([horizon])

Moving-average matrices Psi_0, ..., Psi_horizon.

normality_test(variable)

Jarque-Bera test on one equation's residuals.

portmanteau_test([lags])

Multivariate Ljung-Box test for residual autocorrelation.

residual_diagnostics(*[, portmanteau_lags, ...])

Run every residual test and collect them into one table.

simulate([n, seed, burn])

A fresh sample path from the fitted system.

stability_check()

Eigenvalue verdict for the companion matrix.

structural_shocks()

Orthogonalized innovations P^{-1} u_t, shape (nobs, k).

summary()

The estimation summary, renderable as text, HTML, or a dataframe.