[R] fixed effects anova in lme lmer

toby909 at gmail.com toby909 at gmail.com
Wed Jun 6 04:11:17 CEST 2007


Can lme or lmer fit a plain regular fixed effects anova? Ie a model without a 
random effect, or have there be at least one random effect in order for these 
functions to work?

Trying to run such, (1) without specifying a random effect produces an error, 
(2) specifying that there is no random effect does not produce the same output 
as  an anova run in lm(); (2b) specifying that there is no random effect in lmer 
crashed R (division by zero, I think).

Just trying to see the connection of fixed and random effects anova in R. STATA 
gives me same results for both models up to the point where they differ.

Best Toby





dt1 = 
as.data.frame(cbind(c(28,35,27,21,21,36,25,18,26,38,27,17,16,25,22,18),c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)))

summary(a1 <- lm(V1~factor(V2)-1, dt1))
anova(a1)

summary(a1 <- lm(V1~factor(V2), dt1))
anova(a1)

dt1$f = factor(dt1$V2)

summary(a2 <- lme(V1~f, dt1))   #1a

summary(a2 <- lme(V1~f, dt1, ~-1|f))   #2a
anova(a2)

lmer(V1~f, dt1)   #1b

lmer(V1~f+(-1|f), dt1)   #2b



More information about the R-help mailing list