[R-sig-ME] lme4 error: "Number of levels of a grouping factor . . ."
Brent Pedersen
bpederse at gmail.com
Wed Jul 27 19:50:10 CEST 2011
On Wed, Jul 27, 2011 at 7:34 AM, Ben Bolker <bbolker at gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 07/27/2011 03:29 AM, Martin Maechler wrote:
>>>>>>> Gabrielle Miller-Messner <gmessner at ucdavis.edu>
>>>>>>> on Tue, 26 Jul 2011 22:26:38 -0700 writes:
>>
>> > Hello, I have count/proportion data and I am trying to
>> > account for overdispersion in a logistic regression. With
>> > the following code from lme4 I receive the following error
>> > message:
>>
>> >> glmm = glmer(cbind(fertilized, unfert) ~ density.class +
>> > (1|individual), family = binomial)
>> > Number of levels of a grouping factor for the random effects
>> > is *equal* to n, the number of > observations
>>
>> > This problem was mentioned in Warton and Hui 2011, so I
>> > imagine it may have been fixed recently. I downloaded the
>> > most recent version of lme4 available through the command
>> > install.packages("lme4"). Is there an updated version of
>> > the package available in a different form?
>>
>> {yes, lme4a on R-forge, but that's not the issue now, and not
>> something I'd recommend to get into just right now ...}
>>
>> Well, I'm puzzled that you say you get an *error* with the above
>> message.
>> You should get a message, but no error in the case of glmer().
>
> Probably this is indeed just a warning message and not an error?
> Gabrielle, does the function return an answer (i.e. a fitted model)?
>
Hi, I've hit this as well. with:
> packageVersion("lme4a")
[1] ‘0.999375.67’
(should I be using another version?)
and code:
"""
library(lme4a)
d = data.frame(a=runif(200),
b=sample(c(strsplit("ABCDEF", "")[[1]]), 200, replace=T),
c=as.factor(1:200))
# d$c[2] = d$c[1]
fm = glmer(a ~ b + (1|c), d)
"""
it shows:
"""
Error in lmer(formula = a ~ b + (1 | c), data = d) :
number of levels of each grouping factor must be less than number of obs
"""
and if i uncomment that line to make the number of grouping factors (c) less
than the number of obs, it runs successfully.
not sure if this is different for binomial...
>>
>>
>> Just to be sure: What does
>> packageVersion("lme4")
>> say for you?
>>
>> Martin
>>
>>
>> > I am using R version 2.13.1 on OS 10.6.4.
>>
>> > thank you! Gabrielle
>>
>> > --
>> > Gabrielle Miller-Messner Graduate Student Center for
>> > Population Biology Section of Evolution and Ecology
>> > University of California, Davis 1 Shields Avenue Davis,
>> > California 95616 gmessner at ucdavis.edu
>>
>> > [[alternative HTML version deleted]]
>>
>> > _______________________________________________
>> > R-sig-mixed-models at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk4wE90ACgkQc5UpGjwzenPiQACeJ33UCdFDFRUi3V3wh4VHEk+G
> KFMAnjA3LOzKK4pj7VnqbzmYaukQT6FV
> =jGz9
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list