IdentifiedVAR#

class impulso.identified.IdentifiedVAR(*, idata, n_lags, data, var_names, volatility, scheme)[source]#

Bases: ImpulsoBaseModel

Immutable structural VAR with identified shocks.

Parameters:
idata#

InferenceData with reduced-form posterior (B, intercept, L, …).

Type:

arviz.data.inference_data.InferenceData

n_lags#

Lag order.

Type:

int

data#

Original VARData.

Type:

impulso.data.VARData

var_names#

Endogenous variable names.

Type:

list[str]

volatility#

Volatility process carried through from the fitted VAR. Required for at= queries on impulse_response / fevd / historical_decomposition (P3), which re-call volatility.cholesky_at(at) for the requested time slice.

Type:

impulso.protocols.VolatilityProcess

scheme#

Identification scheme used to produce the structural shock matrix. Required for at= queries so the scheme can be re-applied to a different Cholesky factor on demand.

Type:

impulso.protocols.IdentificationScheme

fevd(horizon=20, at=None)[source]#

Compute forecast error variance decomposition.

Under partial identification (any shock column labelled unidentified_*), the shares of the unidentified columns are masked to NaN — see _fevd_guard().

Parameters:
  • horizon (int) – Number of periods.

  • at (int | Literal['last', 'all'] | None) – Time index for the structural shock matrix (see shock_matrix() for accepted forms).

Returns:

FEVDResult with FEVD posterior draws.

Return type:

FEVDResult

historical_decomposition(start=None, end=None, cumulative=False, at=None)[source]#

Compute historical decomposition of observed series.

Historical decomposition is intrinsically time-indexed: it attributes each in-sample observation to past structural shocks. The at= parameter controls which Cholesky factor identifies those shocks.

Under partial identification (shock columns labelled unidentified_*), the individual contributions of the unidentified shocks are rotation-arbitrary, but their sum is well-defined (it is the residual variation the identified shocks do not explain). Those columns are therefore collapsed into a single unidentified_remainder column. The decomposition remains exactly additive, and the identified shocks’ contributions are invariant to both the orthogonal completion and any unit-effect column rescaling.

Parameters:
  • start (Timestamp | None) – Optional start date to restrict decomposition.

  • end (Timestamp | None) – Optional end date to restrict decomposition.

  • cumulative (bool) – If True, return cumulative shock contributions.

  • at (int | Literal['last', 'all'] | None) – Time index for the structural shock matrix. None or "all" → per-t decomposition (correct for SV, identical to single-L under constant volatility). int or "last" → single-L hypothetical (warns under SV).

Returns:

HistoricalDecompositionResult.

Return type:

HistoricalDecompositionResult

impulse_response(horizon=20, at=None)[source]#

Compute structural impulse response functions.

Parameters:
  • horizon (int) – Number of periods.

  • at (int | Literal['last', 'all'] | None) – Time index for the structural shock matrix (see shock_matrix() for accepted forms).

Returns:

IRFResult with IRF posterior draws.

Return type:

IRFResult

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

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

shock_matrix(at=None)[source]#

Query the structural shock matrix at a given time index.

This is the single pathway from the volatility process and identification scheme to a labelled structural shock matrix. IRF, FEVD, and historical decomposition all compute through it. Results are memoised per at value on this instance so that all quantities from one IdentifiedVAR share the same structural draws (deterministic per object, even under SignRestriction).

Parameters:

at (int | Literal['last', 'all'] | None) – Time index. None or "last" → most recent slice. An integer t → that specific time index. "all" → full time path (adds a time dim).

Returns:

DataArray with dims (chain, draw[, time], response, shock).

Raises:

ValueError – If at="all" under constant volatility.

Return type:

DataArray

property shock_names: list[str]#

Shock coordinate labels from the identification scheme.