TVPVARSVResult#

class cultivars.multivariate.nonlinear.time_varying.TVPVARSVResult(*, endog, names, order, trend, training, nobs, beta_mean, beta_low, beta_high, beta_draws, state_cov, sigma_u, resid, fittedvalues, n_draws, n_burn, thin, h_draws, impact_draws, vol_of_vol)[source]#

A fitted TVP-VAR with stochastic volatility, after Primiceri (2005).

Everything the homoskedastic result reports, plus the volatility side: the innovation covariance drifts through the triangular factorization

\[\Sigma_t = A^{-1} H_t A^{-\top}, \qquad H_t = \mathrm{diag}\bigl(e^{h_{1,t}}, \ldots, e^{h_{k,t}}\bigr), \qquad h_t = h_{t-1} + \zeta_t, \quad \zeta_t \sim N(0, W),\]

with \(A\) a constant unit-lower-triangular matrix and the log variances random walks drawn by the Kim-Shephard-Chib mixture sampler. The impact and log-variance draws are retained because the structural wrapper needs their posterior, not a point.

Note

sigma_u on this result is the posterior mean of the end-of-sample covariance \(\Sigma_T\); the full path is in h_draws and impact_draws. Because \(A\) is triangular in the order of names, the recursive identification is fixed when the model is fitted: TVPSVAR refuses a different ordering on this result.

Variables:
  • h_draws – (S, nobs, k) kept log-variance path draws.

  • impact_draws – (S, k, k) kept draws of A^{-1}.

  • vol_of_vol – (k,) posterior mean random-walk variances of the log volatilities.

See also

  • TVPVARSV – the model that produces this record.

  • TVPVARResult – the homoskedastic parent.

  • BVARSVResult – constant coefficients with the same drifting covariance.

References

Primiceri, G. E. (2005). Time varying structural vector autoregressions and monetary policy. Review of Economic Studies, 72(3), 821-852.

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.

Kim, S., Shephard, N., & Chib, S. (1998). Stochastic volatility: Likelihood inference and comparison with ARCH models. Review of Economic Studies, 65(3), 361-393.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros((140, 2))
>>> for t in range(1, 140):
...     y[t] = 0.5 * y[t - 1] + rng.standard_normal(2)
>>> res = TVPVARSV(y, order=1, training=40).fit(n_draws=40, n_burn=15, seed=0)
>>> res.h_draws.shape, res.impact_draws.shape, res.vol_of_vol.shape
((13, 99, 2), (13, 2, 2), (2,))
>>> bool(np.allclose(np.diagonal(res.impact_draws, axis1=1, axis2=2), 1.0))
True
>>> bool(np.allclose(res.impact_draws[0], np.tril(res.impact_draws[0])))
True
>>> res.volatility_path("y1").shape, res._family()
((99, 3), 'TVP-VAR-SV')

Attributes#

h_draws

(S, nobs, k) kept log-variance paths, orthogonalized shocks.

impact_draws

(S, k, k) kept draws of the unit-lower-triangular A^{-1}.

vol_of_vol

(k,) posterior mean random-walk variances of the log volatilities.

beta_draws

(S, nobs, D) kept coefficient-path draws.

beta_high

(nobs, D) posterior 84th-percentile path.

beta_low

(nobs, D) posterior 16th-percentile path.

beta_mean

(nobs, D) posterior mean coefficient path, equation-major.

endog

The observed panel, (nobs_total, k), training rows included.

fittedvalues

(nobs, k) one-step means at the posterior mean path.

k_endog

Number of endogenous variables.

n_burn

Iterations discarded from the start.

n_draws

Total sampler iterations, burn-in included.

n_kept

Posterior draws retained after burn-in and thinning.

names

Variable labels, in column order.

nobs

Estimation rows after the training split and the p presample rows.

order

The autoregressive order p.

resid

(nobs, k) residuals at the posterior mean path.

sigma_u

(k, k) posterior mean innovation covariance.

state_cov

(D, D) posterior mean drift covariance Q.

thin

Every thin-th post-burn iteration is kept.

training

Rows split off the front to calibrate the priors, then discarded.

trend

"n", "c" or "ct".

Methods#

coefficient_path(equation, regressor)

One coefficient's posterior path: 16th percentile, mean, 84th.

coefficients_at(t)

The posterior mean lag stack A_1..A_p prevailing at date t.

convergence(*chains[, include, exclude, ...])

Assess the sampler's convergence over the retained draws.

stability_path()

Largest companion-root modulus of the posterior mean VAR at each date.

summary()

The estimation summary, renderable as text, HTML, or a dataframe.

volatility_path(name)

One equation's posterior innovation standard deviation path.