TVPVARSV.fit#

TVPVARSV.fit(*, n_draws=2000, n_burn=1000, thin=2, k_drift=0.01, k_vol=0.01, seed=None)[source]#

Estimate by Gibbs sampling with the KSC volatility block.

Each iteration draws the coefficient path given the current covariance path, Q given the increments, and then the volatility block – the log-variance paths through the KSC mixture with the simulation smoother, the rows of A, and the diagonal W – given the residuals.

Parameters:
  • n_draws (int) – Total sampler iterations.

  • n_burn (int) – Burn-in iterations discarded.

  • thin (int) – Keep every thin-th post-burn draw.

  • k_drift (float) – Primiceri’s k_Q: prior scale of coefficient drift.

  • k_vol (float) – Primiceri’s k_W: prior scale of the log-volatility random walk.

  • seed (int | Generator | None) – Seed or generator.

Return type:

TVPVARSVResult

Returns:

The fitted TVPVARSVResult.

Raises:

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.n_kept, res.h_draws.shape, res.impact_draws.shape
(13, (13, 99, 2), (13, 2, 2))
>>> isinstance(res, TVPVARResult), type(res).__name__
(True, 'TVPVARSVResult')