[R] Intercept in lm and in library(car): Anova
Stefan Th. Gries
stgries at gmail.com
Fri Sep 14 20:08:31 CEST 2007
Hi
I have two questions regarding the meaning of intercept outputs of lm.
Question 1: In data set 1 (a fully-balanced design), the line with
(Intercept) contains the overall mean, and the estimates contain the
differences from the overall mean (matching those from model.tables).
But in data set 2, the line with the intercept does not correspond to
the overall mean and the estimates don't correspond to the differences
outputted by model.tables. What does the output contain here?
#####
rm(list=ls(all=TRUE))
options(contrasts=c("contr.sum", "contr.poly"))
# data set 1
Y1<-c(43, 23, 88, 45, 2, 68, 39, 41, 55, 64, 91, 9, 90, 37, 88, 41)
M1<-factor(c("k", "g", "k", "g", "k", "k", "g", "g", "g", "g", "k",
"k", "g", "g", "k", "k"))
N1<-factor(c("k", "g", "g", "k", "k", "g", "k", "g", "k", "g", "g",
"k", "g", "k", "g", "k"))
# linear model 1
model1<-lm(Y1~M1*N1); summary(model1)
model.tables(aov(Y1~M1*N1), "means")
model.tables(aov(Y1~M1*N1))
# data set 2
Y2<-c(34, 16, 46, 5, 2, 78, 31, 39, 25, 64, 45, 92, 65, 91, 60, 12,
33, 40, 72, 61, 49, 59)
M2<-factor(c(rep("a", 10), rep("b", 12)))
N2<-factor(c(rep("d", 4), rep("e", 6), rep("d", 8), rep("e", 4)))
# linear model 2
model2<-lm(Y2~M2*N2); summary(model2)
model.tables(aov(Y2~M2*N2), "means")
model.tables(aov(Y2~M2*N2))
#####
Question 2: what does the line with (Intercept) mean that the
following lines produce?
#####
library(car)
Anova(model, type=c("III"))
#####
Any help would be much appreciated. Thx,
STG
More information about the R-help
mailing list