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_udivides by \(T - kp - d\) and feeds every inferential quantity: standard errors, Wald tests, the Cholesky impact matrix.sigma_mldivides 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 ofnamesas an identifying restriction. Permute the variables and the answer changes. The summary says so on every fit; a declared identification scheme lives instructural.- 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 ofA_1, ..., A_p.deterministic –
(d, k)deterministic coefficients, one row per term; zero rows whentrend == "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;
Nonefor least squares.prior_label – What the prior was, for the summary;
"none"for least squares.
See also
VAR– the model whosefit()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#
The |
|
The |
|
Standard errors, keyed identically to |
|
Covariance of the coefficient matrix, sampling or posterior. |
|
The |
|
AIC, BIC, and HQIC derived from the likelihood and parameter count. |
|
Whether every companion eigenvalue lies inside the unit circle. |
|
Number of endogenous variables. |
|
Every coefficient, keyed |
|
Two-sided p-values against zero, keyed identically to |
|
Normal test statistics against zero, keyed identically to |
Methods#
|
Engle's LM test for conditional heteroskedasticity in one equation. |
|
Rank this result against others by an information criterion. |
|
Confidence bounds for every coefficient. |
|
The coefficients of one equation, keyed by regressor. |
|
Forecast-error variance decomposition. |
|
Deterministic multi-step forecasts from the end of the sample. |
|
Variance shares from the generalized responses, normalized to sum to one. |
|
Pesaran-Shin impulse responses, which do not depend on variable order. |
|
Wald test that one variable's lags are jointly zero in another equation. |
Attribute each observation to the shocks that produced it. |
|
|
Declare an identification scheme and return the structural view. |
|
Impulse responses to a one-standard-deviation shock. |
|
Test this result as the restricted model against a nesting one. |
|
Moving-average matrices |
|
Jarque-Bera test on one equation's residuals. |
|
Multivariate Ljung-Box test for residual autocorrelation. |
|
Run every residual test and collect them into one table. |
|
A fresh sample path from the fitted system. |
Eigenvalue verdict for the companion matrix. |
|
Orthogonalized innovations |
|
|
The estimation summary, renderable as text, HTML, or a dataframe. |