HierarchicalBVAR#
- class cultivars.multivariate.large_dim.hierarchical.HierarchicalBVAR(endog, *, order, sum_of_coefficients=True, dummy_initial_observation=True, decay=1.0, exogenous=100.0, persistence=1.0, trend='c', names=None)[source]#
Giannone-Lenza-Primiceri hierarchical shrinkage over the conjugate BVAR.
The conjugate Normal-inverse-Wishart prior with Minnesota moments is indexed by the overall tightness \(\lambda\) and, when the dummy-observation priors are included, by the sum-of-coefficients looseness \(\mu\) and the dummy-initial-observation looseness \(\delta\) (larger is looser, as in the paper). Each carries a Gamma hyperprior – mode 0.2 and standard deviation 0.4 for \(\lambda\), mode 1 and standard deviation 1 for \(\mu\) and \(\delta\) – and the conjugate model’s closed-form marginal likelihood \(p(y \mid \theta)\) is the likelihood of the hyperparameter posterior.
fitfinds its mode by direct optimization in log space and, under the full method, explores it by adaptive random-walk Metropolis, drawing one(B, Sigma)from the exact conditional posterior at every kept state. The lag decay, the deterministic looseness and the persistence prior mean are held fixed, as in the paper.- Variables:
_endog – The validated
(nobs_total, k)panel._order – The autoregressive order.
_trend – The deterministic specification.
_names – One label per variable.
_prior – The prior at the hyperprior modes, the search’s start.
_soc – Whether the sum-of-coefficients dummies are active.
_dio – Whether the dummy-initial-observation row is active.
_decay – The fixed Minnesota lag decay.
_exogenous – The fixed looseness of the deterministic block.
_persistence – The fixed prior mean of each own first lag.
- Parameters:
endog (
ArrayLike) – The observed panel, shape(nobs, k).order (
int) – Autoregressive order, at least 1.sum_of_coefficients (
bool) – Include the sum-of-coefficients dummies, with their loosenessmuas a hyperparameter.dummy_initial_observation (
bool) – Include Sims’ co-persistence dummy, with its loosenessdeltaas a hyperparameter.decay (
float) – Minnesota lag decay, held fixed as in the paper.exogenous (
float) – Looseness of the deterministic block, held fixed.persistence (
float|Sequence[float]) – Prior mean of each variable’s own first lag, one value for all or one per variable.trend (
Literal['n','c','ct']) – Deterministic terms,"n","c"or"ct".names (
Sequence[str] |None) – One label per variable. Defaults toy1 ... yk.
- Raises:
SpecificationError – If
trendis not one of the three names,namesdoes not have one entry per column, or the prior’s own validation ofdecay,exogenousorpersistencefails.DimensionError – If the panel is not a time-down-the-rows matrix or too short for the order.
See also
HierarchicalBVARResult– the recordfitreturns.BVAR– the conjugate model at a fixed tightness.NormalInverseWishartPrior– the prior family the hierarchy ranges over.
References
Giannone, D., Lenza, M., & Primiceri, G. E. (2015). Prior selection for vector autoregressions. Review of Economics and Statistics, 97(2), 436-451.
Example
>>> 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) >>> res = HierarchicalBVAR(y, order=1).fit( ... method="empirical", n_draws=100, seed=0 ... ) >>> res.hyper_names ('lambda', 'mu', 'delta') >>> res.beta_draws.shape (100, 3, 2) >>> lambda_only = HierarchicalBVAR( ... y, order=1, sum_of_coefficients=False, dummy_initial_observation=False ... ).fit(method="empirical", n_draws=50, seed=0) >>> lambda_only.hyper_names, lambda_only.prior_label, lambda_only.n_dummy (('lambda',), 'glp(lambda)', 0)
Attributes#
The validated sample. |
|
Whether a prior contributes anything to this estimate. |
|
Number of endogenous variables. |
|
Regressors per equation. |
|
Variable labels. |
|
The effective sample a replication is shaped like, |
|
Autoregressive order. |
|
The prior on the coefficients; |
|
Deterministic specification. |
Methods#
|
Estimate the hyperparameter posterior, then the VAR under it. |
|
Score every order from zero to |
|
Data sets the prior generates, shaped like the effective sample. |