TVPVARSV#

class cultivars.multivariate.nonlinear.time_varying.TVPVARSV(endog, *, order, training=None, trend='c', names=None)[source]

Bases: TVPVAR

Time-varying-parameter VAR with stochastic volatility, after Primiceri (2005).

Coefficients drift as in TVPVAR; in addition the innovation covariance moves every period through

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

with a constant unit-lower-triangular \(A\) and random-walk log variances – the cited workhorse for “has policy changed, or have the shocks?”, which is unanswerable with either ingredient alone. The log-variance block is the Kim-Shephard-Chib mixture sampler; the rows of \(A\) are Gaussian regressions of each orthogonalized residual on the ones above it; \(W\) is diagonal, each entry an inverse-Gamma draw with prior scale set by k_vol.

The triangular factorization is taken in the order of names, and that ordering is a structural declaration made at estimation time; see TVPSVAR.

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, in the recursive order, from the base model.

  • _prior – The base slot, unused: the priors come from the training sample.

  • _training – The resolved training-sample length.

Parameters:
  • endog (ArrayLike) – The observed panel, shape (nobs, k).

  • order (int) – Autoregressive order.

  • training (int | None) – Rows split off the front to calibrate the priors.

  • trend (Literal['n', 'c', 'ct']) – Deterministic terms.

  • names (Sequence[str] | None) – One label per variable, in the intended recursive order.

Raises:
  • SpecificationError – If the specification is malformed or the training sample is below the identification floor.

  • DimensionError – If too few estimation rows remain after the split.

See also

  • TVPVARSVResult – the record fit returns.

  • TVPVAR – the homoskedastic parent.

  • BVARSV – constant coefficients with the same volatility block.

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

Innovations whose scale triples over the sample; with the volatility prior loosened the posterior mean path ends well above where it starts, while the default k_vol barely lets it move:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros((140, 2))
>>> for t in range(1, 140):
...     scale = 0.5 + 1.0 * t / 140
...     y[t] = 0.5 * y[t - 1] + scale * rng.standard_normal(2)
>>> res = TVPVARSV(y, order=1, training=40).fit(n_draws=40, n_burn=15, seed=0)
>>> res.volatility_path("y1").shape
(99, 3)
>>> model = TVPVARSV(y, order=1, training=40)
>>> loose = model.fit(n_draws=40, n_burn=15, k_vol=0.1, seed=0).volatility_path("y1")[:, 1]
>>> tight = res.volatility_path("y1")[:, 1]
>>> bool(loose[-1] / loose[0] > 2.0), bool(tight[-1] / tight[0] < 1.3)
(True, True)