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, column equation – from every retained draw and summarizes the S values 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 mean beta_mean[r, e] as S grows but is not identical to it. For a different quantile, a joint region, or a functional of several coefficients, work from beta_draws directly with the same indices.

Parameters:
  • equation (str) – The endogenous variable whose equation the coefficient belongs to; one of names.

  • regressor (str) – The per-equation regressor label: "const", "trend" (only when trend is "ct"), or "{name}.L{lag}" with name in names and lag in 1 .. p.

Return type:

NDArray[double]

Returns:

A (3,) array (low, mean, high) – the 16th percentile, the mean, and the 84th percentile of the coefficient across beta_draws.

Raises:

SpecificationError – If equation is not one of names, or regressor is 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').