FittedVAR#

class impulso.fitted.FittedVAR(*, idata, n_lags, data, var_names, volatility)[source]#

Bases: ImpulsoBaseModel

Immutable container for a fitted (reduced-form) Bayesian VAR.

Parameters:
idata#

ArviZ InferenceData with posterior draws.

Type:

arviz.data.inference_data.InferenceData

n_lags#

Lag order used in estimation.

Type:

int

data#

Original VARData used for fitting.

Type:

impulso.data.VARData

var_names#

Names of endogenous variables.

Type:

list[str]

volatility#

Volatility process used at fit time. Required; populated by VAR.fit from VAR.volatility (default at the spec level is “constant”, which resolves to Constant()).

Type:

impulso.protocols.VolatilityProcess

property coefficients: ndarray#

Posterior draws of B coefficient matrices.

forecast(steps, include_shock_uncertainty=True, seed=None, exog_future=None)[source]#

Produce h-step-ahead forecasts from the reduced-form posterior.

Parameters:
  • steps (int) – Number of forecast steps.

  • include_shock_uncertainty (bool) – If True (default), draw shock innovations from the volatility process’s forecast Cholesky path, giving true posterior-predictive intervals (density forecast). If False, propagate only the conditional mean — intervals reflect parameter uncertainty only (mean forecast).

  • seed (int | Generator | None) – RNG seed (int) or Generator for reproducible density forecasts. Ignored when include_shock_uncertainty=False.

  • exog_future (ndarray | None) – Future exogenous values, shape (steps, k). Required if model has exog.

Returns:

ForecastResult with posterior forecast draws.

Return type:

ForecastResult

property has_exog: bool#

Whether the model includes exogenous variables.

property intercepts: ndarray#

Posterior draws of intercept vectors.

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

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

set_identification_strategy(scheme)[source]#

Apply a structural identification scheme.

The structural shock matrix is no longer eagerly computed or stored in the posterior. Instead, IdentifiedVAR.shock_matrix() lazily queries and memoises it on first access. This method constructs the IdentifiedVAR through normal Pydantic validation.

Parameters:

scheme (IdentificationScheme) – An IdentificationScheme protocol instance (e.g. Cholesky, SignRestriction).

Returns:

IdentifiedVAR ready for structural queries.

Return type:

IdentifiedVAR

sigma()[source]#

Posterior draws of the structural-shock covariance Σ.

Dispatches to the configured volatility adapter so the returned shape depends on whether Σ is time-invariant or time-varying:

  • Constant volatility — Σ is shared across time, so the result has shape (chains, draws, n_vars, n_vars).

  • Stochastic volatility — Σ_t evolves, so the result has shape (chains, draws, T, n_vars, n_vars) where T is the in-sample length after lag trimming. Callers needing a single slice should call volatility.cholesky_at(posterior, t) and square the factor themselves.

Note

Breaking change vs. v0.0.4 and earlier: sigma is now a method, not a property. Call sites that used fitted.sigma must be updated to fitted.sigma().

Returns:

Posterior draws of Σ (or Σ_t for SV) computed from the volatility adapter’s Cholesky factor as L @ L.T.

Return type:

ndarray