[R] plotting/examining residuals of a mixed generalised linear model

Ben Bolker bolker at ufl.edu
Thu Oct 15 15:25:30 CEST 2009




kath_oreilly wrote:
> 
> Dear R users,
> 
> I'm hoping that more experienced users will be able to assist me in
> examining the model fit of a mixed generalised linear model. The example
> using the data 'bacteria' within the MASS package will hopefully
> illustrate what I would like to acheive;
> 
> 

I think you're a little confused. Thanks for the reproducible example,
though.

First of all, you're confusing nlme ("old mixed models", described most
thoroughly
in Pinheiro and Bates 2000, good for correlation and heteroscedasticity
models
but not capable of doing GLMMs) with lme4 ("new mixed models", not yet
thoroughly documented but D. Bates is working on a book ...) Mixing
them is usually a bad idea.

The plotting capabilities aren't as highly developed for lme4 as for
nlme, but you can still get what you want done.

The r-sig-mixed-models list may be better for this kind of question.

Here's my solution to your problem:

library(MASS)
data(bacteria)

with(bacteria,table(y,trt))
library(lme4)
bacteria$pres <- as.numeric(bacteria$y=="y")  ## derive 0/1 variable
model <- lmer(pres ~ trt + (week|ID),family=binomial,data=bacteria)
summary(model)

with(bacteria,boxplot(residuals(model)~trt))

## or boxplot(residuals(model)~bacteria$trt)


-- 
View this message in context: http://www.nabble.com/plotting-examining-residuals-of-a-mixed-generalised-linear-model-tp25905522p25908589.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list