johansen_test#
- impulso.johansen_test(data, *, det_order=0, k_ar_diff=1, alpha=0.05)[source]#
Johansen cointegration rank test.
Reports both the trace and maximum-eigenvalue sequential tests. A rank of 0 means no cointegration; a rank equal to the number of series means the system is stationary in levels; anything in between means the levels share common stochastic trends. Any rank of 1 or more therefore carries a modelling consequence rather than just a verdict: differencing every series discards the long-run relationship those series share, throwing away the cointegrating restrictions along with the unit roots.
Impulso does not implement a vector error-correction model, and that is a deliberate scope boundary rather than an omission. The recommended response to a non-zero rank is a VAR in levels — the Sims-Stock-Watson stance, under which a levels VAR stays consistent when the series are cointegrated and avoids imposing a rank the test only estimates — and the Minnesota prior already shrinks toward random walks, so a levels fit is not fighting the unit roots it contains.
The test is conditioned on a lag order. k_ar_diff counts lagged differences, so it is p - 1 for a VAR(p) in levels — pick p with select_lag_order first, then subtract one.
Critical values are MacKinnon-Haug-Michelis (1996); there are no p-values, so alpha is restricted to the tabulated levels.
- Parameters:
data (VARData | DataFrame) – VARData (endogenous block only) or DataFrame, two or more columns.
det_order (Literal[-1, 0, 1]) – Deterministic term. -1 for none, 0 for a constant, 1 for a linear trend.
k_ar_diff (int) – Number of lagged differences in the vector error-correction model (VECM), p - 1.
alpha (float) – Significance level. Restricted to 0.10, 0.05, or 0.01, the levels for which critical values are tabulated.
- Returns:
CointegrationTestResult with both rank decisions and the full table.
- Raises:
ValueError – If alpha is not a tabulated level, if det_order is not -1, 0, or 1, if k_ar_diff is negative, or if fewer than two series are supplied.
- Return type: