ModelEvidence#

class impulso.evidence.ModelEvidence(*, log_marginal_likelihood, n_obs, n_vars, var_names, n_lags, volatility=None, hyperparameters=<factory>, sample_start, sample_end, sample_digest)[source]#

Bases: ImpulsoBaseModel

Closed-form log marginal likelihood of a conjugate VAR, with comparability metadata.

The value is the log density of the observed response block given the presample and the hyperparameters,

log p(y_{p+1:T} | y_{1:p}, hyperparameters, model),

with three properties worth stating explicitly:

  • It is a density over the observed data. When a deterministic volatility break rescales the sample, the change-of-variables Jacobian is included, so a break model and a homoscedastic model fitted to the same observations are directly comparable.

  • It is conditional on the hyperparameters in hyperparameters. With NIWPrior(select=True) those were chosen by maximising evidence times hyperprior, so a ratio of two such values is an empirical-Bayes (conditional) Bayes factor, not a fully marginal one. When hyperparameters is empty — a fixed prior with no volatility break — nothing was selected and the value is the full marginal likelihood of the model.

  • It conditions on the presample, so models with different lag orders condition on different initial rows. Fixing the response window and conditioning on initial conditions is the standard practice (Giannone, Lenza and Primiceri 2015), but the resulting Bayes factor is conditional on those initial conditions.

Parameters:
log_marginal_likelihood#

The log evidence. Must be finite.

Type:

float

n_obs#

Response rows after lag trimming, T_full - n_lags.

Type:

int

n_vars#

Number of endogenous variables.

Type:

int

var_names#

Endogenous variable names, in column order.

Type:

list[str]

n_lags#

Lag order p.

Type:

int

volatility#

Name of the deterministic volatility break, or None if homoscedastic.

Type:

str | None

hyperparameters#

Hyperparameters the evidence was evaluated at (empty when the prior is fixed and there is no volatility break).

Type:

dict[str, float]

sample_start#

Timestamp of the first response row.

Type:

pd.Timestamp

sample_end#

Timestamp of the last response row.

Type:

pd.Timestamp

sample_digest#

Digest of the response block (see _response_digest).

Type:

str

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

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