GibbsBVARResult.inclusion_probabilities#
- GibbsBVARResult.inclusion_probabilities()[source]#
Posterior inclusion probability of each lag coefficient.
Entry
[lag, i, j]is the posterior probability that variablej’s coefficient at that lag in equationisits in the slab – is included – averaged over kept sweeps (Rao-Blackwellized: the averaged quantity is the exact conditional probability, not the binary indicator).- Return type:
- Returns:
A
(p, k, k)stack aligned withcoefficients.- Raises:
SpecificationError – If the prior was not a selection prior – only a spike-and-slab posterior defines inclusion.
Example
>>> import numpy as np >>> from cultivars.bayes.priors import HorseshoePrior, SpikeAndSlabPrior >>> rng = np.random.default_rng(0) >>> y = np.zeros((200, 3)) >>> for t in range(1, 200): ... y[t] = 0.6 * y[t - 1] + rng.standard_normal(3) >>> res = GibbsBVAR(y, order=1, prior=SpikeAndSlabPrior()).fit( ... n_draws=300, n_burn=100, seed=0 ... ) >>> included = res.inclusion_probabilities() >>> included.shape, bool(np.all((0 <= included) & (included <= 1))) ((1, 3, 3), True) >>> bool(np.all(np.diag(included[0]) > 0.9)) True >>> GibbsBVAR(y, order=1, prior=HorseshoePrior()).fit( ... n_draws=60, n_burn=20, seed=0 ... ).inclusion_probabilities() Traceback (most recent call last): cultivars.exceptions.SpecificationError: inclusion probabilities exist only under ...