IdentificationScheme#

class impulso.protocols.IdentificationScheme(*args, **kwargs)[source]#

Bases: Protocol

Contract for structural identification schemes.

identify(L, var_names, posterior=None, data=None, n_lags=None)[source]#

Identify the structural shock matrix from a Cholesky factor.

Parameters:
  • L (ndarray) – Lower-triangular Cholesky factor of the structural-shock covariance, shape (chains, draws, n_vars, n_vars). Produced by volatility.cholesky_at(…).

  • var_names (list[str]) – Endogenous variable names, in the order they appear in the underlying data.

  • posterior (xr.Dataset | None) – Full posterior xarray Dataset. Optional; provided by the pipeline so schemes that need additional draws (e.g., SignRestriction with restriction_horizon > 0 needs B for the MA recursion) can reach for them. Schemes that only need L may ignore this argument. Schemes that need posterior for context but receive None should raise a clear ValueError.

  • data (VARData | None) – The VARData used at fit time. Optional; provided by the pipeline so schemes that need the observed sample — e.g. ProxySVAR, which reconstructs reduced-form residuals and aligns an instrument by date — can reach for it. Schemes that only need L may ignore this argument.

  • n_lags (int | None) – Lag order of the fitted VAR. Provided alongside data because residual reconstruction needs it.

Returns:

Structural shock matrix array of shape (chains, draws, n_vars, n_vars). Caller is responsible for wrapping into an xarray DataArray with named coords.

Return type:

ndarray

shock_coords(n_vars)[source]#

Return the labels for the shock coordinate of the structural matrix.

The pipeline calls this after identify to label the columns of the structural shock matrix when wrapping into an xarray DataArray.

Parameters:

n_vars (int) – Number of endogenous variables (i.e. width of the structural shock matrix).

Returns:

A list of length n_vars naming each shock column.

Return type:

list[str]