ANOVA Using Regression
ANOVA Using Regression: Coding Groups as Dummy Variables
Ordinary fixed-effects ANOVA can be written as a linear regression using indicator (dummy) variables. Under the same independent-error and variance assumptions, ordinary least squares reproduces the group means, sums of squares, and classical ANOVA F-test. Variants such as Welch, repeated-measures, or mixed-effects ANOVA require modified variance or covariance models.
Raw plant-growth measurements by fertilizer group
Setting up the model
For k groups, choose one group as the baseline and create k−1 dummy variables. For example, with three teaching methods (Lecture = baseline, Flipped, Online) on exam score Y:
Here DFlip=1 only for Flipped-class students and DOnline=1 only for Online students; both are 0 for Lecture students.
Fitting this by least squares gives, for example, β^0=75, β^1=5, β^2=−3. This means: the Lecture mean is 75, the Flipped mean is 75+5=80, and the Online mean is 75−3=72. Every coefficient except the intercept is a difference from the baseline, never a group mean by itself.
Linking regression output to the ANOVA table
- SST=SSR+SSE (total = explained by group + within-group error)
- R2=SSR/SST
- F=SSE/(n−k)SSR/(k−1)
This regression F-statistic, testing H0:β1=β2=⋯=0, is numerically identical to the ordinary ANOVA F-test of H0:μ1=μ2=⋯=μk.
A significant individual coefficient's t-test (e.g. testing β1=0) is equivalent to a pairwise comparison between that group and the baseline, and its standard error is built from the pooled error variance: with balanced groups of size m, SE(β^1)=MSE(m1+m1), and the reference distribution uses the error degrees of freedom n−k.
Indicator coding and group sizes for a three-group fertilizer experiment, together with the fitted regression equation.
Two factors and their interaction
With Factor A at a levels and Factor B at b levels, the same counting rule applies twice. Main effects need (a−1)+(b−1) dummies, and the interaction needs the (a−1)(b−1) products of those dummies. Adding the intercept gives 1+(a−1)+(b−1)+(a−1)(b−1)=ab parameters, exactly one per cell, which is what 'saturated' means.
Using the fitted regression equation shown in the figure, Y^=20+4DB+7DC, calculate the predicted mean growth (in cm) for a plant in Group B.
Give your answer in cm.
Indicator coding and group sizes for a three-group fertilizer experiment, together with the fitted regression equation.
Raw plant-growth measurements by fertilizer group
A researcher fits the growth data by regressing Y on DB and DC and obtains β^1=4.00 with SE(β^1)=1.46, computed from MSE=8.571 on dferror=21. Using tcrit≈2.080 for a two-tailed test at α=0.05, which conclusion correctly links the coefficient test to the ANOVA comparison of the Group B and Group A means?