UCSVPosterior#
- class cultivars.univariate.stochastic_volatility.UCSVPosterior(*, endog, gamma_fixed, trend_draws, h_draws, q_draws, gamma2_irregular_draws, gamma2_trend_draws, nobs, n_draws, n_burn, thin)[source]#
A posterior over the unobserved-components stochastic-volatility model.
- Variables:
gamma_fixed (
bool) – Whether the vol-of-vol was held fixed.h_draws (
NDArray[double]) –(S, n)log variances of the irregular.q_draws (
NDArray[double]) –(S, n)log variances of the trend innovation.gamma2_irregular_draws –
(S,)vol-of-vol variance draws of \(h\).gamma2_trend_draws (
NDArray[double]) –(S,)vol-of-vol variance draws ofq.nobs (
int) – Observations.n_draws (
int) – Total sampler iterations.n_burn (
int) – Burn-in discarded.thin (
int) – Post-burn thinning.
Stock and Watson’s (2007) model, in the timing the sampler uses:
y_t = tau_t + exp(h_t / 2) eps_t tau_{t+1} = tau_t + exp(q_t / 2) eta_t h_{t+1} = h_t + gamma_h nu_t q_{t+1} = q_t + gamma_q xi_t
Every path is sampled, so unlike
_SVPosteriorunder the particle chain the bands here carry path uncertainty. When the vol-of-vol was held fixed, the twogamma2arrays are constant.See also
UCSVPosterior– the public name of this class.UCSV.fit()– returns an instance.UCSVPosterior._from_fit()– returns an instance.
Example
>>> import numpy as np >>> from cultivars.univariate.stochastic_volatility import UCSV >>> rng = np.random.default_rng(0) >>> y = np.cumsum(0.2 * rng.standard_normal(120)) + 0.7 * rng.standard_normal(120) >>> post = UCSV(y).fit(n_draws=120, n_burn=60, seed=0) >>> isinstance(post, _UCSVPosterior), post.gamma_fixed, post.n_kept (True, True, 60) >>> post.trend.shape, post.trend_quantiles().shape ((120,), (3, 120)) >>> post.forecast(4, n_paths=50, seed=0).shape (50, 4)
Attributes#
The observed series, |
|
Whether the vol-of-vol was held fixed and not sampled. |
|
Kept trend paths \(\tau_t\), |
|
Kept log-variance paths of the irregular, |
|
Kept log-variance paths of the trend innovation, |
|
Kept draws of the step variance of \(h\), |
|
Kept draws of the step variance of |
|
Number of observations \(n\). |
|
Total sampler iterations, burn-in included. |
|
Iterations discarded as burn-in. |
|
Thinning interval applied after burn-in. |
|
The observed series minus the posterior-mean trend. |
|
Posterior-mean volatility of the irregular \(\mathbb{E}[\exp(h_t / 2) \mid y]\). |
|
Posterior draws retained. |
|
The posterior-mean parameter record. |
|
The model at the posterior mean, on the nonlinear substrate. |
|
Posterior-mean trend, |
|
Posterior-mean trend-innovation volatility, \(\mathbb{E}[\exp(q_t / 2) \mid y]\). |
|
Fitted values of the host record. |
|
Residuals of the host record. |
Methods#
|
Assess the sampler's convergence over the retained draws. |
|
Predictive draws of the series, |
|
The estimation summary, renderable as text, HTML, or a dataframe. |
|
The aligned per-observation outputs as plain numpy arrays. |
|
The aligned per-observation outputs as a |
The aligned per-observation outputs as a |
|
|
Pointwise posterior quantiles of the trend, |