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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 02 Apr 2007 - 14:07:03 GMT

The short answer is that lm() is written more robustly. I don't think either should fail, but without a reproducible example it is hard to tell.

On Mon, 2 Apr 2007, Michael Kubovy wrote:

> 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'))

I don't know what c.setSize is, but data=osss, subset=subs=='42' is a much clear way to write this lm() call.

> 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.
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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 Tue Apr 03 00:11:29 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:38 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.