VARData#

class impulso.data.VARData(*, endog, endog_names, exog=None, exog_names=None, index)[source]#

Bases: ImpulsoBaseModel

Immutable, validated container for VAR estimation data.

Variable names must be unique. endog_names and exog_names are each checked for internal duplicates, and the two must not share any name — a single label cannot refer to both an endogenous and an exogenous column.

Exogenous columns must vary within the sample. A column that is exactly constant is collinear with the intercept every VAR carries, so it is not identified; it is rejected rather than silently soaking up an arbitrary share of the intercept.

Every value must be finite. NaN or Inf in either block is rejected at construction, not left to surface later as a failed fit or an all-NaN posterior.

Immutability extends to the arrays themselves: endog and exog are copied and marked read-only once validation passes, so a fitted model can never be re-pointed at data that was mutated underneath it.

Parameters:
endog#

Endogenous variable array of shape (T, n) where T >= 1 and n >= 2.

Type:

numpy.ndarray

endog_names#

Names for each endogenous variable. Must be unique.

Type:

list[str]

exog#

Optional exogenous variable array of shape (T, k). Every column must take at least two distinct values. Endogenous variables are modelled jointly and each carries a structural shock; exogenous regressors enter contemporaneously, are never explained by the system, and carry no shock of their own. Which columns belong on which side is a modelling assumption the data cannot check.

Type:

numpy.ndarray | None

exog_names#

Names for each exogenous variable. Required if exog is provided. Must be unique and disjoint from endog_names.

Type:

list[str] | None

index#

DatetimeIndex of length T.

Type:

pandas.DatetimeIndex

Expand for references to impulso.data.VARData

Preparing Data for VARData / From a pandas DataFrame

Granger Causality and Toda-Yamamoto / A worked example, and what it does not license

Granger Causality and Toda-Yamamoto / Query a fitted model

Impulso

The conjugate VAR: fast Bayesian estimation / When to reach for ConjugateVAR instead of the NUTS VAR / Scope

Probabilistic Forecasts

The Minnesota Prior, From Scratch

Model Checks and Validation

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

Estimating a VAR after March 2020 / What this reproduction does and does not match

Oil supply news with an external instrument / How the announcement surprise identifies one shock

Fitting Your First Bayesian VAR

Counterfactuals, conditional forecasts, and structural scenarios / “What if” analysis in the style of Antolín-Díaz, Petrella & Rubio-Ramírez (2021) / The Lucas critique still applies

Stochastic volatility: modelling time-varying uncertainty / Model / Stochastic volatility inside a VAR

Structural Shocks in the Atmosphere

classmethod from_df(df, endog, exog=None)[source]#

Construct VARData from a pandas DataFrame.

Column names must be unique within endog, within exog, and across the two — pandas silently widens the selection when a label is repeated or when df itself carries duplicate column labels, which would produce arrays that no longer match their names.

Parameters:
  • df (DataFrame) – DataFrame with a DatetimeIndex.

  • endog (list[str]) – Column names for endogenous variables.

  • exog (list[str] | None) – Column names for exogenous variables (optional).

Returns:

Validated VARData instance.

Return type:

Self

Expand for references to impulso.data.VARData.from_df

Preparing Data for VARData / From a pandas DataFrame

Granger Causality and Toda-Yamamoto / A worked example, and what it does not license

Granger Causality and Toda-Yamamoto / Query a fitted model

Impulso

Stochastic volatility: modelling time-varying uncertainty / Model / Stochastic volatility inside a VAR

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

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