FittedVAR#
- class impulso.fitted.FittedVAR(*, idata, n_lags, data, var_names, volatility)[source]#
Bases:
ImpulsoBaseModelImmutable container for a fitted (reduced-form) Bayesian VAR.
- Parameters:
idata (InferenceData)
n_lags (int)
data (VARData)
volatility (VolatilityProcess)
- idata#
ArviZ InferenceData with posterior draws.
- Type:
arviz.data.inference_data.InferenceData
- data#
Original VARData used for fitting.
- Type:
- 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()).
- 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). IfFalse, 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:
- 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 theIdentifiedVARthrough normal Pydantic validation.- Parameters:
scheme (IdentificationScheme) – An IdentificationScheme protocol instance (e.g. Cholesky, SignRestriction).
- Returns:
IdentifiedVAR ready for structural queries.
- Return type:
- 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: