*! version 1.1.0 07may2026

Title

qvar -- Quantile Vector Autoregression

Syntax

qvar subcommand [varlist] [, options]

where subcommand is one of

estimate estimate QVAR model equation-by-equation via quantile regression

granger quantile Granger causality with instability detection

varqr two-stage VAR-QR Growth-at-Risk model

forecast multi-step quantile forecasting via simulation

irf quantile impulse response functions

evaluate forecast evaluation (qwCRPS, Diebold-Mariano, coverage)

plot publication-quality visualizations

table formatted output tables (console, LaTeX, HTML)

Subcommand syntax

qvar estimate varlist , lags(#) [taus(numlist) recursive norecursive maxiter(#) tolerance(#)]

qvar granger depvar gcvar , lags(#) [controls(varlist) bootstrap(#) regimes noregimes alpha(#) supwald nosupwald taugrid(numlist)]

qvar varqr varlist , varlags(#) [qrlags(#) taus(numlist)]

qvar forecast , horizon(#) [nsims(#) seed(#) stress(string) variable(string)]

qvar irf , shockvar(varname) [shocksize(#) horizon(#) taupath(numlist) nboot(#) seed(#) compare(numlist)]

qvar evaluate varlist , actual(varname) [taus(numlist) weight(string) horizon(#) nominal(#)]

qvar plot plottype [, plot_options]

qvar table tabletype [, table_options]

Options

estimate options

lags(#) specifies the number of lags in the QVAR system. Required.

taus(numlist) specifies the quantile levels at which to estimate.
Default is 0.05 0.25 0.50 0.75 0.95.

recursive imposes a recursive (lower-triangular) contemporaneous
structure on the QVAR, where the ordering of variables in varlist
determines the Cholesky identification. This is the default.

norecursive omits contemporaneous regressors so that each equation
depends only on lagged values.

maxiter(#) sets the maximum number of QR iterations. Default is 1000.

tolerance(#) sets the QR convergence tolerance. Default is 1e-6.

granger options

lags(#) specifies the number of lags of the Granger-causing variable. Required.

controls(varlist) specifies additional control variables to include
in both the restricted and unrestricted quantile regressions.

bootstrap(#) specifies the number of bootstrap replications for
computing p-values. Default is 499.

regimes requests sequential regime detection (Algorithm 2 of
Mayer, Wied & Troster, 2025). This is the default.

noregimes skips the regime detection step.

alpha(#) specifies the significance level for regime detection.
Default is 0.10.

supwald computes the supWald comparison test of Koenker & Machado (1999).
This is the default.

nosupwald skips the supWald computation to save time.

taugrid(numlist) specifies the quantile grid over which to compute
the test statistics. Default is 0.05(0.01)0.95.

varqr options

varlags(#) specifies the number of lags for the Stage 1 OLS VAR. Required.

qrlags(#) specifies the number of lags for the Stage 2 quantile
regression on VAR residuals. Default is 1.

taus(numlist) specifies the quantiles for the residual QR stage.
Default is 0.10 0.90.

forecast options

horizon(#) specifies the forecast horizon (number of steps ahead). Required.
Requires a prior qvar estimate.

nsims(#) specifies the number of Monte Carlo simulation paths.
Default is 10000.

seed(#) sets the random number seed for reproducibility. Default is 42.

stress(string) specifies a stress-testing scenario.

variable(string) specifies the variable to focus the stress test on.

irf options

shockvar(varname) specifies the variable receiving the impulse shock. Required.
Requires a prior qvar estimate.

shocksize(#) specifies the magnitude of the shock in standard-deviation
units. Default is 1.0.

horizon(#) specifies the IRF horizon. Default is 20.

taupath(numlist) specifies the quantile path for the IRF computation.
Default is 0.50 (median).

nboot(#) specifies the number of bootstrap replications for
confidence bands. Default is 500.

seed(#) sets the random number seed. Default is 42.

compare(numlist) requests a comparison of IRFs across the specified
quantile paths.

evaluate options

actual(varname) specifies the variable containing realized values. Required.

taus(numlist) specifies the quantile levels corresponding to each
forecast variable in varlist. Default is 0.05 0.25 0.50 0.75 0.95.

weight(string) specifies the weight function for qwCRPS:
tails (default), left, right, or uniform.

horizon(#) specifies the forecast horizon for Diebold-Mariano HAC
variance. Default is 1.

nominal(#) specifies the nominal coverage probability for the
Christoffersen (1998) coverage test. Default is 0.90.

Subcommands

plot

qvar plot plottype [, options]

where plottype is one of

coef coefficient bubble heatmap across quantiles

cusum CUSUM process with optional breakpoint

regime Granger causality regime timeline bar

fan forecast fan chart with nested confidence bands

irf single-quantile IRF with confidence bands

irfcompare multi-quantile IRF comparison overlay

gar Growth-at-Risk time series plot

All plot types accept saving(filename) to export as PNG. The color
palette uses Teal (#0A6C74), Coral (#E8714A), Gold (#F4B942), Slate
(#4A5568), Lavender (#8B7EC8), Mint (#2ECC9B), and Rose (#E85D75).

table

qvar table tabletype [, options]

where tabletype is one of

summary QVAR model summary (after estimate)

coef coefficient table across quantiles with significance stars

granger Granger causality test results (after granger)

eval forecast evaluation results (after evaluate)

Table options include fmt(string) for output format (console,
latex, or html), taus(numlist) for coefficient tables,
and saving(filename) for file output.

Description

qvar implements Quantile Vector Autoregression models for Stata,
providing a comprehensive toolkit for quantile-based multivariate
time-series analysis. The package supports the complete QVAR workflow:
estimation, testing, forecasting, impulse responses, evaluation, and
publication-quality visualization.

Key features:

1. QVAR estimation (qvar estimate): Equation-by-equation quantile
regression with optional recursive (lower-triangular) contemporaneous structure
following Chavleishvili & Manganelli (2019). Estimates conditional quantile
functions Q_(tau | x) for each variable and quantile level.

2. Quantile Granger causality (qvar granger): Tests the joint null
of no Granger causality and constant parameters using supLM and expLM
statistics with bootstrap p-values (Algorithm 1 of Mayer, Wied & Troster,
2025). Includes sequential regime detection (Algorithm 2) and the supWald
comparison test of Koenker & Machado (1999).

3. VAR-QR model (qvar varqr): Two-stage Growth-at-Risk estimation
following Carboni et al. (2024). Stage 1 fits an OLS VAR for the conditional
mean; Stage 2 applies quantile regression to VAR residuals to extract
time-varying conditional volatility.

4. Quantile forecasting (qvar forecast): Multi-step ahead density
forecasting via Monte Carlo simulation using the random coefficient
representation of Surprenant (2025). Computes Expected Shortfall (ES) and
Expected Longrise (EL) risk measures.

5. Quantile IRF (qvar irf): Quantile impulse response functions
following White, Kim & Manganelli (2015) and Chavleishvili & Manganelli (2019).
Computes point IRFs via coefficient propagation with bootstrap confidence bands.
Supports multi-quantile comparison.

6. Forecast evaluation (qvar evaluate): Quantile-weighted CRPS
(Gneiting & Ranjan, 2011), Diebold-Mariano (1995) pairwise comparison with
HAC standard errors, and Christoffersen (1998) unconditional coverage test.

The data must be tsset before using qvar. Panel data is not
currently supported.

Examples

Setup

. webuse lutkepohl2, clear
. tsset qtr

1. QVAR estimation with recursive structure

. qvar estimate dln_inv dln_inc dln_consump, lags(1) taus(0.10 0.50 0.90) recursive

2. View estimation results

. ereturn list
. matrix list _qvar_b_0_50_eq1

3. Summary and coefficient tables

. qvar table summary
. qvar table coef, taus(0.10 0.50 0.90)
. qvar table coef, taus(0.10 0.50 0.90) fmt(latex)

4. Quantile Granger causality: income -> investment

. qvar granger dln_inv dln_inc, lags(1) bootstrap(499) regimes
. qvar table granger

5. VAR-QR Growth-at-Risk model

. qvar varqr dln_inv dln_inc dln_consump, varlags(2) taus(0.10 0.90)

6. Quantile IRF: shock to income

. qvar estimate dln_inv dln_inc, lags(1) taus(0.05 0.50 0.95)
. qvar irf, shockvar(dln_inc) horizon(20) shocksize(1) taupath(0.50)

7. Multi-step forecasting

. qvar estimate dln_inv dln_inc, lags(1) taus(0.05 0.25 0.50 0.75 0.95)
. qvar forecast, horizon(12) nsims(5000) seed(42)

8. Forecast evaluation

. qvar evaluate fc_q05 fc_q50 fc_q95, actual(dln_inv) taus(0.05 0.50 0.95) weight(tails)

9. Stationarity check (utility)

. _qvar_stationarity_check dln_inv dln_inc dln_consump

10. Publication-quality plots

. qvar plot coef, equation(dln_inv) taus(0.10 0.50 0.90) saving(coef_heatmap.png)
. qvar plot irf, irf(_qvar_irf_dln_inc_dln_inv) lower(_qvar_irf_lo_dln_inc_dln_inv) upper(_qvar_irf_hi_dln_inc_dln_inv)

Stored results

qvar estimate stores the following in e():

Scalars

e(n_vars) number of endogenous variables

e(n_lags) number of lags

e(n_obs) number of usable observations

e(n_taus) number of quantile levels

e(recursive) 1 if recursive structure used, 0 otherwise

Macros

e(cmd) qvar estimate

e(varnames) list of endogenous variable names

e(taus) list of quantile levels

Matrices

_qvar_b_tau_eq# coefficient vector for quantile tau, equation #

_qvar_se_tau_eq# standard error vector

Variables

_qvar_resid_ttau_var quantile regression residuals

qvar granger stores the following in e():

Scalars

e(n_obs) number of observations

e(n_gc_lags) number of GC lags

e(n_bootstrap) number of bootstrap replications

e(sup_lm) supLM test statistic

e(sup_lm_pval) bootstrap p-value for supLM

e(exp_lm) expLM test statistic

e(exp_lm_pval) bootstrap p-value for expLM

e(sup_wald) supWald statistic (if computed)

e(sup_wald_pval) simulation p-value for supWald

e(n_regimes) number of detected regimes (1 or 2)

e(breakpoint) breakpoint fraction (if 2 regimes)

e(bp_obs) breakpoint observation number

Macros

e(cmd) qvar granger

e(depvar) dependent variable

e(gcvar) Granger-causing variable

e(controls) control variables

Matrices

e(wald_stats) Wald statistics across quantile grid

qvar varqr stores the following in e():

e(cmd) qvar varqr

e(varnames) variable names

e(n_vars) number of variables

e(var_lags) number of VAR lags

e(qr_lags) number of QR lags

e(n_obs) number of observations

e(var_aic) VAR AIC

Variables

_varqr_resid_var VAR residuals for each variable

_varqr_sigma_var estimated time-varying volatility

qvar irf stores the following in e():

e(irf_horizon) IRF horizon

e(irf_shocksize) shock magnitude

e(irf_shockvar) shock variable name

e(irf_taupath) quantile path used

Variables

_qvar_irf_shock_resp point IRF

_qvar_irf_lo_shock_resp lower 68% confidence band

_qvar_irf_hi_shock_resp upper 68% confidence band

qvar forecast stores the following in e():

e(fc_horizon) forecast horizon

e(fc_nsims) number of simulations

e(fc_seed) random seed used

qvar evaluate stores the following in r():

r(qw_crps) quantile-weighted CRPS

r(dm_stat) Diebold-Mariano test statistic

r(dm_pval) Diebold-Mariano p-value

r(dm_diff) mean loss differential

r(coverage) empirical coverage probability

r(uc_stat) unconditional coverage LR statistic

r(uc_pval) unconditional coverage p-value

References

Carboni, G., Fonseca, L., Fornari, F. and Urrutia, A. (2024). Structural
Drivers of Growth-at-Risk. ECB Working Paper 3171.

Chavleishvili, S. and Manganelli, S. (2019). Forecasting and Stress Testing
with Quantile Vector Autoregression. ECB Working Paper 2330.

Christoffersen, P. (1998). Evaluating Interval Forecasts.
International Economic Review, 39(4), 841-862.

Diebold, F.X. and Mariano, R.S. (1995). Comparing Predictive Accuracy.
Journal of Business & Economic Statistics, 13(3), 253-263.

Gneiting, T. and Ranjan, R. (2011). Comparing Density Forecasts Using
Threshold- and Quantile-Weighted Scoring Rules.
Journal of Business & Economic Statistics, 29(3), 411-422.

Koenker, R. and Machado, J.A.F. (1999). Goodness of Fit and Related
Inference Processes for Quantile Regression.
Journal of the American Statistical Association, 94(448), 1296-1310.

Mayer, A., Wied, D. and Troster, B. (2025). Quantile Granger Causality in
the Presence of Instability. Journal of Econometrics, 249.

Surprenant, S. (2025). Quantile VARs and Macroeconomic Risk Forecasting.
Bank of Canada Staff Working Paper 2025-4.

White, H., Kim, T.-H. and Manganelli, S. (2015). VAR for VaR: Measuring
Tail Dependence Using Multivariate Regression Quantiles.
Journal of Econometrics, 187(1), 169-188.

Author

Dr. Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane/QVAR

Also see

Help: qreg, var, dfuller, bsample