TVPVAR#
- class cultivars.multivariate.nonlinear.time_varying.TVPVAR(endog, *, order, training=None, trend='c', names=None)[source]#
Time-varying-parameter VAR with constant innovation covariance.
The stacked coefficient vector follows a random walk, \(\beta_t = \beta_{t-1} + \eta_t\) with \(\eta_t \sim N(0, Q)\), and the innovations are homoskedastic, \(u_t \sim N(0, \Sigma)\). The priors come from a training sample split off the front: its OLS estimate \(\hat b_0\) and covariance \(\hat V_0\) give the initial state \(\beta_0 \sim N(\hat b_0, 4 \hat V_0)\), the drift covariance an inverse-Wishart prior with scale \(k_Q^2\,\nu_Q\,\hat V_0\) and \(\nu_Q = \max(\tau, D + 2)\) degrees of freedom, and \(\Sigma\) an inverse-Wishart prior centred on the training covariance with \(k + 2\) degrees of freedom. The training rows are then discarded.
- 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, from the base model.
_prior – The base slot, unused: the priors here 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, then discarded. Defaults to roughly forty, floored by what the prior regression needs.trend (
Literal['n','c','ct']) – Deterministic terms.names (
Sequence[str] |None) – One label per variable. Defaults toy1 ... yk.
- Raises:
SpecificationError – If the specification is malformed or the training sample is shorter than
w + k + 2rows, the floor at which the prior regression is identified.DimensionError – If fewer than
2 westimation rows remain after the training split.
See also
TVPVARResult– the recordfitreturns.TVPVARSV– the same drift with stochastic volatility.BVAR– the constant-coefficient conjugate model.
References
Cogley, T., & Sargent, T. J. (2005). Drifts and volatilities: Monetary policies and outcomes in the post WWII US. Review of Economic Dynamics, 8(2), 262-302.
Primiceri, G. E. (2005). Time varying structural vector autoregressions and monetary policy. Review of Economic Studies, 72(3), 821-852.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros((140, 2)) >>> for t in range(1, 140): ... a = 0.4 + 0.3 * t / 140 ... y[t] = a * y[t - 1] + rng.standard_normal(2) >>> res = TVPVAR(y, order=1, training=40).fit(n_draws=40, n_burn=15, seed=0) >>> res.coefficient_path("y1", "y1.L1").shape (99, 3) >>> TVPVAR(y, order=1).training, TVPVAR(y, order=2, training=20).training (40, 20) >>> TVPVAR(y, order=1, training=4) Traceback (most recent call last): cultivars.exceptions.SpecificationError: a training sample of 4 rows cannot identify ...
Attributes#
The validated sample. |
|
Whether a prior contributes anything to this estimate. |
|
Number of endogenous variables. |
|
Regressors per equation. |
|
Variable labels. |
|
Autoregressive order. |
|
The prior on the coefficients; |
|
Rows consumed by the training prior. |
|
Deterministic specification. |
Methods#
|
Estimate by Gibbs sampling. |
|
Score every order from zero to |