MinnesotaPrior#

class impulso.priors.MinnesotaPrior(*, tightness=0.1, decay='harmonic', cross_shrinkage=0.5, own_lag_mean=1.0)[source]#

Bases: ImpulsoModel

Minnesota prior for VAR coefficient shrinkage.

tightness is always held fixed at the value supplied; there is no estimation path for it. That is the deliberate contrast with NIWPrior, whose select flag estimates the tightness by marginal likelihood — the independent-Normal coefficient prior used here has no closed-form marginal likelihood to maximise, so the shrinkage stays a modelling choice rather than an estimand.

Parameters:
tightness#

Overall shrinkage toward prior mean. Must be > 0. Always fixed, never estimated from the data.

Type:

float

decay#

How coefficients shrink on longer lags.

Type:

Literal[‘harmonic’, ‘geometric’]

cross_shrinkage#

Shrinkage on other variables’ lags vs own. 0 = only own lags, 1 = equal.

Type:

float

own_lag_mean#

Prior mean of each variable’s own first-lag coefficient (the Minnesota δᵢ): 1 for a random-walk series, 0 for a stationary one. A scalar applies to every variable; a sequence gives one entry per variable, in endog_names order, and its length is checked against n_vars in build_priors. Must be finite.

Type:

float | tuple[float, …]

Expand for references to impulso.priors.MinnesotaPrior

The Minnesota Prior / Usage

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

The Minnesota Prior, From Scratch

build_priors(n_vars, n_lags, *, sigma)[source]#

Build prior mean and standard deviation arrays for VAR coefficients.

The prior standard deviation on the coefficient linking lag l of variable j to the equation for variable i is scaled by sigma[i] / sigma[j] — the textbook Minnesota/Litterman cross-lag form, and the same ratio the conjugate NIWPrior already applies via minnesota_dummies. On own lags (i == j) the ratio is sigma[i] / sigma[i], which is 1 for any finite nonzero sigma[i], so this leaves the own-lag standard deviations unchanged; it only rescales cross-lag entries. That “1” would break down if sigma[i] were exactly zero (0.0 / 0.0 is nan, not 1) — see the warning below for why that case cannot reach here. See docs/adr/0015 for why the scaling itself is always on, with no opt-out.

Warning

A near-zero but nonzero sigma[c] (e.g. data.endog[:, c] is numerically flat but not exactly constant) is accepted, not guarded against: every cross-lag entry in row c (sigma[c] in the numerator) collapses toward zero, and every cross-lag entry in every other row that references variable c’s lag (sigma[c] in the denominator) blows up instead — the ratio can reach 1e12 or more for an otherwise-ordinary numerically near-constant column. That is by design: the column still varies, so it is still a real, identified variable: it just gets an effectively flat, uninformative cross-lag prior everywhere but its own equation.

An exactly-zero or non-finite sigma[c] is different in kind, not degree — the own-lag entry B_sigma[c, c] would be 0.0 / 0.0, i.e. nan, not the unscaled value the “ratio is 1 on own lags” description above promises — and is rejected: see Raises below. impulso.data.VARData also rejects endogenous columns that are exactly constant over the whole sample before sigma is ever computed from them, and VAR._build_pymc_model checks the sigma it computes before calling this method, so both guards run ahead of build_priors on the normal VAR.fit / VAR.prior_predictive path. The check here exists for callers who construct MinnesotaPrior and call build_priors directly, supplying their own sigma.

Parameters:
  • n_vars (int) – Number of endogenous variables.

  • n_lags (int) – Number of lags.

  • sigma (ndarray) – Per-variable scale, shape (n_vars,) — typically impulso._conjugate.ar1_residual_sd(data.endog). Required and keyword-only (see Prior.build_priors). Every entry must be finite and strictly positive.

Returns:

Dictionary with keys ‘B_mu’ and ‘B_sigma’ as numpy arrays. B_mu is own_lag_mean on each variable’s own first lag and 0 everywhere else.

Raises:
  • ValueError – If sigma does not have length n_vars, or if any entry of sigma is zero, negative, or non-finite.

  • ValueError – If own_lag_mean is a sequence whose length is not n_vars.

Return type:

dict[str, ndarray]

model_config = {'frozen': True}#

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