ConjugateVAR#

class impulso.conjugate.ConjugateVAR(*, lags, prior, volatility=None, draws=1000, tune=1000, seed=None)[source]#

Bases: ImpulsoBaseModel

Closed-form conjugate (Normal-Inverse-Wishart) Bayesian VAR estimator.

Parameters:
lags#

Number of lags p (>= 1).

Type:

int

prior#

The conjugate Minnesota NIWPrior.

Type:

impulso.priors.NIWPrior

volatility#

Optional deterministic volatility break (ConjugateVolatility), or None for a homoscedastic conjugate VAR. The break must declare at least one hyperparameter to estimate; an adapter with none is rejected at construction because the closed-form fast path would silently ignore it.

Type:

impulso.conjugate_volatility.ConjugateVolatility | None

draws#

Number of retained posterior draws.

Type:

int

tune#

Number of Metropolis warm-up iterations (ignored on the fixed-prior fast path).

Type:

int

seed#

Seed for the single RNG driving selection, sampling and coefficient draws.

Type:

int | None

Expand for references to impulso.conjugate.ConjugateVAR

The conjugate VAR: fast Bayesian estimation / When to reach for ConjugateVAR instead of the NUTS VAR / Scope

Estimating a VAR after March 2020 / What this reproduction does and does not match

fit(data)[source]#

Estimate the conjugate VAR and pack the draws into a FittedVAR.

Parameters:

data (VARData) – Endogenous data to fit.

Returns:

A FittedVAR whose posterior holds B (lag coefficients only), intercept, the base Cholesky factor L, and every estimated hyperparameter (e.g. lambda_, s_march, s_april, s_may, rho), all with a singleton chain dimension. The posterior’s attrs carry in_sample_length (observations after lag trimming) so volatility adapters can anchor forecast paths at the true sample end, and — only when at least one hyperparameter was estimated — metropolis_acceptance_rate, the acceptance rate of the random-walk Metropolis sampler over the retained draws. On the fixed-prior fast path no Metropolis chain runs (draws come straight from the closed-form posterior), so the attr is absent rather than stamped with a meaningless 1.0. FittedVAR.evidence carries the closed-form log marginal likelihood at the selected hyperparameters together with the metadata impulso.compare_evidence needs to form Bayes factors.

Raises:

ValueError – If data carries exogenous regressors — the conjugate engine estimates endogenous dynamics only, and silently dropping the exog block would corrupt every downstream forecast.

Return type:

FittedVAR

model_config = {'arbitrary_types_allowed': True, 'frozen': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].