GraphicalVARResult.granger_adjacency#
- GraphicalVARResult.granger_adjacency(threshold=0.0)[source]#
The directed Granger network the support draws.
Entry
[i, j]isTruewhen some lag of variablejenters variablei’s equation with magnitude abovethreshold–jGranger-causesiin the selected model. A statement about the selected support, not a hypothesis test.- Parameters:
threshold (
float) – Magnitude below which an entry is read as absent.- Return type:
- Returns:
A
(k, k)boolean matrix with aFalsediagonal.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> k, n = 6, 300 >>> first = 0.5 * np.eye(k) >>> first[1, 0], first[3, 2] = 0.3, -0.3 >>> y = np.zeros((n, k)) >>> for t in range(1, n): ... y[t] = first @ y[t - 1] + rng.standard_normal(k) >>> res = SparseVAR(y, order=1).fit(penalty="mcp") >>> edges = res.granger_adjacency(threshold=0.15) >>> edges.dtype, bool(edges.diagonal().any()) (dtype('bool'), False) >>> [(i, j) for i in range(k) for j in range(k) if edges[i, j]] [(1, 0), (3, 2)] >>> int(res.granger_adjacency().sum()) >= int(edges.sum()) True