GraphicalVARResult.contemporaneous_adjacency#
- GraphicalVARResult.contemporaneous_adjacency(threshold=0.05)[source]#
The undirected partial-correlation network.
Entry
[i, j]isTruewhen the partial correlation between innovationsiandj– given all the others – exceedsthresholdin magnitude. Symmetric by construction.- Parameters:
threshold (
float) – Magnitude below which an edge 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 = 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)) >>> y = np.zeros((n, k)) >>> for t in range(1, n): ... y[t] = 0.5 * y[t - 1] + chol @ rng.standard_normal(k) >>> res = GraphicalVAR(y, order=1).fit(seed=0) >>> edges = res.contemporaneous_adjacency() >>> edges.dtype, bool(np.array_equal(edges, edges.T)), bool(edges.diagonal().any()) (dtype('bool'), True, False) >>> bool(edges[0, 1]), bool(edges[2, 3]) (True, True) >>> int(res.contemporaneous_adjacency(threshold=0.3).sum() // 2) 2