ANOVA Calculations, Sum of Squares, and the F-Test – STAT 212, Principles of Statistics II – Study Notes
offline

Difficulty: Intermediate | Prerequisites: Part 1 of these notes (ANOVA Fundamentals), basic algebra, comfort with summation notation.


Big Picture

Once you understand what ANOVA tests (Part 1), the next step is understanding how it works mechanically. ANOVA partitions the total variability in the data into two pieces: variation explained by group membership (treatment) and variation left unexplained (error/noise). These pieces are summarised in the ANOVA table, and their ratio produces the F-statistic that drives the hypothesis test. This section covers every calculation you need to complete an ANOVA table from scratch and interpret the result.


TL;DR

ANOVA splits total variation (SST) into treatment variation (SSTr, between groups) and error variation (SSE, within groups). Dividing each sum of squares by its degrees of freedom gives mean squares. The F-statistic is MSTr/MSE. Under the null hypothesis, F should be near 1; large F values lead to rejection. The R commands aov() and anova() automate this.


Key Terms

Sum of Squares Total (SST)

The total variability in the dataset, measured as the sum of squared deviations of every observation from the grand mean. In simple terms, this is how spread out all the data points are, ignoring groups entirely.

Sum of Squares Treatment (SSTr)

The portion of total variability attributable to differences between group means. Calculated as the weighted sum of squared deviations of each group mean from the grand mean. Think of it as: "How much of the total spread is explained by group membership?"

Sum of Squares Error (SSE)

The portion of total variability that remains within groups, i.e., variation not explained by the factor. Also called "unexplained variation" or "residual variation." Think of it as noise or random scatter around each group's own mean.

Degrees of freedom, Treatment (dfTr)

Equal to k - 1, where k is the number of groups. This reflects the number of independent comparisons among the group means.

Degrees of freedom, Error (dfE)

Equal to N - k, where N is the total sample size. This reflects the number of independent pieces of information left after estimating each group mean.

Mean Square Treatment (MSTr)

SSTr divided by its degrees of freedom: MSTr = SSTr / (k - 1). This is the average between-group variability per degree of freedom.

Mean Square Error (MSE)

SSE divided by its degrees of freedom: MSE = SSE / (N - k). This is the average within-group variability per degree of freedom. MSE is an unbiased estimator of σ² regardless of whether H₀ is true.

F-statistic

The ratio MSTr / MSE. It measures how large the between-group variation is relative to the within-group variation.

Expected value of MSTr

E(MSTr) = σ² + Σnᵢ(µᵢ - µ..)² / (k - 1). Under H₀ this simplifies to σ²; under Hₐ it exceeds σ².

Expected value of MSE

E(MSE) = σ², always, regardless of whether H₀ is true or false.


Core Content

The Fundamental Partition

  • Total variation is split into two additive components:

    • SST = SSTr + SSE

  • This is the only correct partition. Common distractors on exams rearrange the terms incorrectly.

Calculating Sum of Squares

  • SST = Σᵢ Σⱼ (Xᵢⱼ - X̄..)², the sum over all observations of squared deviations from the grand mean.

  • SSTr = Σᵢ nᵢ(X̄ᵢ - X̄..)², where nᵢ is the sample size of group i. Each group mean's deviation from the grand mean is squared and weighted by the group size.

  • SSE = Σᵢ Σⱼ (Xᵢⱼ - X̄ᵢ)², the sum over all observations of squared deviations from their own group mean.

  • If you know any two of {SST, SSTr, SSE}, you can find the third by subtraction. Exam questions frequently give two and ask for the missing one.

Degrees of Freedom

  • dfTr = k - 1 (number of groups minus one).

  • dfE = N - k (total observations minus number of groups).

  • dfTotal = N - 1, and note that dfTotal = dfTr + dfE.

Mean Squares

  • MSTr = SSTr / dfTr = SSTr / (k - 1)

  • MSE = SSE / dfE = SSE / (N - k)

  • Mean squares are "average" variabilities per degree of freedom, which makes them comparable even when the two sums of squares are based on different numbers of terms.

The F-Statistic and Its Interpretation

  • F = MSTr / MSE

  • Under H₀ (all means equal), both MSTr and MSE estimate σ², so F is expected to be approximately 1.

  • Under Hₐ (at least two means differ), MSTr estimates something larger than σ² (because it includes the systematic term), so F is expected to exceed 1.

  • The F-statistic can never be negative (it is a ratio of two positive quantities).

  • The test is one-tailed to the right: we only reject H₀ when F is significantly larger than 1, never for small F values. A small F simply suggests the treatment effect is negligible.

Why the F-Test Is One-Tailed

  • E(MSTr) = σ² + Σnᵢ(µᵢ - µ..)² / (k - 1). The second term is zero under H₀ and positive otherwise. So MSTr can only be at least as large as MSE in expectation, never systematically smaller. This is why only large F values provide evidence against H₀.

The ANOVA Table (Template)

Source

df

Sum of Squares

Mean Square

F-value

Treatment

k - 1

SSTr

SSTr / (k - 1)

MSTr / MSE

Error

N - k

SSE

SSE / (N - k)

Total

N - 1

SST

Making a Decision

  • Compare the computed F to a critical value from the F-distribution table with (k - 1, N - k) degrees of freedom, or compare the p-value to α.

  • If F > F_critical (or p-value < α), reject H₀ and conclude that at least two population means differ.

  • If F ≤ F_critical (or p-value ≥ α), fail to reject H₀.

Using R for ANOVA

  • Fit the model: fit <- aov(response ~ factor, data = dataset)

  • Display the ANOVA table: anova(fit)

  • The anova() function (not summary(), not plot()) is the command that produces the standard ANOVA table output.


Formulas / Diagrams

