GraphicalVARResult.sparsity#
- property GraphicalVARResult.sparsity: float[source]#
Share of penalized coefficients set exactly to zero.
1 - n_nonzero / (p k^2); the deterministic block is not penalized and not counted.Example
>>> import numpy as np >>> y = np.random.default_rng(0).standard_normal((120, 4)) >>> res = SparseVAR(y, order=1).fit(lam=0.5) >>> res.n_nonzero, res.sparsity (0, 1.0) >>> loose = SparseVAR(y, order=1).fit(lam=0.01) >>> bool(abs(loose.sparsity - (1 - loose.n_nonzero / 16)) < 1e-12) True