[R] fixed effects anova in lme lmer

Simon Blomberg s.blomberg1 at uq.edu.au
Wed Jun 6 04:23:43 CEST 2007

?gls in package nlme. It's like lme but with no random effects. But you
can still model the variance-covariance properties of the data.


On Tue, 2007-06-05 at 19:11 -0700, toby909 at gmail.com wrote:
> 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
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 

Room 320, Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au 

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

More information about the R-help mailing list