Writing a Custom Prior#
Impulso uses typing.Protocol for extensibility. You can write your own prior by implementing the Prior protocol.
The Prior protocol#
Your build_priors method must return a dictionary with keys "B_mu" and "B_sigma", both NumPy arrays of shape (n_vars, n_vars * n_lags).
B_mu: Prior mean for VAR coefficient matrixB_sigma: Prior standard deviation for VAR coefficient matrix
sigma is required and keyword-only: a per-endogenous-variable scale, shape (n_vars,), that VAR.fit computes once via impulso._conjugate.ar1_residual_sd(data.endog) and passes to whichever Prior it holds. MinnesotaPrior uses it to scale each cross-lag prior standard deviation by sigma[i] / sigma[j] — see The Minnesota Prior. A prior with no use for the data’s scale still has to accept the argument; it can simply ignore it, as FlatPrior does below.