GibbsBVAR.fit#
- GibbsBVAR.fit(*, n_draws=2000, n_burn=500, thin=1, seed=None)[source]#
Run the Gibbs sampler and keep the post-burn draws.
Each sweep draws all coefficients jointly given the covariance, the covariance given the coefficients, and – under an adaptive prior – the scale hierarchy; the first
n_burnsweeps are discarded and everythin-th of the rest is kept. The sameseedreproduces the chain exactly.- Parameters:
- Return type:
- Returns:
The fitted
GibbsBVARResult.- Raises:
SpecificationError – If the prior is improper, mixes adaptive components into a composition, or the draw bookkeeping is inconsistent.
NumericalError – If a conditional draw collapses.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros((200, 2)) >>> for t in range(1, 200): ... y[t] = 0.5 * y[t - 1] + rng.standard_normal(2) >>> model = GibbsBVAR(y, order=1) >>> res = model.fit(n_draws=200, n_burn=50, thin=3, seed=0) >>> res.n_kept, res.n_draws, res.n_burn, res.thin (50, 200, 50, 3) >>> again = model.fit(n_draws=200, n_burn=50, thin=3, seed=0) >>> bool(np.array_equal(res.beta_draws, again.beta_draws)) True >>> model.fit(n_draws=50, n_burn=50) Traceback (most recent call last): cultivars.exceptions.SpecificationError: n_draws (50) must exceed n_burn (50).