[R-sig-ME] Fitted values for binomial family in lme4a{glmer}

Ben Bolker bbolker at gmail.com
Fri Dec 10 22:59:35 CET 2010


On 10-12-10 08:01 AM, Douglas Bates wrote:
> On Tue, Nov 23, 2010 at 12:05 PM, Kevin E. Thorpe
> <kevin.thorpe at utoronto.ca> wrote:
>> I searched the archives and found questions like this with no definitive
>> answers.  I also did not find an answer in the lme4a help files.
> 
>> I'm using lme4a_0.999375-57 in R version 2.12.0 Patched (2010-11-07 r53537) on
>> Platform: i686-pc-linux-gnu (32-bit).
>>
>> I've fit a model with glmer() using the binomial family.  I'm wondering what
>> fitted() gives on the result.  It appears that fitted() on a regular logistic
>> model fit with glm() returns fitted probabilities.  It looks like the same
>> behaviour occurs with a glmer() object, but some confirmation would be nice.
> 
> Yes, the value of the fitted method is on the scale of the mean
> response, which is the probability scale when using a binomial family.

   This is not necessarily easy for everyone, but I find the "empirical
hack" approach works well for answering these questions (often easier
than reading the source, and sometimes even easier than reading the
docs): make up an example where you know the answer.

f <- factor(rep(LETTERS[1:10],each=10))
set.seed(101)
rf <- rnorm(10)
eta <- rf[f]
p <- plogis(eta)
N <- 10
y <- rbinom(length(f),size=N,prob=p)

library(lme4)
m <- glmer(y~1+(1|f))
plot(N*p,fitted(m),xlab="true",ylab="est")
abline(a=0,b=1)

  So fitted() is on the "N*p" scale ...

  (oops, I did this with lme4 not lme4a.  You could try it for lme4a, or
just take Doug's word for it :-)  )




More information about the R-sig-mixed-models mailing list