O'Reilly logo

The R Book by Michael J. Crawley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A More Complex ANCOVA: Two Factors and One Continuous Covariate

The following experiment, with Weight as the response variable, involved Genotype and Sex as two categorical explanatory variables and Age as a continuous covariate. There are six levels of Genotype and two levels of Sex.

Gain <-read.table("c:\\temp\\Gain.txt",header=T)
attach(Gain)
names(Gain)

[1] "Weight" "Sex" "Age" "Genotype" "Score"

We begin by fitting the maximal model with its 24 parameters: different slopes and intercepts for every combination of Sex and Genotype.

m1<-lm(Weight~Sex*Age*Genotype)
summary(m1)
Coefficients: Estimate Std. Error t value Pr (>|t|) (Intercept) 7.80053 0.24941 31.276 < 2e-16 *** Sexmale -0.51966 0.35272 -1.473 0.14936 Age 0.34950 0.07520 4.648 4.39e-05 *** GenotypeCloneB 1.19870 0.35272 3.398 0.00167 ** GenotypeCloneC -0.41751 0.35272 -1.184 0.24429 GenotypeCloneD 0.95600 0.35272 2.710 0.01023 * GenotypeCloneE -0.81604 0.35272 -2.314 0.02651 * GenotypeCloneF 1.66851 0.35272 4.730 3.41e-05 *** Sexmale:Age -0.11283 0.10635 -1.061 0.29579 Sexmale:GenotypeCloneB -0.31716 0.49882 -0.636 0.52891 Sexmale:GenotypeCloneC -1.06234 0.49882 -2.130 0.04010 * Sexmale:GenotypeCloneD -0.73547 0.49882 -1.474 0.14906 Sexmale:GenotypeCloneE -0.28533 0.49882 -0.572 0.57087 Sexmale:GenotypeCloneF -0.19839 0.49882 -0.398 0.69319 Age:GenotypeCloneB -0.10146 0.10635 -0.954 0.34643 Age:GenotypeCloneC -0.20825 0.10635 -1.958 0.05799 . Age:GenotypeCloneD -0.01757 0.10635 -0.165 0.86970 Age:GenotypeCloneE ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required