Skip to content

extract specific values from lmer summary

1 message · Ben Bolker

#
* yes, in general these sorts of question should go directly to
r-sig-mixed-models at r-project.org

 * it's mildly surprising but not shocking that this format doesn't work
any more.

 * without testing, here are a few idioms that should work better:


for(i in 1:nlevels(vital)) {
   lmer.sheep <- glmer(y ~ (1|year),
      family = binomial,
      data = subset(sheep.dat,vital==levels(vital)[i])
}

or

for(i in 1:nlevels(vital)) {
   lmer.sheep <- glmer(y ~ (1|year),
      family = binomial,
      data = sheep.dat,
      subset = vital==levels(vital)[i])
}

 or

model.list <- vector(nlevels(vital),mode="list")
model.list[[1]] <- glmer(y ~ (1|year),
      family = binomial,
      data = sheep.dat,
      subset = vital==levels(vital)[1])
for (i in 2:nlevels(vital)) {
  model.list[[i]] <- update(model.list[[1]],
       subset = vital==levels(vital)[i]
}

  etc.





-------- Original Message --------
Subject: Re: extract specific values from lmer summary
Date: Sun, 04 May 2014 15:25:42 -0800
From: Laura Prugh <lprugh at alaska.edu>
To: Ben Bolker <bbolker at gmail.com>

Hi Ben,
Sorry to bother you again (please let me know if you prefer I post these
questions to a list?)--I updated my version of R to the newest and reran
the code, which had run fine on the older version. It's now giving me an
error referring to how I'm trying to get it to loop through my
dataset--my code is:
for(i in 1:nlevels(vital)) {
lmer.sheep <- glmer(y[vital==levels(vital)[i]] ~
(1|year[vital==levels(vital)[i]]), family = binomial, data = sheep.dat)
}
and it gives the error:
Error in FUN(X[[1L]], ...) :
  Invalid grouping factor specification, year[vital == levels(vital)[i]]

When I put "year[vital == levels(vital)[i]]" directly into R, it appears
to work properly, and this syntax worked yesterday on the older R
version. Is a new syntax required or could this perhaps be a bug?

thanks,
Laura
On 5/2/2014 1:18 PM, Ben Bolker wrote: