Engle-Granger Cointegration Test Calculator
Enter aligned X and Y level series, declare a fixed residual-ADF lag and calculate the augmented Engle–Granger two-step statistic for Y on X. The page exposes the fitted spread, MacKinnon cointegration references and direction sensitivity without claiming a stable pair, mean-reversion edge or trade setup.
Enter aligned X and Y level series
Use the same timestamps, frequency and preprocessing in both columns. Direction is fixed as Y on X and is not symmetric.
Whole lags only. Version 1.0.0 uses the entered lag exactly and performs no hidden selection.
Enter 20 to 500 finite levels, oldest to newest, with one aligned timestamp per row.
Y is the response in the first-stage Y-on-X equation; row count and order must match X.
Two-step cointegration reference
Entered Stationarity and Cointegration 1.0.0.
On smaller screens, scroll horizontally to inspect the complete audit table.
| Row | X level | Y level | Fitted Y | Residual |
|---|
How the augmented Engle–Granger calculation works
Step 2: Δut = γut−1 + ΣδiΔut−i + εt
Version 1.0.0 first fits ordinary least squares in one declared direction: Y on X with a constant. It records the slope, intercept, fitted Y and residual for every aligned row. Reversing X and Y creates a different first-stage equation and can change the two-step result.
The second stage applies a no-constant fixed-lag ADF regression to the fitted residual sequence. Although the residual regression has no constant, its test statistic is evaluated with the cointegration-specific MacKinnon response surfaces for two I(1) series and a constant in the first-stage equation.
The 1%, 5% and 10% critical references are not ordinary one-series ADF critical values. Version 1.0.0 uses the MacKinnon N=2 finite-sample curves with n minus one observations, matching the declared statsmodels 0.14.6 oracle.
Worked example from the audited fixture
The audited fixture contains 48 aligned level observations and declares one lag for the residual ADF step.
- The first-stage Y-on-X equation estimates slope 1.48214117, intercept 1.25190533 and residual population deviation 0.29439384.
- The residual statistic is −4.11579461, the cointegration-specific approximate p-value is 0.00487607 and the 5% finite-sample critical reference is −3.46922086.
Reproduce it: select “Load audited example” above. The governed engine retains full precision and rounds only the visible interface.
How to interpret the result
- Begin with direction. The page fits Y on X; it does not search both directions and select the more favorable output.
- The residual statistic is evaluated against cointegration-specific, not ordinary ADF, reference surfaces. Substituting one-series critical values would be incorrect.
- The maintained Engle–Granger setup expects both level series to be I(1). This browser page cannot establish integration order from the same test result.
- A fitted residual can change with the window, lag, deterministic terms, structural breaks, price scaling, missing observations and data revisions.
- Cointegration is a statistical long-run relation under assumptions. It does not supply transaction costs, entry thresholds, position sizing, stop logic or evidence of out-of-sample profitability.
Assumptions and limits
- Enter 20 to 500 equal-length level observations aligned by meaningful timestamps and frequency; malformed or unequal rows fail closed.
- The calculator cannot verify that X and Y are each I(1), that timestamps match, or that data sourcing and preprocessing are consistent.
- Only a constant-included Y-on-X first stage is supported. Johansen systems, multiple regressors, trend terms and alternative directions are outside Version 1.0.0.
- The residual ADF lag is entered manually and used exactly. No AIC, BIC, t-statistic lag search or multiple-specification correction is performed.
- Near-perfect collinearity is rejected because the numerical residual test becomes unstable and an infinite statistic is not a useful browser result.
- No cointegration, stable-pair, mean-reversion, hedge-ratio recommendation, strategy-validation, forecast, grade, signal, position instruction or trade recommendation verdict is generated.
Which time-series diagnostic answers which question?
ADF, KPSS and Engle–Granger do not produce one interchangeable stationarity score. Their null hypotheses, deterministic terms, lag roles and reference distributions differ. The comparison below keeps those choices visible before any user interprets a p-value or critical boundary.
| Diagnostic | Null hypothesis | Alternative | Reference family | Lag role |
|---|---|---|---|---|
| Augmented Dickey–Fuller | Unit root | No unit root under constant or trend choice | Lower-tail MacKinnon approximation | Fixed augmentation lag |
| KPSS | Level or trend stationarity | Unit-root component under chosen null | Published 0.01–0.10 table | Fixed Newey–West lag |
| Engle–Granger | No cointegration for Y on X | Cointegration under two-series assumptions | N=2 MacKinnon approximation | Fixed residual ADF lag |
| Ljung–Box | No residual autocorrelation through h | At least one nonzero residual autocorrelation | Chi-square approximation | Maximum lag and fitted orders |
Frequently asked questions
- It calculates a reference for the null of no cointegration after fitting a constant-included Y-on-X relation and applying a fixed-lag ADF regression to its residuals.
- The first-stage ordinary-least-squares equation is directional; reversing the response and predictor changes the fitted equation and can change the two-step result.
- Enter aligned level observations for two series that the maintained analysis treats as integrated of order one, using matching timestamps, frequency and preprocessing.
- Each residual equals entered Y minus the fitted intercept minus the fitted slope times entered X for that same aligned row.
- Residual cointegration statistics have a different distribution, so the page uses MacKinnon N=2 response surfaces for a constant-included first-stage equation.
- No. Integration order is a maintained user assumption and must be evaluated separately; the two-step output cannot establish it for both inputs.
- No. A statistical long-run relation does not supply stable hedge ratios, execution costs, entry thresholds, exits or out-of-sample performance evidence.
- No. It generates no cointegration verdict, stable-pair label, mean-reversion claim, trade signal, position instruction or recommendation.
Sources and methodology
- statsmodels — Engle–Granger Cointegration Test — Official implementation documentation for the augmented two-step method and MacKinnon references.
- Engle and Granger (1987) — Original Econometrica paper on cointegration, error correction, representation, estimation and testing.
- MacKinnon — Critical Values for Cointegration Tests — Primary source for the finite-sample N=2 critical response surfaces.
Version 1.0.0 was locked after its regression statistics, reference values and example outputs were independently recomputed with statsmodels 0.14.6 and SciPy 1.13.1. The browser calculator performs local arithmetic and does not upload entered observations. Reference probabilities remain conditional on the disclosed model and data assumptions.
Audit the series before planning a pair
Verify the ordered evidence before testing it
Reconcile the exact symbol, price basis, statement window, observation timestamps, timezone, sampling frequency, missing rows, spread, commission, financing, currency conversion, rollover adjustments and preprocessing before entering a series. Correct regression arithmetic cannot repair selected, misaligned or cost-inconsistent evidence.
Risk and affiliate disclosure: Leveraged forex and CFD trading can result in substantial losses. These are affiliate links, so ForexMT4Indicators.com may receive compensation if you register or trade through them, at no additional cost to you. Availability and terms vary by jurisdiction and broker entity.

