[R-sig-ME] Residuals for a binomial lmer model

Andy Fugard a.fugard at ed.ac.uk
Fri Mar 14 13:37:09 CET 2008


I was wondering how to get residuals out of binomial lmers as the 
"residuals" function isn't implemented.  I've noticed a few other people 
ask the question too but get no response.  (Or at least I haven't found 
a response.)

I guess the answer is just to use the "fitted" function, which is 
implemented for binomial GLMMs.

Take the sleepstudy data, dichotomize Reaction (just to give us a 
dataset), and fit a multilevel logistic model:

med = median(sleepstudy$Reaction)
sleepstudy$bin = (sleepstudy$Reaction > med) + 0
M2 = lmer(bin ~ Days + (1|Subject) + (0+Days|Subject),
           data = sleepstudy, family = binomial)

We can pull out the fitted values and, say, plot fitted (post-inverse
logit) against data using a boxplot:

ilog = function(x) { 1/(1 + exp(-x)) }
boxplot(ilog(fitted(fm3)) ~ bin, data = sleepstudy)

Not sure now how useful this is, but I had some reason for wanting to peek!


Andy Fugard, Postgraduate Research Student
Psychology (Room F3), The University of Edinburgh,
   7 George Square, Edinburgh EH8 9JZ, UK
Mobile: +44 (0)78 123 87190   http://www.possibly.me.uk

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