SignRestriction#

class impulso.identification.SignRestriction(*, restrictions, n_rotations=1000, restriction_horizon=0, random_seed=None)[source]#

Bases: ImpulsoModel

Sign restriction identification scheme.

Uses random rotation matrices to find structural impact matrices satisfying sign restrictions on impulse responses.

Parameters:
restrictions#

Dict mapping variable -> {shock_name: “+” or “-“}.

Type:

dict[str, dict[str, str]]

n_rotations#

Number of candidate rotations per draw.

Type:

int

random_seed#

Seed for reproducibility.

Type:

int | None

Expand for references to impulso.identification.SignRestriction

Structural Identification / Cholesky identification / Sign restrictions

Using Sign Restrictions / Define restrictions

Identification in structural VARs: Cholesky vs sign restrictions / A case study using U.S. monetary policy data / Impulse Response Function

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. Acceptance rate available via the sign_restriction_acceptance_rate attribute on the wrapping IdentifiedVAR’s posterior (set by the pipeline).

Return type:

ndarray

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 initialise 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

shock_coords(n_vars)[source]#

Sign-restriction shock labels: named shocks first, then padding.

Parameters:

n_vars (int)

Return type:

list[str]