Partition of sums of squares: SST = SSTr + SSE

Degrees of freedom: dfTr = k - 1 , dfE = N - k , dfTotal = N - 1

Mean squares: MSTr = SSTr / (k - 1) , MSE = SSE / (N - k)

F-statistic: F = MSTr / MSE

Expected values: E(MSE) = σ² E(MSTr) = σ² + Σnᵢ(µᵢ - µ..)² / (k - 1)


Real-World Applications

Every time a researcher presents an ANOVA table in a journal paper, they have performed exactly this calculation. A food scientist comparing acidity across wines from four wineries, a geologist comparing iron content across rock formations, an educator comparing student performance across teaching methods: the mechanics are identical. Learning to fill in a partial ANOVA table is a skill that transfers directly to reading and critically evaluating published research.


Common Misconceptions

  • Students frequently confuse SST and SSTr because the abbreviations are similar. SST is the total; SSTr is the treatment (between-group) component. The partition is SST = SSTr + SSE.

  • A common error is dividing sums of squares by the wrong degrees of freedom. MSTr uses (k - 1), not (N - 1). MSE uses (N - k), not (k - 1). Mix these up and every downstream number is wrong.

  • Students sometimes think a large F-statistic proves the means differ. It provides evidence against H₀, evaluated via the p-value or critical value comparison. Statistical significance is not certainty.

  • Some students believe MSE changes depending on whether H₀ is true. It does not: E(MSE) = σ² always. Only MSTr's expected value changes.


Why It Matters / Exam Flags

⚠️ Filling in missing values in a partial ANOVA table is one of the most common exam question formats (see Questions 16-18 and 24 in practice exams). Practise working backwards from any two known sums of squares to find the third.

⚠️ Know the formula for every cell in the ANOVA table. You should be able to reconstruct the entire table from SST, SSTr (or SSE), k, and N.

⚠️ The F-statistic formula (MSTr / MSE) and the reason it is approximately 1 under H₀ are tested in both multiple-choice and long-answer formats.

⚠️ Be able to explain why the F-test is one-tailed using the expected value of MSTr. This is a 10-mark long-answer topic.

⚠️ The R command for displaying the ANOVA table is anova(fit), not summary(). This has appeared as a multiple-choice question.


Quick Self-Test

Fill in the blank: SST = ________ + ________. SSTr + SSE

True or False: MSE is an unbiased estimator of σ² only when H₀ is true. False. MSE is an unbiased estimator of σ² regardless of whether H₀ is true.

Fill in the blank: The degrees of freedom for the Error term in ANOVA are calculated as ________. N - k

True or False: If H₀ is true, the F-statistic is expected to be approximately 0. False. It is expected to be approximately 1.

Fill in the blank: The R function used to display the ANOVA table after fitting a model with aov() is ________. anova()


Practice Q&A

Q: Given k = 3 groups, N = 18 total observations, SSTr = 45.2, and SSE = 60.0, calculate dfTr, dfE, MSTr, MSE, and the F-statistic.

A: dfTr = 3 - 1 = 2. dfE = 18 - 3 = 15. MSTr = 45.2 / 2 = 22.6. MSE = 60.0 / 15 = 4.0. F = 22.6 / 4.0 = 5.65.

Q: A geologist's ANOVA table has 4 groups, N = 40, SST = 1072.25, SSTr = 509.12, and MSE = 15.64. Find the missing dfE, SSE, and F-value.

A: dfE = 40 - 4 = 36. SSE = 1072.25 - 509.12 = 563.13. F = MSTr / MSE = 169.71 / 15.64 = 10.85.

Q: If the computed F = 10.85 and the critical value F₀.₀₅,₃,₃₆ = 2.87, what is your conclusion?

A: Since 10.85 > 2.87, reject H₀ at the 5% significance level. There is strong evidence that at least two group means differ.

Q: What does the "unexplained variation" in ANOVA refer to?

A: SSE (Error Variation), the variation within groups that is not accounted for by the factor.

Q: A researcher finds a p-value of 0.024 from an ANOVA F-test at α = 0.05. What is the conclusion?

A: Since 0.024 < 0.05, reject H₀. There is sufficient evidence that at least two of the population means differ.

Q: State E(MSTr) and use it to explain why the F-test is one-tailed.

A: E(MSTr) = σ² + Σnᵢ(µᵢ - µ..)² / (k - 1). Under H₀, the second term is zero, so E(MSTr) = σ² = E(MSE), giving F ≈ 1. Under Hₐ, the second term is positive, so E(MSTr) > σ² and F > 1 in expectation. Because the systematic term can only add to MSTr (never subtract), evidence against H₀ only appears in the right tail. We never reject for small F values.

Q: In a winery experiment, what does a very large F-statistic (e.g., 170.51) suggest?

A: The between-winery variation (MSTr) is far larger than the within-winery variation (MSE). The differences in wine acidity across wineries are very likely systematic rather than due to random chance.


Connections to Other Topics

The sum-of-squares partition (SST = SSTr + SSE) reappears in regression as SST = SSR + SSE, where SSR is the regression sum of squares. The R² statistic in regression is SSTr/SST in ANOVA terms. The F-test here is also the same F-test used to assess overall significance of a regression model. Understanding mean squares and degrees of freedom now makes factorial ANOVA (two or more factors) and ANCOVA much more approachable later in the course.


Related Terms / Search Tags: sum of squares, SST, SSTr, SSE, total variation, treatment variation, error variation, unexplained variation, degrees of freedom, mean square, MSTr, MSE, F-statistic, F-ratio, F-test, ANOVA table, expected value MSTr, one-tailed test, critical value, p-value, aov, anova R command, variance partition, STAT 212, Texas A&M, Principles of Statistics II