NaturalConjugate¶
The NaturalConjugate model implements Bayesian VAR estimation with a Natural-Conjugate Normal-Inverse-Wishart prior. Conjugacy gives a closed-form posterior, so the model needs neither MCMC nor burn-in. This makes it a fast and versatile option for most applications.
Constructor arguments (minnesota, soc, sur, covid, covid_dates) are documented on SamplingModel; soc and sur default to True.
Prior Structure¶
The prior is specified jointly over the coefficients and the covariance matrix:
where \(V_A^{-1}\) is the \((k \times k)\) per-equation prior precision matrix (Minnesota form) and \(\beta_0\) encodes the random-walk prior means. After observing data \(Y\), the posteriors update to known closed-form distributions, from which draws are taken directly.
Hyperparameters¶
| Parameter | Description | Default |
|---|---|---|
c1 |
Overall shrinkage / tightness | 0.2 |
c3 |
Lag-decay exponent | 2.0 |
mu |
SOC tightness (if soc=True) |
1.0 |
theta |
SUR tightness (if sur=True) |
1.0 |
lambda_covid |
COVID-dummy prior variance | 10 000 |
Hyperparameters can be set manually via set_priors() or optimised automatically with BVAR.optimise_hyperparameters() (uses marginal-likelihood maximisation).
Example¶
import bvar as bv
model = bv.NaturalConjugate(
minnesota=True,
soc=True,
sur=True,
covid=True,
)
bvar = bv.BVAR(n_lags=4, model=model, stationary=False, optimisation_method="ml")
bvar.optimise_hyperparameters(data)
bvar.sample(data, N_draws=5000)
API¶
bvar.NaturalConjugate ¶
NaturalConjugate(minnesota: bool = True, soc: bool = True, sur: bool = True, covid: bool = False, covid_dates: Optional[list] = None)
BVAR with Natural-Conjugate (Normal-Inverse-Wishart) priors.
The prior is vec(A) | Σ ~ N(β₀, Σ ⊗ V_A⁻¹) and
Σ ~ IW(S₀, ν₀). Posterior sampling follows Chan (2020).
| ATTRIBUTE | DESCRIPTION |
|---|---|
requires_burnin |
TYPE:
|
supports_ml |
TYPE:
|
sample ¶
sample(data: ndarray, n_lags: int, covid_indices: ndarray, vars_in_levels: ndarray, N_draws: int, point_only: bool = False, progressbar: bool = True, soc: Optional[bool] = None, sur: Optional[bool] = None, rng: Optional[Generator] = None) -> SamplingResult
Run the full conjugate estimation pipeline.
sample_posterior_state ¶
sample_posterior_state(Y: ndarray, Z: ndarray, current_state: PosteriorState, rng: Optional[Generator] = None) -> PosteriorState
Return a single random posterior draw as a PosteriorState.
Draws one sample from the known Normal-Inverse-Wishart posterior
using the stored prior (self.beta_0, self.V_A_inv,
self.pars.S_0, self.pars.nu_0) from the last call to
:meth:sample. The method accepts current_state for interface
compatibility but ignores it because the posterior comes directly
from the closed-form distribution rather than an MCMC update.