tvpSvFit#
Estimate a Time-Varying Parameter VAR with Stochastic Volatility (Primiceri 2005).
Format#
- result = tvpSvFit(y[, ctl])#
- Parameters:
y (matrix or dataframe) – T x m matrix of endogenous variables.
ctl (struct tvpSvControl) – Optional. Control structure with estimation settings. Created by
tvpSvControlCreate().
- Returns:
result (struct tvpSvResult) – Estimation results including posterior draws of terminal B_T, SV parameters, and acceptance diagnostics.
Model#
The full Primiceri (2005) TVP-VAR-SV:
Three time-varying components: coefficients B_t (random walk), Cholesky off-diagonals U_t (random walk), and log-volatilities h_t (AR(1) stochastic volatility).
Example#
new;
library timeseries;
// US macro data
fname = getGAUSSHome("pkgs/timeseries/examples/data/us_macro_quarterly.csv");
y = loadd(fname, "gdp_growth + cpi_inflation + fed_funds");
// Estimate with defaults
result = tvpSvFit(y);
// Print terminal coefficients
print result.b_mean;
// With custom settings
ctl = tvpSvControlCreate();
ctl.p = 2;
ctl.n_draws = 10000;
ctl.n_burn = 10000;
result = tvpSvFit(y, ctl);
Control structure#
ctl.p |
Scalar, lag order. Default = 1. |
ctl.include_const |
Scalar, include constant (1) or not (0). Default = 1. |
ctl.n_draws |
Scalar, number of posterior draws to keep. Default = 5000. |
ctl.n_burn |
Scalar, number of burn-in iterations to discard. Default = 5000. |
ctl.n_thin |
Scalar, thinning factor. Default = 1 (keep every draw). |
ctl.seed |
Scalar, RNG seed for reproducibility. Default = 42. |
ctl.use_asis |
Scalar, enable ASIS interweaving for SV (recommended). Default = 1. |
ctl.q_b_shape |
Scalar, IG prior shape for B drift covariance Q_B diagonal elements. Q_B,jj ~ IG(shape, scale). Default = 6.0. |
ctl.q_b_scale |
Scalar, IG prior scale for Q_B. Default = 0.01 (slow drift). |
ctl.q_u_shape |
Scalar, IG prior shape for U drift covariance Q_U diagonal elements. Default = 6.0. |
ctl.q_u_scale |
Scalar, IG prior scale for Q_U. Default = 0.01. |
ctl.p0_b_kappa |
Scalar, diffuse initialization scale for B FFBS. P_0 = kappa * I. Default = 10.0. |
ctl.p0_u_kappa |
Scalar, diffuse initialization scale for U FFBS. Default = 10.0. |
ctl.u_bandwidth |
Scalar, band-limited drifting U. 0 = full (default), k > 0 = first k off-diagonals per column. See |
ctl.xreg |
Matrix, exogenous regressors (T x K). Empty = none. |
ctl.quiet |
Scalar, set to 1 to suppress printed output. Default = 0. |
Result structure#
result.m |
Scalar, number of endogenous variables. |
result.p |
Scalar, lag order. |
result.n_obs |
Scalar, effective sample size (T - p). |
result.n_draws |
Scalar, number of posterior draws kept. |
result.var_names |
String array, variable names (from dataframe column names, or empty). |
result.b_mean |
K x m matrix, posterior mean of terminal B_T (coefficients at the last observation). |
result.b_sd |
K x m matrix, posterior standard deviation of terminal B_T. |
result.sv_mu |
m x 1 vector, posterior mean of SV level parameters μ_i. |
result.sv_phi |
m x 1 vector, posterior mean of SV persistence parameters φ_i. |
result.sv_sigma2 |
m x 1 vector, posterior mean of SV innovation variance σ²_i. |
result.phi_accept_rate |
m x 1 vector, Metropolis-Hastings acceptance rate for φ per equation. Healthy range: 20-60%. |
Remarks#
The sampler uses equation-by-equation Carter-Kohn FFBS for B_t (Primiceri’s original approach), reducing the state dimension from K*m to K per equation.
The observation variance for each equation comes from the stochastic volatility h_{eq,t}, not a constant Sigma.
Q_B and Q_U have conjugate diagonal Inverse-Gamma posteriors.
B_0 is initialized from OLS and redrawn each iteration from its full conditional.
SV updates use the OCSN 10-component mixture approximation with optional ASIS interweaving.
Set
ctl.u_bandwidth> 0 for large systems (m > 15) to reduce U parameters.
See also#
tvpSvControlCreate()— create control structure with defaultsbvarSvFit()— SV-BVAR with constant coefficients (simpler model)varFit()— OLS VAR (simplest model)
References#
Primiceri, G. E. (2005). Time varying structural vector autoregressions and monetary policy. Review of Economic Studies, 72(3), 821-852.
Carter, C. K. & Kohn, R. (1994). On Gibbs sampling for state space models. Biometrika, 81(3), 541-553.
Del Negro, M. & Primiceri, G. E. (2015). Time varying structural vector autoregressions and monetary policy: A corrigendum. Review of Economic Studies, 82(4), 1342-1345.