QVAR#
- class cultivars.multivariate.nonlinear.quantile.QVAR(endog, *, order, trend='c', names=None)[source]
Bases:
_QuantileVectorAutoRegressionModel[QVARResult]Quantile vector autoregression, after Koenker and Bassett, equation by equation.
Models the conditional \(\tau\)-quantile of every variable as linear in the system’s lags, with its own coefficient stack at every requested level,
\[Q_\tau(y_{i,t} \mid y_{t-1}, \ldots, y_{t-p}) = c_i(\tau)' d_t + \sum_{l=1}^{p} a_{i,l}(\tau)' y_{t-l},\]so the tails get their own dynamics rather than the mean’s dynamics plus a symmetric error. Each equation at each level is one exact check-loss linear program, solved by HiGHS in primal form: the residual is split into its positive and negative parts, priced at \(\tau\) and \(1 - \tau\), under \(X\beta + u - v = y\). Equations and levels separate because the check loss is additive across both, so a fit is \(k \times Q\) independent programs over one design. No prior surface is offered: the base’s shrinkage prior is a Gaussian belief about conditional-mean coefficients and has no meaning for a check loss.
- Variables:
_endog – The observed panel, from the base model.
_order – The autoregressive order
p, from the base model._trend – The deterministic specification, from the base model.
_names – The variable labels, from the base model.
_prior – The base slot, held at
_NoPriorbecause no prior is offered.
- Parameters:
- Raises:
SpecificationError – If the panel, order, trend or names are malformed.
DimensionError – If the sample cannot support the specification.
See also
QVARResult– the recordfitreturns.VAR– the conditional-mean system on the same design.GARCH– a moving tail modelled through the variance instead.
References
Koenker, R., & Bassett, G. (1978). Regression quantiles. Econometrica, 46(1), 33-50.
White, H., Kim, T.-H., & Manganelli, S. (2015). VAR for VaR: Measuring tail dependence using multivariate regression quantiles. Journal of Econometrics, 187(1), 169-188.
Adrian, T., Boyarchenko, N., & Giannone, D. (2019). Vulnerable growth. American Economic Review, 109(4), 1263-1289.
Example
On a Gaussian VAR(1) the three levels share the same lag coefficients and differ in their intercepts, which order with the level:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros((200, 2)) >>> for t in range(1, 200): ... y[t] = 0.5 * y[t - 1] + rng.standard_normal(2) >>> res = QVAR(y, order=1).fit(quantiles=(0.25, 0.5, 0.75)) >>> res.coefficients(0.5).shape (1, 2, 2) >>> res.quantile_path("y1", 0.75).shape (199,) >>> spread = res.coefficient_stacks.max(axis=0) - res.coefficient_stacks.min(axis=0) >>> bool(spread.max() < 0.3) True >>> intercepts = res.deterministics[:, 0, 0] >>> bool(intercepts[0] < intercepts[1] < intercepts[2]) True >>> QVAR(y, order=1, names=("a", "b")).fit(quantiles=(0.5,)).names ('a', 'b')