Class VarianceRatio

java.lang.Object
com.quantfinlib.microstructure.VarianceRatio

public final class VarianceRatio extends Object
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 — VR > 1; negative autocorrelation (mean reversion) cancels — 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 — 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 homoskedastic z-statistic; the heteroskedasticity-robust variant is likewise omitted. Stated, not hidden. VR(1) is identically 1. Static, deterministic, research lane.

  • Method Details

    • test

      public static VarianceRatio.Result test(double[] returns, int q)
      Parameters:
      returns - 1-period returns, ≥ 10·q finite observations
      q - aggregation horizon, ≥ 2 (VR(1) ≡ 1 needs no test)