HierarchicalBVARResult.credible_interval#
- HierarchicalBVARResult.credible_interval(equation, regressor)[source]#
Posterior summary of one coefficient: 16th percentile, mean, 84th percentile.
Selects the scalar \(B_{r,e}\) – row
regressor, columnequation– from every retained draw and summarizes theSvalues by their 16th percentile, arithmetic mean, and 84th percentile. The interval is the 68% central credible interval of that coefficient’s marginal posterior, one standard deviation wide under normality, which is the convention every band on this result uses. The middle entry is the Monte Carlo mean of the draws; it approaches the exact posterior meanbeta_mean[r, e]asSgrows but is not identical to it. For a different quantile, a joint region, or a functional of several coefficients, work frombeta_drawsdirectly with the same indices.- Parameters:
- Return type:
- Returns:
A
(3,)array(low, mean, high)– the 16th percentile, the mean, and the 84th percentile of the coefficient acrossbeta_draws.- Raises:
SpecificationError – If
equationis not one ofnames, orregressoris not a label the fitted design has. The message lists the admissible labels.
Example
>>> import numpy as np >>> from cultivars.multivariate.large_dim.bayesian import BVAR >>> rng = np.random.default_rng(0) >>> y = np.zeros((120, 2)) >>> for t in range(1, 120): ... y[t] = 0.7 * y[t - 1] + rng.standard_normal(2) >>> res = BVAR(y, order=1, names=("growth", "inflation")).fit(n_draws=200, seed=0) >>> low, mean, high = res.credible_interval("growth", "growth.L1") >>> bool(low < mean < high) True >>> bool(abs(mean - res.beta_mean[1, 0]) < 0.05) True >>> res.credible_interval("growth", "growth.L2") Traceback (most recent call last): ... cultivars.exceptions.SpecificationError: unknown regressor 'growth.L2'; expected one of ('const', 'growth.L1', 'inflation.L1').