VARXResult#
- class cultivars.multivariate.reduced_form.vector_autoregression.VARXResult(*, endog, names, order, trend, sigma_u, sigma_ml, resid, fittedvalues, design, llf, nobs, n_params, posterior=None, prior_label='none', coefficients, deterministic, exog, exog_names, exog_order, exog_coefficients)[source]#
A fitted vector autoregression with exogenous regressors.
The estimated system is
\[y_t = D d_t + \sum_{i=1}^{p} A_i y_{t-i} + \sum_{j=0}^{s} B_j x_{t-j} + u_t, \qquad u_t \sim (0, \Sigma_u),\]with the distributed lag of \(x\) appended to the design after the endogenous lags. Everything the reduced-form surface offers is inherited unchanged, because the exogenous block does not enter the moving-average representation:
irf,fevd,historical_decomposition,granger_causality,stability_checkandresidual_diagnosticsread the endogenous dynamics and are therefore the same objects they are for a plain VAR on \((A_1, \dots, A_p, \Sigma_u)\).forecast()is the exception, and it is the only new behaviour in the model. A VARX forecast is conditional on a path for \(x\), and this class has no model of \(x\) to supply one, so it asks for the path and refuses without it.Note
Granger causality is a test between endogenous variables. An exogenous regressor cannot be named as a cause, because its block is conditioned on rather than modelled; the coefficient on it and its lags, with standard errors, is in
params,bseandequation().- Variables:
exog (
NDArray[double]) – The(n, m)exogenous sample, aligned on the same index.names (
tuple[str,...]) – Endogenous labels, in Cholesky order.order (
int) – Endogenous autoregressive orderp.exog_order (
int) – Exogenous lagssbeyond the contemporaneous term.trend (
str) –"n","c"or"ct".coefficients (
NDArray[double]) –(p, k, k)stack ofA_1, ..., A_p.exog_coefficients (
NDArray[double]) –(s + 1, k, m)stack ofB_0, ..., B_s.deterministic (
NDArray[double]) –(d, k)deterministic coefficients.sigma_u (
NDArray[double]) – Residual covariance with the degrees-of-freedom correction.sigma_ml (
NDArray[double]) – Residual covariance divided by the effective sample.resid (
NDArray[double]) –(nobs, k)residuals over the effective sample.fittedvalues (
NDArray[double]) –(nobs, k)one-step conditional means.design (
NDArray[double]) –(nobs, d + kp + m(s + 1))regressor matrix as estimated.llf (
float) – Gaussian log-likelihood.nobs (
int) – Effective sample sizen - max(p, s).n_params (
float) – Free parameters, covariance included.
See also
References
Lütkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer. Chapter 10.
Example
A bivariate system driven by one exogenous series that hits the first equation on impact and the second with a lag. The fit recovers both impact matrices, the fitted values are the design applied row by row, and the forecast needs the future path:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> A = np.array([[0.5, 0.2], [0.0, 0.4]]) >>> B0, B1 = np.array([[1.0], [0.0]]), np.array([[0.0], [0.5]]) >>> x = rng.standard_normal((200, 1)) >>> y = np.zeros((200, 2)) >>> for t in range(1, 200): ... y[t] = A @ y[t - 1] + B0 @ x[t] + B1 @ x[t - 1] + 0.3 * rng.standard_normal(2) >>> res = VARX(y, x, order=1, exog_order=1, names=("a", "b"), exog_names=("z",)).fit() >>> res.exog_coefficients.shape, res.k_exog, res.nobs, res.n_params ((2, 2, 1), 1, 199, 13) >>> bool(np.abs(res.exog_coefficients[0] - B0).max() < 0.1) True >>> bool(np.abs(res.exog_coefficients[1] - B1).max() < 0.1) True >>> fitted = ( ... res.deterministic[0] ... + y[:-1] @ res.coefficients[0].T ... + x[1:] @ res.exog_coefficients[0].T ... + x[:-1] @ res.exog_coefficients[1].T ... ) >>> bool(np.allclose(fitted, res.fittedvalues)) True >>> res.forecast(2, exog_future=np.zeros((2, 1))).shape (2, 2) >>> res.forecast(2) Traceback (most recent call last): cultivars_engine.exceptions.SpecificationError: a VARX forecast is conditional on the ...
Attributes#
The |
|
The |
|
The |
|
The exogenous labels, in the column order of |
|
Exogenous lags |
|
The |
|
Standard errors, keyed identically to |
|
Covariance of the coefficient matrix, sampling or posterior. |
|
The |
|
The regressor matrix as estimated. |
|
The sample the model was fitted to. |
|
One-step conditional means over the effective sample. |
|
AIC, BIC, and HQIC derived from the likelihood and parameter count. |
|
Whether every companion eigenvalue lies inside the unit circle. |
|
Number of endogenous variables. |
|
Number of exogenous variables. |
|
Gaussian log-likelihood. |
|
Parameters the fit spends, covariance included. |
|
Variable labels, in the order the columns appear. |
|
Effective sample size. |
|
Autoregressive order, counted in the family's own convention. |
|
Every coefficient, keyed |
|
The posterior covariance when a prior was applied, otherwise |
|
What the prior was, for the summary. |
|
Two-sided p-values against zero, keyed identically to |
|
Residuals over the effective sample. |
|
Residual covariance divided by the effective sample. |
|
Residual covariance with the degrees-of-freedom correction. |
|
Deterministic specification. |
|
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. |
|
Point forecasts conditional on a future path for the exogenous block. |
|
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 \(\Psi_0, \ldots, \Psi_{\mathrm{horizon}}\). |
|
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 \(P^{-1} u_t\), shape |
|
|
The estimation summary, renderable as text, HTML, or a dataframe. |
|
This unit's equations in levels, as a global system consumes them. |