SparseVAR#
- class cultivars.multivariate.large_dim.sparse.SparseVAR(endog, *, order, trend='c', names=None)[source]#
Penalized VAR: lasso, adaptive lasso, SCAD, MCP, or lag-group.
One estimator, five penalties on the standardized lag coefficients. The lasso \(\lambda \sum |a|\) is the baseline; the adaptive lasso reweights each coefficient by a ridge pilot, \(\lambda \sum |a| / |\tilde a|\); SCAD and MCP are the nonconvex penalties that leave large coefficients unbiased, solved by local linear approximation as a short sequence of weighted lasso problems; and the lag-group penalty \(\lambda \sum_i \sqrt{k^2}\, \lVert A_i \rVert_F\) zeroes whole lag matrices, so it selects lags rather than entries. Every problem is solved by FISTA, warm-started along a geometric path from the level that zeroes everything down to
lambda_min_ratioof it, and the level is chosen by rolling-origin one-step forecast error with a refit at every origin. Deterministic terms are never penalized.- Variables:
_endog – The validated
(nobs_total, k)panel._order – The autoregressive order.
_trend – The deterministic specification.
_names – One label per variable.
- Parameters:
- Raises:
SpecificationError – If
orderis below 1,trendis not one of the three names, ornamesdoes not have one entry per column.DimensionError – If the panel is not a time-down-the-rows matrix or too short for the order.
See also
SparseVARResult– the recordfitreturns.GraphicalVAR– this estimator plus a sparse residual precision.BVAR– the shrinkage alternative for wide systems, with a likelihood.
References
Basu, S., & Michailidis, G. (2015). Regularized estimation in sparse high-dimensional time series models. Annals of Statistics, 43(4), 1535-1567.
Nicholson, W. B., Matteson, D. S., & Bien, J. (2017). VARX-L: Structured regularization for large vector autoregressions with exogenous variables. International Journal of Forecasting, 33(3), 627-651.
Zou, H., & Li, R. (2008). One-step sparse estimates in nonconcave penalized likelihood models. Annals of Statistics, 36(4), 1509-1533.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros((300, 6)) >>> for t in range(1, 300): ... y[t] = 0.5 * y[t - 1] + rng.standard_normal(6) >>> res = SparseVAR(y, order=2).fit(penalty="lasso") >>> res.coefficients.shape (2, 6, 6) >>> bool(res.sparsity > 0.3) True >>> SparseVAR(y, order=2).fit(penalty="ridge") Traceback (most recent call last): cultivars.exceptions.SpecificationError: penalty must be one of ('lasso', 'adaptive', ...
Attributes#
The validated sample. |
|
Whether a prior contributes anything to this estimate. |
|
Number of endogenous variables. |
|
Regressors per equation. |
|
Variable labels. |
|
Autoregressive order. |
|
The prior on the coefficients; |
|
Deterministic specification. |
Methods#
|
Estimate under one penalty family, selecting the level if unstated. |
|
Score every order from zero to |