[R] Why does lmList() fail when lm() doesn't?

From: Michael Kubovy <kubovy_at_virginia.edu>
Date: Mon 02 Apr 2007 - 13:11:07 GMT


Dear r-helpers,

Can anyone suggest why lm() doesn't complain here:

summary(osss.lm1 <- lm(logOdds ~ c.setSize %in% task, data = osss))

whereas in package:nlme (and in package:lme4)

osss.lmL <- lmList(logOdds ~ c.setSize %in% task | subj, data = osss)
# Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
# contrasts can be applied only to factors with 2 or more levels

If it were because for each subj I have only 1 datum per cell:

with(subset(osss, osss$subj == '42'), table(setSize, task))
# task
# setSize os ss
# 2 1 1
# 3 1 1
# 4 1 1
# 5 1 1
# 6 1 0
# 7 1 0

then

osss.lm1 <- lm(logOdds ~ c.setSize %in% task, data = subset(osss, osss $subj == '42'))

should fail as well, but I get

anova(osss.lm1)
# Analysis of Variance Table
#
# Response: logOdds
# Df Sum Sq Mean Sq F value Pr(>F)
# c.setSize:task 2 6.8269 3.4134 1.9976 0.2059
# Residuals 7 11.9612 1.7087



Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766

WWW: http://www.people.virginia.edu/~mk9y/

R-help@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. Received on Mon Apr 02 23:40:22 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 02 Apr 2007 - 14:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.