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

Raw plant-growth measurements by fertilizer group

Setting up the model

For kk groups, choose one group as the baseline and create k−1k-1 dummy variables. For example, with three teaching methods (Lecture = baseline, Flipped, Online) on exam score YY:


Y=β0+β1DFlip+β2DOnline+εY = \beta_0 + \beta_1 D_{Flip} + \beta_2 D_{Online} + \varepsilon


Here DFlip=1D_{Flip}=1 only for Flipped-class students and DOnline=1D_{Online}=1 only for Online students; both are 0 for Lecture students.


Fitting this by least squares gives, for example, β^0=75\hat\beta_0 = 75, β^1=5\hat\beta_1 = 5, β^2=−3\hat\beta_2 = -3. This means: the Lecture mean is 75, the Flipped mean is 75+5=8075+5=80, and the Online mean is 75−3=7275-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+SSESST = SSR + SSE (total = explained by group + within-group error)
  • R2=SSR/SSTR^2 = SSR/SST
  • F=SSR/(k−1)SSE/(n−k)F = \dfrac{SSR/(k-1)}{SSE/(n-k)}


This regression F-statistic, testing H0:β1=β2=⋯=0H_0: \beta_1=\beta_2=\cdots=0, is numerically identical to the ordinary ANOVA F-test of H0:μ1=μ2=⋯=μkH_0:\mu_1=\mu_2=\cdots=\mu_k.


A significant individual coefficient's t-test (e.g. testing β1=0\beta_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 mm, SE(β^1)=MSE(1m+1m)SE(\hat\beta_1) = \sqrt{MSE\left(\tfrac1m + \tfrac1m\right)}, and the reference distribution uses the error degrees of freedom n−kn-k.

Indicator coding and group sizes for a three-group fertilizer experiment, together with the fitted regression equation.

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 aa levels and Factor B at bb levels, the same counting rule applies twice. Main effects need (a−1)+(b−1)(a-1)+(b-1) dummies, and the interaction needs the (a−1)(b−1)(a-1)(b-1) products of those dummies. Adding the intercept gives 1+(a−1)+(b−1)+(a−1)(b−1)=ab1+(a-1)+(b-1)+(a-1)(b-1) = ab parameters, exactly one per cell, which is what 'saturated' means.



In the figure, the fertilizer growth data are modelled with two dummy variables, DBD_B and DCD_C, and the fitted model is Y^=20+4DB+7DC\hat{Y} = 20 + 4D_B + 7D_C. Which statement correctly describes what the intercept β^0=20\hat\beta_0 = 20 represents?

Indicator coding and group sizes for a three-group fertilizer experiment, together with the fitted regression equation.

Indicator coding and group sizes for a three-group fertilizer experiment, together with the fitted regression equation.

Raw plant-growth measurements by fertilizer group

Raw plant-growth measurements by fertilizer group

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Using the fitted regression equation shown in the figure, Y^=20+4DB+7DC\hat{Y} = 20 + 4D_B + 7D_C, 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.

Indicator coding and group sizes for a three-group fertilizer experiment, together with the fitted regression equation.

Raw plant-growth measurements by fertilizer group

Raw plant-growth measurements by fertilizer group

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A researcher fits the growth data by regressing YY on DBD_B and DCD_C and obtains β^1=4.00\hat\beta_1 = 4.00 with SE(β^1)=1.46SE(\hat\beta_1) = 1.46, computed from MSE=8.571MSE = 8.571 on dferror=21df_{error} = 21. Using tcrit≈2.080t_{crit}\approx 2.080 for a two-tailed test at α=0.05\alpha=0.05, which conclusion correctly links the coefficient test to the ANOVA comparison of the Group B and Group A means?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors