[R] Why does lmList() fail when lm() doesn't?
Petr Klasterecky
klaster at karlin.mff.cuni.cz
Mon Apr 2 16:04:05 CEST 2007
Michael Kubovy napsal(a):
> Dear r-helpers,
>
> Can anyone suggest why lm() doesn't complain here:
No, we can't since we don't have your data and we have no idea what
logOdds, task and osss are...
The error given below says you are trying to model the effect of a
factor, which however only has 1 level. So maybe lm() didn't treat your
variable(s) as factor(s) while lmList does?
Petr
>
> 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 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.
>
--
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic
More information about the R-help
mailing list