Class CointegrationTest
java.lang.Object
com.quantfinlib.hedging.CointegrationTest
Engle-Granger two-step cointegration test: regress one price series on the
other, then run an augmented Dickey-Fuller test (no constant) on the
residual spread. This is the statistical justification
PairsHedger
needs before a pairs trade — a high return correlation is not enough; the
spread must be stationary.
Critical values: the constants are the Engle-Granger two-variable,
no-trend asymptotics -3.90 (1%), -3.34 (5%), -3.04 (10%);
criticalValue(double, int) gives MacKinnon's (2010, "Critical values for
cointegration tests", Queen's Economics Department WP 1227, Table 2,
N = 2, constant) finite-sample response surface
τ(T) = τ∞ + τ₁/T + τ₂/T², which engleGranger(double[], double[], int) uses. More negative ADF t-statistics mean stronger
evidence of cointegration. The hedge ratio is the OLS slope of A on B,
which is not symmetric in the two series (regressing B on A gives a
different ratio); total least squares or Johansen would be.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final doublestatic final double -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleadfTStatistic(double[] series) Dickey-Fuller t-statistic (no constant, no lags — appropriate for mean-zero regression residuals): regressΔe_t = γ e_{t-1} + u_tand returnt = γ̂ / se(γ̂).static doubleadfTStatistic(double[] series, int lags) Augmented Dickey-Fuller t-statistic without constant (the residuals of a regression with intercept have mean zero):Δe_t = γ·e_{t−1} + Σ_{j=1..p} φ_j·Δe_{t−j} + u_t, OLS overt = p+1 .. n−1; returnsγ̂ / se(γ̂).static doublecriticalValue(double level, int observations) MacKinnon (2010) finite-sample critical value for the two-variable Engle-Granger test with a constant.engleGranger(double[] pricesA, double[] pricesB) Engle-Granger test with no augmentation lags and the asymptotic critical values (the original behaviour); seeengleGranger(double[], double[], int).engleGranger(double[] pricesA, double[] pricesB, int lags) Engle-Granger test withlagsaugmentation lags in the ADF regression and MacKinnon finite-sample critical values.
-
Field Details
-
CRITICAL_1PCT
public static final double CRITICAL_1PCT- See Also:
-
CRITICAL_5PCT
public static final double CRITICAL_5PCT- See Also:
-
CRITICAL_10PCT
public static final double CRITICAL_10PCT- See Also:
-
-
Method Details
-
criticalValue
public static double criticalValue(double level, int observations) MacKinnon (2010) finite-sample critical value for the two-variable Engle-Granger test with a constant.- Parameters:
level- 0.01, 0.05 or 0.10observations- T, the number of residuals used in the ADF regression
-
engleGranger
Engle-Granger test with no augmentation lags and the asymptotic critical values (the original behaviour); seeengleGranger(double[], double[], int). -
engleGranger
public static CointegrationTest.EngleGrangerResult engleGranger(double[] pricesA, double[] pricesB, int lags) Engle-Granger test withlagsaugmentation lags in the ADF regression and MacKinnon finite-sample critical values. -
adfTStatistic
public static double adfTStatistic(double[] series) Dickey-Fuller t-statistic (no constant, no lags — appropriate for mean-zero regression residuals): regressΔe_t = γ e_{t-1} + u_tand returnt = γ̂ / se(γ̂). -
adfTStatistic
public static double adfTStatistic(double[] series, int lags) Augmented Dickey-Fuller t-statistic without constant (the residuals of a regression with intercept have mean zero):Δe_t = γ·e_{t−1} + Σ_{j=1..p} φ_j·Δe_{t−j} + u_t, OLS overt = p+1 .. n−1; returnsγ̂ / se(γ̂).lags = 0isadfTStatistic(double[]).
-