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]
Bases:
SparseVARResultA 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.0by 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 atthreshold=0.05by 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)
Private methods#
Build the structured summary. |