Quant Memo
Core

Analysis of Variance and F-Tests

A way to test whether three or more group means differ at all, in one shot, by comparing how much the groups spread apart from each other against how much noise sits within each group individually.

Prerequisites: One-Sample and Two-Sample t-Tests, Degrees of Freedom

Comparing two trading strategies, a t-test does the job directly. Comparing five strategies at once, the obvious instinct — run every pairwise t-test — quietly breaks the statistics: with five groups there are ten pairs, and running ten tests each at a 5% false-alarm rate stacks up a much higher combined chance of a fluke "winner," the exact family-wise error problem. Analysis of variance (ANOVA) sidesteps this by asking one single, honest question first: do these groups differ at all? Only if the answer is yes does it make sense to dig into which ones.

An analogy: are these classrooms actually different, or just noisy?

Five classrooms take the same exam. Their average scores differ — some by a little, some by a lot — but so does the spread of scores within each individual classroom, student to student. If the gap between classroom averages is small compared to how much scores naturally bounce around within any one classroom, the differences between classrooms are probably just noise. If the gap between classroom averages is large compared to the within-classroom spread, something real is likely distinguishing the classrooms — a better teacher, a different curriculum. ANOVA is exactly this ratio, formalized: variation between groups relative to variation within groups.

The formula, one symbol at a time

Split the total variability in the data into two pieces: between-group variance (how much the group means differ from the overall average) and within-group variance (how much individual observations differ from their own group's mean). The F-statistic is their ratio:

F=variance between groupsvariance within groups=MSBMSWF = \frac{\text{variance between groups}}{\text{variance within groups}} = \frac{MSB}{MSW}

In plain English: MSBMSB (mean square between) measures how spread out the group averages are from each other; MSWMSW (mean square within) measures how noisy each group is internally. If the groups are all really drawn from populations with the same true mean, FF should hover around 1 — between-group spread and within-group spread should look similar, since both are just reflecting the same underlying noise. A large FF, well above 1, means the groups are more spread apart from each other than ordinary within-group noise would explain. FF is compared against an F-distribution with (k1,Nk)(k-1, N-k) degrees of freedom, where kk is the number of groups and NN the total observations.

Distribution · normal
-2.000.002.00μvalue →
Within ±1σ 68.3%mean μ 0.00std σ 1.00

MSBMSB and MSWMSW are each built from squared, roughly-normal deviations like the ones the curve above describes — MSBMSB from how far group means sit from the grand mean, MSWMSW from how far individual points sit from their own group mean — and the F-distribution captures the shape of their ratio.

Worked example 1: three strategies, is there a real difference?

Three strategies, 10 return observations each. Their group means: 0.10%,0.08%,0.15%0.10\%, 0.08\%, 0.15\%; grand mean across all 30 observations: 0.11%0.11\%. Suppose the computed sums of squares give MSB=0.0018MSB = 0.0018 and MSW=0.0012MSW = 0.0012 (in squared-percent units).

F=MSBMSW=0.00180.0012=1.50F = \frac{MSB}{MSW} = \frac{0.0018}{0.0012} = 1.50

With k1=2k-1=2 and Nk=27N-k=27 degrees of freedom, the critical value at α=0.05\alpha=0.05 is about 3.353.35. Since 1.50<3.351.50 < 3.35, there is not enough evidence that the three strategies' true means actually differ — the gaps between 0.10%0.10\%, 0.08%0.08\%, and 0.15%0.15\% are consistent with ordinary within-strategy noise.

low F: groups overlap high F: groups separate
Left: three group means with wide within-group spread bars that overlap heavily — low F, no real separation. Right: the same three means but with narrow spread bars that barely touch — high F, a real difference between groups.

Worked example 2: a clearer separation

Same setup, but now suppose the between-group spread is larger relative to noise: MSB=0.0060MSB = 0.0060, MSW=0.0010MSW = 0.0010.

F=0.00600.0010=6.00F = \frac{0.0060}{0.0010} = 6.00

6.006.00 exceeds the critical value of 3.353.35 for (2,27)(2, 27) degrees of freedom — this result is statistically significant. The conclusion at this stage is only that at least one of the three strategies' true means differs from the others; ANOVA's F-test does not by itself say which one, or by how much — that requires a follow-up (a post-hoc test, itself typically run with a multiple-testing correction such as Bonferroni or Holm).

ANOVA's F-test answers one yes/no question — do at least three or more group means differ at all — by comparing between-group spread to within-group noise in a single ratio. It replaces a battery of pairwise t-tests (which would inflate the false-alarm rate) with one test that controls the overall error rate correctly.

What this means in practice

ANOVA is the right first step whenever comparing more than two groups at once — multiple strategy variants, multiple parameter settings in a grid search, multiple market regimes' average returns — before drilling into pairwise comparisons. Running it first, and only proceeding to pairwise tests if the F-test is significant, is a disciplined way to avoid exactly the fishing-expedition problem that plagues naive "just t-test every pair" approaches to comparing several backtested variants.

A significant F-test tells you that some difference exists somewhere among the groups — it does not identify which group or groups are responsible, and it is a common and costly mistake to follow a significant ANOVA with unprotected pairwise t-tests, silently reintroducing the multiple-testing problem ANOVA was meant to control in the first place. Any follow-up comparisons need their own correction (Tukey's HSD, Bonferroni, or similar) to keep the combined error rate honest.

Related concepts

Practice in interviews

Further reading

  • Fisher (1925), Statistical Methods for Research Workers
  • Wasserman, All of Statistics, ch. 13
ShareTwitterLinkedIn