HierarchicalBVAR.fit#
- HierarchicalBVAR.fit(*, method='full', n_draws=1000, n_burn=500, seed=None)[source]#
Estimate the hyperparameter posterior, then the VAR under it.
Builds the active hyperparameter set and its Gamma hyperpriors from the modes and standard deviations the paper uses, finds the posterior mode, and either conditions on it (
"empirical") or runs the Metropolis chain from it ("full"), drawing(B, Sigma)at every kept state. The sameseedreproduces the chain exactly.- Parameters:
method (
str) –"full"marginalizes the(B, Sigma)draws over the hyperparameters by Metropolis;"empirical"conditions on the hyperparameter posterior mode.n_draws (
int) – Kept(B, Sigma)draws, at least 1.n_burn (
int) – Burn-in Metropolis iterations (full method), at least 0.seed (
int|Generator|None) – Seed or generator, for reproducibility.
- Return type:
- Returns:
The fitted
HierarchicalBVARResult.- Raises:
SpecificationError – If the method or counts are malformed.
NumericalError – If the mode search fails.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = 5.0 + rng.standard_normal((150, 2)) >>> model = HierarchicalBVAR(y, order=1) >>> full = model.fit(method="full", n_draws=100, n_burn=100, seed=0) >>> again = model.fit(method="full", n_draws=100, n_burn=100, seed=0) >>> bool(np.array_equal(full.hyper_draws, again.hyper_draws)) True >>> model.fit(method="map") Traceback (most recent call last): cultivars.exceptions.SpecificationError: method must be 'full' or 'empirical'; ... >>> model.fit(n_draws=0) Traceback (most recent call last): cultivars.exceptions.SpecificationError: n_draws must be positive and n_burn ...