ConditionalForecastResult#

class impulso.results.ConditionalForecastResult(*, idata, steps, var_names, mode='density', path_uncertainty='none', conditions=<factory>)[source]#

Bases: VARResultBase

Result from conditional forecasting.

The posterior-predictive Dataset carries “forecast” (chain, draw, step, variable) plus the per-draw plausibility statistics “plausibility” (q, chi-squared reference) and “plausibility_calibrated” (q_cal ∈ [0.5, 1], ADPRR binomial calibration); Dataset attrs hold n_restrictions and the chi-squared tail probability of the median q.

Parameters:
idata#

InferenceData-schema container with the draws and statistics.

steps#

Number of forecast steps.

Type:

int

var_names#

Names of forecasted variables.

Type:

list[str]

mode#

“density” or “mean”.

Type:

str

path_uncertainty#

“none” (hard pins) or “unconditional”.

Type:

Literal[‘none’, ‘unconditional’]

conditions#

The VariablePath conditions echoed from the call.

Type:

list[impulso.scenario.VariablePath]

hdi(prob=0.89)[source]#

HDI for the conditional forecast.

Parameters:

prob (float) – Probability mass for the HDI. Default 0.89.

Returns:

HDIResult whose lower / upper DataFrames mirror median().

Return type:

HDIResult

median()[source]#

Posterior median conditional forecast (step-indexed).

Return type:

DataFrame

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

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

property n_restrictions: int#

Number of binding restrictions recorded on the result.

Returns:

The n_restrictions Dataset attribute, or 0 when the result carries no plausibility metadata (e.g. a hand-built result).

pinned_values()[source]#

Resolved pinned values per variable.

Resolves the echoed conditions against the forecast grid the same way the sampler did: a scalar broadcasts to every step, an array pins a leading run of steps, and NaN entries stay free.

Returns:

Dict mapping each variable name to its (step, value) pins with 1-based steps, in condition order; variables without pins map to an empty list.

Raises:

ValueError – On unknown variables, scalar-NaN conditions, over-length arrays, or duplicate pins.

Return type:

dict[str, list[tuple[int, float]]]

plausibility(prob=0.89)[source]#

Posterior summary of the plausibility statistic.

q is the per-draw squared Mahalanobis distance of the pinned values from their unconditional law (chi^2_r reference when all shocks adjust); q_cal is the ADPRR-calibrated companion on [0.5, 1] — values near 1 flag scenarios the model considers incredible.

Parameters:

prob (float) – Probability mass for the HDI bounds. Default 0.89.

Returns:

Dict with q_median, q_hdi_lower, q_hdi_upper, q_calibrated_median, n_restrictions, and tail_probability (P(chi^2_r >= median q); 1.0 with no restrictions).

Return type:

dict[str, float]

plot()[source]#

Plot the conditional forecast fan chart with pinned values marked.

Return type:

Figure

to_dataframe()[source]#

Conditional-forecast posterior median as a DataFrame (passthrough to median()).

Return type:

DataFrame