toda_yamamoto#

impulso.toda_yamamoto(data, cause, effect, *, lags='aic', max_lags=12, d=None, integration_order_result=None, max_order=2, alpha=0.05, regression='c', rope=None, standardize=True, prior=None, draws=1000, seed=None)[source]#

Granger causality with Toda-Yamamoto lag augmentation.

Toda and Yamamoto (1995) make Granger-causality inference valid without first deciding the integration and cointegration structure: fit the VAR in levels with p + d lags, where p is the lag order you would have chosen and d the highest integration order in the system, then test only the first p lags. The extra d lags are never tested — they exist to restore the standard asymptotics — and this function never silently changes the reported test lag order to match the fitted one: the result carries n_lags_tested and n_lags_fitted separately.

d comes from integration_order unless it is passed explicitly. When the diagnostics leave any variable in inconclusive, d_max is a floor rather than a finding, so this function refuses to run rather than under-augment; read the full table and pass d= yourself.

The fit uses the closed-form conjugate estimator (ConjugateVAR with an NIWPrior) because augmentation inflates the lag order and the conjugate path draws in closed form. For the NUTS estimator, a stochastic-volatility process, or exogenous regressors, run the procedure by hand — it is three calls:

`python d = integration_order(data).d_max fitted = VAR(lags=p + d).fit(data) fitted.granger_causality(cause, effect, test_lags=p) `

Parameters:
  • data (VARData) – Endogenous data, in levels. Exogenous regressors are not supported here (the conjugate estimator does not consume them).

  • cause (str) – Variable whose lags are tested.

  • effect (str) – Variable whose equation they are tested in.

  • lags (int | Literal['aic', 'bic', 'hq']) – Test lag order p, or an information criterion to select it with (“aic”, “bic”, “hq”).

  • max_lags (int) – Upper bound when lags is a criterion.

  • d (int | None) – Augmentation to use. Passing it skips the diagnostics entirely, and records augmentation_source=”user”.

  • integration_order_result (IntegrationOrderResult | None) – Diagnostics to reuse instead of running integration_order again. Ignored when d is given.

  • max_order (int) – max_order for integration_order, when it is run.

  • alpha (float) – Significance level for integration_order, when it is run.

  • regression (Literal['c', 'ct']) – Deterministic terms for integration_order’s level test, when it is run.

  • rope (float | None) – Region of practical equivalence for p_rope.

  • standardize (bool) – Report in sd(effect) per sd(cause) units. Note that the standard deviations of integrated series carry their trends, so standardised magnitudes compare best within one fit.

  • prior (NIWPrior | None) – Conjugate prior for the fit. Defaults to NIWPrior().

  • draws (int) – Posterior draws to retain.

  • seed (int | None) – Seed for the conjugate sampler.

Returns:

GrangerCausalityResult with n_lags_tested = p, augmentation = d, and the consulted diagnostics attached when they were run.

Raises:

ValueError – If data carries exogenous regressors, if the names are unknown or identical, if lags or d is invalid, or if the integration-order diagnostics are inconclusive.

Return type:

GrangerCausalityResult

Expand for references to impulso.toda_yamamoto

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

Granger Causality and Toda-Yamamoto / Toda-Yamamoto for integrated systems