Chapter 17 of 22 Statistics guide · Part 5: Beyond the basics

Repeated Measures ANOVA and Crossover Designs: Data Over Time and Covariance Structures

When the same animal or plot is measured again and again, the measurements are correlated, and an ordinary ANOVA treats them as independent. This chapter analyzes the weekly weights of the 24 pigs as repeated measures, compares covariance structures (compound symmetry, AR(1), unstructured), and explains crossover (changeover) designs, where each animal receives several treatments in turn.

  • Plant and animal examples
  • Worked by hand and in R
  • Sources cited
  • Free tools to try it

Quick answers

What are repeated measures?
Several measurements of the same experimental unit over time or space: weekly weights, monthly milk yield, soil moisture at several depths. They are correlated within each unit.
What is a repeated measures ANOVA?
An analysis that compares treatments over time while allowing for the correlation between measurements on the same unit. Today it is usually fitted as a mixed model.
Why not analyze each time point separately?
It ignores how responses change over time, multiplies tests, and wastes information. One model of treatment, time and treatment × time answers the question directly.
What is compound symmetry?
A covariance structure that assumes equal correlation between any two times on the same unit. AR(1) lets the correlation fade as times get further apart; unstructured estimates every correlation separately.
What is a crossover design?
Each animal receives every treatment in sequence, in separate periods with washouts in between. Animals act as their own controls, so far fewer are needed.
What is a carryover effect?
When a treatment from one period still affects the response in the next. Washout periods and balanced sequences (Williams designs) guard against it.
On this page
  1. Quick answers
  2. Why repeated measurements need special treatment
  3. Three ways to analyze repeated measures
  4. Choosing a covariance structure
  5. Reading the results: diet, time and diet × time
  6. Crossover (changeover) designs
  7. Repeated measures in R and SAS
  8. Key takeaways
  9. Questions people ask
  10. Sources

Why repeated measurements need special treatment

Weights of one pig at weeks 2 and 4 are more alike than weights of two different pigs: a heavy pig stays heavy. If you put all 96 weekly weights into an ordinary ANOVA, it counts 96 independent units when there are only 24 pigs, and treatment effects look far more certain than they are.

The experimental unit is still the pig; time is a factor applied within each pig, but it cannot be randomized. Repeated-measures analysis keeps the pig as the unit and models how its measurements correlate.

Three ways to analyze repeated measures

  1. Summary measures. Reduce each animal's series to one number that answers the question, such as its growth rate (ADG) or its area under the curve, and analyze that with an ordinary ANOVA. Simple, valid, and often the best choice. ADG in this guide is exactly that.
  2. Univariate repeated-measures ANOVA (split-plot in time): treats time as a subplot factor. It assumes sphericity (roughly, equal correlations between all pairs of times), which is rarely true for data over time; Greenhouse-Geisser or Huynh-Feldt corrections adjust for this.
  3. Mixed model with a covariance structure. Models the correlation directly, handles missing measurements and unequal spacing, and lets you compare structures. This is the modern standard.

Choosing a covariance structure

StructureAssumesParameters (4 times)
IndependentNo correlation (wrong for repeated data)1
Compound symmetry (CS)Equal variance, equal correlation between any two times2
First-order autoregressive, AR(1)Correlation ρ, ρ², ρ³… fading with distance in time2
Toeplitz (TOEP)Correlation depends only on the gap between times4
Unstructured (UN)Every variance and correlation free10

Pick the structure with the lowest AIC or BIC among sensible candidates, fitted by REML with the same fixed effects, before looking at treatment tests. Unstructured is the most flexible but needs many units relative to time points.

Reading the results: diet, time and diet × time

The diet main effect (p = 0.51) averages over weeks, including week 0 when no diet had acted yet, so it is not meaningful here. With growth data the summary-measure approach is often clearest: the ADG analysis in the ANOVA chapter asks the same question and, with litters as blocks, found p = 0.0003. Weights at week 0 can also serve as a covariate.

Crossover (changeover) designs

In a crossover design each animal receives every treatment, one per period: cow 1 gets diets A, B, C in that order, cow 2 gets B, C, A, and so on. Comparisons are made within animals, so the large differences between animals drop out and far fewer animals are needed. They are common in dairy nutrition, digestibility and metabolism studies, and in fistulated or cannulated animals.

  • Model: response = period + sequence + animal (random, within sequence) + treatment (+ carryover) + error.
  • Carryover: a treatment's effect lingers into the next period. Use washout periods and adaptation days before measuring.
  • Balanced sequences: Latin squares in which each treatment follows every other equally often (Williams designs) balance first-order carryover. Plan a study builds them.
  • Not suitable when treatments are permanent (castration, a vaccine), when the response changes steadily with time (lactation curve, growth), or when animals may drop out.

Repeated measures in R and SAS

In R

library(nlme)
wk <- read.csv("pig-weights-weekly.csv")
wk$diet <- factor(wk$diet); wk$week <- factor(wk$week)
cs <- gls(weight ~ diet * week, data = wk, correlation = corCompSymm(form = ~ 1 | pig))
ar <- gls(weight ~ diet * week, data = wk, correlation = corAR1(form = ~ 1 | pig))
un <- gls(weight ~ diet * week, data = wk, correlation = corSymm(form = ~ 1 | pig),
          weights = varIdent(form = ~ 1 | week))
AIC(cs, ar, un)
anova(un, type = "marginal")

In SAS

proc mixed data=weekly;
  class pig diet week;
  model weight = diet week diet*week / ddfm=kr;
  repeated week / subject=pig type=un;     /* try cs, ar(1), toep */
  lsmeans diet*week / slice=week;          /* diets compared at each week */
run;

Key takeaways

  • Measurements on the same unit are correlated; ignoring that makes effects look more certain than they are.
  • Summary measures (slope, area under the curve) are simple and often the best analysis.
  • Mixed models with a chosen covariance structure (CS, AR(1), UN) are the modern standard; choose by AIC or BIC before testing.
  • The treatment × time interaction asks whether responses diverge over time.
  • Crossover designs use each animal as its own control, but need washouts and balanced sequences to handle carryover.

Questions people ask

What is sphericity?

The assumption of the univariate repeated-measures ANOVA that the variances of differences between all pairs of time points are equal. Mauchly's test checks it; mixed models avoid the assumption.

Can repeated measures handle missing values?

Mixed models use all available measurements, so an animal missing one weighing still contributes. The classic univariate and multivariate approaches drop the whole animal.

Is time a fixed or random effect?

Usually fixed, as a factor (week 0, 2, 4, 6) or as a numeric trend. The correlation over time is handled by the covariance structure or a random slope.

How long should a washout period be?

Long enough for the previous treatment to stop acting, judged from its biology: often 1 to 3 weeks for diets in ruminants, with the last days of each period used for measurement.

Sources

  • Littell, R. C., Henry, P. R., and Ammerman, C. B. (1998). Statistical analysis of repeated measures data using SAS procedures. Journal of Animal Science, 76(4), 1216–1231.
  • Kaps, M., and Lamberson, W. R. (2017). Biostatistics for Animal Science (3rd ed.), chapters on changeover designs and repeated measures. CABI.
  • Williams, E. J. (1949). Experimental designs balanced for the estimation of residual effects of treatments. Australian Journal of Scientific Research, 2(3), 149–168.