Skip to content

DPredict · Guide test 206

Johansen maximum eigenvalue test

Tests a specified cointegration rank against the next larger rank.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

  • Cointegration tests — Do several wandering (unit-root) series move together in the long run, so that some combination of them is stationary?

In Cointegration tests, choose Test = Johansen trace and maximum eigenvalue.

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Johansen maximum eigenvalue test

80
1.50
0.60

1: the gap is a random walk too (no cointegration).

0.050

Your data

Simulated with known truth
—— y– – x—— gap y − 0.79 − 1.53·x

Cointegrated series wander together: the gap from their long-run line keeps returning to zero.

If H₀ were true

λ_max = 18.21
  1. The reference: how λ_max varies across samples when H₀ is true, λ-max of two independent random walks, n = 80 (Monte Carlo null: 999 samples simulated under H₀ (seed 20261107)).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .029).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

λmax⁡(0)=−Tln⁡(1−λ^1)\lambda_{\max}(0) = -T\ln(1 - \hat\lambda_1)

With your numbers

λmax⁡=−78ln⁡(1−0.21)=18.21\lambda_{\max} = -78\ln(1 - 0.21) = 18.21
λi\lambda_i
squared canonical correlations between differences and lagged levels
TT
effective sample size
rr
cointegrating rank; H₀ here: r = 0

The verdict

λ_max = 18.21, p = .029

p ≤ α = .050: reject H₀

Against the specific alternative r = 1 it can be sharper than the trace test; the two can disagree.

Statistic
18.209
p-value
0.0290
Johansen maximum eigenvalue test on two series of length 80: λ_max = 18.21, p = .029. The p-value is below α = .050, so the data are hard to reconcile with H0.

Johansen maximum eigenvalue test on two series of length 80: λ_max = 18.21, p = .029. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: cointegration rank equals r; H1: rank equals r+1.

Assumptions

A correctly specified vector error-correction model for I(1) series, suitable innovations, chosen lag order and deterministic terms, and no unmodeled structural break.

Formula

Jmax(r,r+1)=−Tlog⁡(1−λ^r+1)J_{max}(r,r+1)=-T\log(1-\widehat\lambda_{r+1})

Parameters and notation

In Δyt=Πyt−1+ΣΓjΔyt−j+deterministic terms+ut, λ̂j are ordered squared canonical correlations after residualizing lagged levels and differences on short-run/deterministic regressors. p is system dimension,T effective sample.

Structure of the method

Use the same residualized levels/differences eigenproblem as the Johansen system procedure, but test the next individual eigenvalue rather than summing the remaining spectrum. The statistic compares rank r with the next larger rank under the specified deterministic and dynamic model. It is therefore a distinct decision rule from the trace test.

Estimated and nuisance parameters

System short-run coefficients, covariance matrices, ordered canonical eigenvalues, adjustment loadings, and the cointegrating space are estimated. Normalized vector coefficients depend on identifying choices; the next-eigenvalue statistic does not itself identify a unique economic equilibrium equation.

Settings and design choices

Prespecify level/difference lag convention, variable set, deterministic placement, seasonal terms, rank-testing sequence, and critical-value source. Python and R options with similar names need not represent identical deterministic restrictions. Choose the statistic before examining which version produces a preferred rank.

Fitting and adaptation

Refit the VECM ingredients for the declared specification and evaluate each hypothesized rank with matching tables. After choosing rank, estimate any economically constrained cointegration relations and validate residual dependence and parameter stability. Bootstrap procedures must reproduce the full fitted null and eigenvalue calculation where justified.

Sensitivity and robustness

Closely spaced eigenvalues, short samples, excessive lags, outliers, and near-singular covariance make rank determination fragile. Structural breaks can create apparent extra relations or mask real ones. Trace and maximum-eigenvalue disagreement is evidence of specification/sample uncertainty, not necessarily a coding error. Report both only with a clear protocol rather than treating them as independent confirmations.

How to use and calibrate

Use Johansen-specific critical values for deterministic specification; sequential rank testing must follow a stated protocol.

Example application

Estimate how many stationary long-run relations exist in a multivariate system.

Interpretation and pitfalls

Watch out

Neither statistic has an ordinary χ² distribution in standard rank testing. Small samples and lag misspecification can distort rank selection.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

The two Johansen implementations use different deterministic-term parameterizations; compare only after aligning the model. Test ranks sequentially using the corresponding critical-value table.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x=np.cumsum(rng.normal(size=160));y=1.5*x+rng.normal(size=160);Z=np.column_stack([y,x])
from statsmodels.tsa.vector_ar.vecm import coint_johansen
r=coint_johansen(Z,det_order=0,k_ar_diff=1)
print("trace",r.lr1,r.cvt)
print("max eigenvalue",r.lr2,r.cvm)
Output
trace [63.05843318  3.78595986] [[13.4294 15.4943 19.9349]
 [ 2.7055  3.8415  6.6349]]
max eigenvalue [59.27247332  3.78595986] [[12.2971 14.2639 18.52  ]
 [ 2.7055  3.8415  6.6349]]
R

Validated — Executed successfully in the validation environment · needs urca

set.seed(2026)
x<-cumsum(rnorm(160));y<-1.5*x+rnorm(160);Z<-cbind(y,x)
library(urca)
print(summary(ca.jo(Z,type="eigen",ecdet="const",K=2)))
Output
###################### 
# Johansen-Procedure # 
###################### 

Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration 

Eigenvalues (lambda):
[1] 4.037212e-01 1.828300e-02 1.344411e-17

Values of teststatistic and critical values of test:

          test 10pct  5pct  1pct
r <= 1 |  2.92  7.52  9.24 12.97
r = 0  | 81.69 13.75 15.67 20.20

Eigenvectors, normalised to first column:
(These are the cointegration relations)

               y.l2      x.l2  constant
y.l2      1.0000000    1.0000  1.000000
x.l2     -1.4723500  332.0156 -1.978132
constant  0.1278698 2125.9707 67.241592

Weights W:
(This is the loading matrix)

           y.l2          x.l2     constant
y.d -1.20217698 -0.0001670904 2.960932e-17
x.d -0.03771394 -0.0001142129 2.542438e-18

Sources

Statistics guide v4 (historical):
Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 206, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT206.