MinnesotaPrior#
- class impulso.priors.MinnesotaPrior(*, tightness=0.1, decay='harmonic', cross_shrinkage=0.5, own_lag_mean=1.0)[source]#
Bases:
ImpulsoModelMinnesota 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, whoseselectflag 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:
- 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:
- 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.
- 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:
- 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:
- model_config = {'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].