GraphicalVARResult#

class cultivars.multivariate.large_dim.graphical.GraphicalVARResult(*, endog, names, order, trend, coefficients, deterministic, sigma_u, resid, fittedvalues, penalty, lam, lambda_path, cv_errors, n_nonzero, nobs, precision, partial_correlations, lam_nodes)[source]#

A fitted graphical VAR: the sparse dynamics plus the precision network.

Everything the sparse result reports – including the closed-system surface and granger_adjacency() for the directed network – plus the contemporaneous side: the residual precision \(\Theta = \Sigma_u^{-1}\) estimated sparsely by nodewise lasso regressions of each residual on all the others,

\[\hat\Theta_{ij} = -\tfrac{1}{2}\bigl(\hat\theta_{ii}\hat\gamma_{ij} + \hat\theta_{jj}\hat\gamma_{ji}\bigr), \qquad \rho_{ij} = -\frac{\Theta_{ij}}{\sqrt{\Theta_{ii}\Theta_{jj}}},\]

with \(\hat\gamma_{ij}\) the lasso slope of residual \(i\) on residual \(j\), \(\hat\theta_{ii}\) the inverse residual variance of that regression, the two one-sided estimates symmetrized by averaging, and \(\rho_{ij}\) the partial correlation of innovations \(i\) and \(j\) given all the others.

Note

The two networks have different grammars and different defaults. A Granger edge is directed and temporal, read off the lasso support at threshold=0.0 by default, so every nonzero coefficient counts; the forecast-optimal penalty the rolling selection picks keeps many small coefficients, and the Granger network it draws is denser than the selection-optimal one. A contemporaneous edge is undirected and conditional, read off the partial correlations at threshold=0.05 by default, because averaging a selected and an unselected one-sided slope leaves a small nonzero that is not an edge. Raise either threshold to read a sparser network; neither is a hypothesis test.

Variables:
  • precision – (k, k) sparse residual precision from symmetrized nodewise regressions.

  • partial_correlations – (k, k) partial correlations implied by the precision, unit diagonal.

  • lam_nodes – (k,) per-node penalty levels chosen by K-fold cross-validation.

See also

  • GraphicalVAR – the model that produces this record.

  • SparseVARResult – the dynamics-only record this one extends.

  • Spillover – forecast-error-variance connectedness, the other network reading of a VAR.

References

Barigozzi, M., & Brownlees, C. (2019). NETS: Network estimation for time series. Journal of Applied Econometrics, 34(3), 347-364.

Meinshausen, N., & Buhlmann, P. (2006). High-dimensional graphs and variable selection with the lasso. Annals of Statistics, 34(3), 1436-1462.

Example

Five innovations with two conditional dependencies, (1, 2) and (3, 4); the precision network recovers them and the partial correlations follow from the precision:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> k, n = 5, 300
>>> theta = np.eye(k)
>>> theta[0, 1] = theta[1, 0] = -0.5
>>> theta[2, 3] = theta[3, 2] = 0.5
>>> chol = np.linalg.cholesky(np.linalg.inv(theta))
>>> coef = 0.5 * np.eye(k)
>>> coef[1, 0] = coef[2, 1] = 0.4
>>> y = np.zeros((n, k))
>>> for t in range(1, n):
...     y[t] = coef @ y[t - 1] + chol @ rng.standard_normal(k)
>>> res = GraphicalVAR(y, order=1).fit(seed=0)
>>> res.precision.shape, res.lam_nodes.shape, res.penalty
((5, 5), (5,), 'lasso')
>>> bool(np.allclose(res.precision, res.precision.T))
True
>>> edges = res.contemporaneous_adjacency(threshold=0.3)
>>> [(i, j) for i in range(k) for j in range(i + 1, k) if edges[i, j]]
[(0, 1), (2, 3)]
>>> bool(res.partial_correlations[0, 1] > 0.4), bool(res.partial_correlations[2, 3] < -0.4)
(True, True)

Attributes#

precision

(k, k) symmetrized nodewise-lasso residual precision.

partial_correlations

(k, k) partial correlations implied by precision, unit diagonal.

lam_nodes

(k,) per-node nodewise penalty levels from K-fold cross-validation.

coefficients

(p, k, k) lag stack at the selected penalty, original units.

cv_errors

(n_lambdas,) rolling one-step squared errors; empty when lam was stated.

deterministic

(n_det, k) unpenalized deterministic coefficients.

endog

The observed panel, shape (nobs_total, k).

fittedvalues

(nobs, k) one-step means over the effective sample.

k_endog

Number of endogenous variables.

lam

The penalty level estimated at, on the standardized scale.

lambda_path

(n_lambdas,) descending candidate path; empty when lam was stated.

n_nonzero

Nonzero penalized coefficients at the solution.

names

Variable labels, in column order.

nobs

Effective sample size after the p presample rows.

order

The autoregressive order p.

penalty

lasso, adaptive, scad, mcp or group.

resid

(nobs, k) residuals over the effective sample.

sigma_u

(k, k) degrees-of-freedom-corrected residual covariance.

sparsity

Share of penalized coefficients set exactly to zero.

trend

"n", "c" or "ct".

Methods#

contemporaneous_adjacency([threshold])

The undirected partial-correlation network.

granger_adjacency([threshold])

The directed Granger network the support draws.

ma_representation([horizon])

Moving-average matrices of the fitted system.

summary()

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