SignRestriction#
- class impulso.identification.SignRestriction(*, restrictions, n_rotations=1000, restriction_horizon=0, random_seed=None)[source]#
Bases:
ImpulsoModelSign restriction identification scheme.
Uses random rotation matrices to find structural impact matrices satisfying sign restrictions on impulse responses.
- Parameters:
- identify(L, var_names, posterior=None, data=None, n_lags=None)[source]#
Apply sign-restriction identification.
- Parameters:
L (ndarray) – Lower-triangular Cholesky factor, shape (chains, draws, n_vars, n_vars).
var_names (list[str]) – Variable names in the data’s natural order.
posterior (xr.Dataset | None) – Required when self.restriction_horizon > 0 because the multi-horizon check needs the VAR coefficients B from the posterior. Ignored for impact-only restrictions (restriction_horizon == 0).
data (VARData | None) – Unused. Accepted for Protocol uniformity.
n_lags (int | None) – Unused. Accepted for Protocol uniformity.
- Returns:
Structural shock matrix, shape (chains, draws, n_vars, n_vars). Per-draw fallback to the supplied L for draws where no rotation satisfies the restrictions. The acceptance rate is available as last_diagnostics[“sign_restriction_acceptance_rate”] and on the matching IdentifiedVAR.shock_matrix() attr.
- Return type:
- property last_diagnostics: dict[str, float]#
Diagnostics from the most recent identify() call.
Scheme-prefixed scalars (see CONTEXT.md “Identification diagnostics”), overwritten per call and surfaced onto IdentifiedVAR.shock_matrix().attrs by the pipeline. Returns a copy.
- model_config = {'frozen': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context, /)#
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
- Return type:
None