Class VarianceRatio
java.lang.Object
com.quantfinlib.microstructure.VarianceRatio
The Lo-MacKinlay variance ratio test — the question that comes before
every strategy choice: is this series trending, mean-reverting, or a
random walk? Under a random walk, variance grows linearly with
horizon, so the ratio
VR(q) = Var(q-period returns) / (q · Var(1-period returns))is 1. Positive return autocorrelation (momentum) compounds, so VR > 1; negative autocorrelation (mean reversion) cancels, so VR < 1. The z-statistic says whether the deviation is signal or sampling noise.
This is the natural companion to OrnsteinUhlenbeck: OU
refuses a series with no mean reversion, and the variance ratio
tells you what the series is instead (VR ≈ 1: don't trade the
spread, index it; VR > 1: you're holding a momentum name, trade it
that way). Overlapping q-period sums with the simplified denominator
and the homoskedastic z-statistic. Lo-MacKinlay's small-sample unbiased
correction is omitted (bias ~(q−1)/n, negligible for n ≫ q; the length
gate enforces n ≥ 10q), and the heteroskedasticity-robust variant is
likewise omitted. VR(1) is identically 1. Static, deterministic,
research lane.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordVariance ratio and its z statistic. -
Method Summary
Modifier and TypeMethodDescriptionstatic VarianceRatio.Resulttest(double[] returns, int q) Runs the Lo-MacKinlay (1988) variance ratio test.
-
Method Details
-
test
Runs the Lo-MacKinlay (1988) variance ratio test.- Parameters:
returns- 1-period returns, ≥ 10·q finite observationsq- aggregation horizon, ≥ 2 (VR(1) ≡ 1 needs no test)
-