HierarchicalBVARResult#
- class cultivars.multivariate.large_dim.hierarchical.HierarchicalBVARResult(*, endog, names, order, trend, prior_label, coefficients, deterministic, beta_mean, sigma_u, beta_draws, sigma_draws, log_marginal_likelihood, posterior_df, resid, fittedvalues, nobs, n_dummy, hyper_names, hyper_mode, hyper_draws, acceptance_rate, method)[source]#
A fitted hierarchical BVAR: the tightness carries a posterior too.
Everything the conjugate result reports, with one change of meaning and one addition. The change: under the full method the retained
(B, Sigma)draws marginalize over the hyperparameters \(\theta = (\lambda, \mu, \delta)\),\[p(B, \Sigma \mid y) = \int p(B, \Sigma \mid y, \theta)\, p(\theta \mid y)\, d\theta, \qquad p(\theta \mid y) \propto p(y \mid \theta)\, p(\theta),\]with \(p(y \mid \theta)\) the conjugate model’s closed-form marginal likelihood, so every band downstream – coefficients, impulse responses, the predictive – includes hyperparameter uncertainty;
log_marginal_likelihoodis the value at the hyperparameter mode, conditional on it. The addition is the hyperparameter layer itself: the posterior mode, the kept draws, and the chain’s acceptance rate.Note
Under
method="empirical"the(B, Sigma)draws condition onhyper_mode,hyper_drawsis empty andacceptance_rateisnan;hyperparameter_intervalrefuses. A hyperparameter whose dummies carry no information –muwhen the presample mean is zero, since the sum-of-coefficients rows are that mean divided bymu– has a posterior equal to its hyperprior and a mode at the search’s start; the marginal likelihood is flat in it, which is correct and worth noticing. The summary’s acceptance-rate guidance is for the kept span; a short run after a long adaptive burn-in can sit above it without harm.- Variables:
hyper_names – One label per hyperparameter, in draw-column order –
"lambda", then"mu"and"delta"when active, parameterized as in Giannone-Lenza-Primiceri.hyper_mode – Posterior-mode hyperparameter vector.
hyper_draws –
(S, d)kept hyperparameter draws; empty under empirical Bayes.acceptance_rate – Metropolis acceptance over the kept span;
nanunder empirical Bayes.method –
"full"or"empirical".
See also
HierarchicalBVAR– the model that produces this record.BVARResult– the conjugate record this one extends, with the tightness fixed.
References
Giannone, D., Lenza, M., & Primiceri, G. E. (2015). Prior selection for vector autoregressions. Review of Economics and Statistics, 97(2), 436-451.
Example
The full hierarchy on a bivariate VAR(1): the tightness has a posterior, the mode agrees with the empirical-Bayes fit, and the coefficient bands marginalize over it:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros((150, 2)) >>> for t in range(1, 150): ... y[t] = 0.6 * y[t - 1] + rng.standard_normal(2) >>> y += 5.0 >>> model = HierarchicalBVAR(y, order=1) >>> full = model.fit(method="full", n_draws=300, n_burn=300, seed=0) >>> full.method, full.hyper_names, full.hyper_draws.shape, full.n_kept ('full', ('lambda', 'mu', 'delta'), (300, 3), 300) >>> low, mean, high = full.hyperparameter_interval("lambda") >>> bool(0.0 < low < mean < high < 1.0), bool(0.1 < full.acceptance_rate < 0.9) (True, True) >>> empirical = model.fit(method="empirical", n_draws=100, seed=0) >>> bool(np.allclose(empirical.hyper_mode, full.hyper_mode)) True >>> bool(empirical.log_marginal_likelihood == full.log_marginal_likelihood) True
Attributes#
|
|
|
|
|
|
Metropolis acceptance over the kept span; |
|
|
|
|
|
|
|
|
|
|
|
The observed panel, |
|
|
|
Number of endogenous variables, |
|
Log marginal likelihood of the sample given the prior, in closed form. |
|
Artificial rows the prior contributed to the update. |
|
Posterior draws retained, |
|
Variable labels, one per column of |
|
the rows the posterior was updated on, dummy rows excluded. |
|
The effective sample the replications are shaped like, |
|
the number of lag blocks in |
|
Inverse-Wishart posterior degrees of freedom \(\bar\nu\). |
|
Short description of the prior the posterior was updated under. |
|
|
|
|
|
|
|
Posterior probability that the system is stable. |
|
|
Methods#
|
Assess the sampler's convergence over the retained draws. |
|
Posterior summary of one coefficient: 16th percentile, mean, 84th percentile. |
|
The posterior predictive: parameter and shock uncertainty. |
|
The posterior predictive's raw simulated paths, one per retained draw. |
|
One hyperparameter's posterior summary: 16th percentile, mean, 84th. |
|
Posterior mean impulse responses. |
|
Posterior bands of the impulse responses. |
The closed-form log marginal likelihood as a comparable record. |
|
|
Replicated effective samples, one per posterior draw used. |
|
A fresh sample path from the fitted system at the posterior mean or at one draw. |
|
The estimation summary, renderable as text, HTML, or a dataframe. |