[R-sig-ME] Curved residuals vs fitted plot
Paul Johnson
paul.johnson at glasgow.ac.uk
Sat Mar 8 02:26:38 CET 2014
Hi Victoria,
Positive correlation between the residuals and fitted values is expected whenever you have a row-level random effect to mop up overdispersion. It happens because overdispersion implies that the low responses are lower than predicted and the high responses are higher than predicted, even allowing for binomial sampling error. The gap between a low predicted proportion and a still lower observed proportion is bridged partly by a negative residual and partly by a negative overdispersion random effect (which can be thought of as an additional 'free' residual to the constrained residual due to binomial sampling error). The same happens at the highest predicted proportions, except that both residual and random effect will be positive, hence the positive correlation between the predicted (fitted) values, which contain the overdispersion random effects, and the residuals.
This problem is dealt with, for binomial GLMMs, in chapter 7 of Alain Zuur's Beginner's guide to GLM and GLMM with R. I don't have this book handy and I can't remember his solution. One solution is to shift the overdispersion random effect from the fitted values to the residuals, which makes sense given that they are really just add-on residuals - see the example code below.
This thread discusses the same problem for lognormal-Poisson GLMMs:
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2013q3/020819.html
Best wishes,
Paul
# simulate binomial data with a positive trend and overdispersion
obs <- factor(1:100)
x <- seq(-1, 0.98, 0.02)
set.seed(12345678)
y <- rbinom(100, 20, plogis(x + rnorm(100, 0, 1)))
par(mfrow=c(3, 1))
plot(y/20 ~ x)
# fit logitnormal-binomial GLMM
fit <- glmer(cbind(y, 20-y) ~ I(1:100) + (1|obs), family="binomial")
summary(fit)
# standard residual vs fitted plot
plot(fitted(fit), resid(fit))
abline(h=0)
# shift overdispersion random effect from fitted values to residuals
Fitted <- plogis(qlogis(fitted(fit)) - ranef(fit)$obs[[1]])
Resid <- (y/20 - Fitted) / sqrt(Fitted * (1 - Fitted)/20)
plot(Fitted, Resid)
abline(h=0)
# NB THIS GETS RID OF THE TREND BUT ISN'T RIGHT!
# This is because I've standardised the variance using the
# variance function for the binomial, p(1-p)/n, but the distribution
# underlying the residuals is now a logitnormal-binomial
# so should incorporate the overdispersion variance. I don't
# know how to do this.
________________________________________
From: r-sig-mixed-models-bounces at r-project.org [r-sig-mixed-models-bounces at r-project.org] On Behalf Of Victoria Wickens [V.J.Wickens at pgr.reading.ac.uk]
Sent: 07 March 2014 19:20
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] Curved residuals vs fitted plot
Dear mixed-models group,
Thank you for taking time to read this plea for help.
I wondered if you could give me any advice regarding the curved residuals vs fitted plot with my model:
model3<-glmer(y~Treatment*Distance.m+(1|Field/Field.section/Transect/fffPlot/Bait.ID),
binomial(link=logit),data=dframe1)
My aim is to explain aphid removal from bait trays in response to treatment (presence of absence of a flower strip) and distance (five distances, or plots, moving away from the margins; 1, 5, 10, 15, and 20m). (More experimental details after message in case helpful).
I am using R version 3.0.2 and the latest version of lme4. The resid vs fitted figure is not great, is this because I need to look at a logit fitted scale? (See here to view the figure: <http://imgur.com/CYe5CxC> http://imgur.com/CYe5CxC)
Any help at all would be more than amazing,
Victoria
Experimental setup
There are two fields overall, each contains one treatment (Mit) and one control (Non). Looking at one treatment, in one field section, there are three transects parallel to each other and perpendicular to the margin treatment (T1, T2 and T3). There are five plots along each transect at specific distances from the treatment margins (1, 5, 10, 15, 20m). At each plot, three replica bait trays were placed (a, b and c). Each tray contained 20 aphids glued to foam. In total, I had two farm fields at the largest scale and between them there were 180 bait trays overall (90 per field).
Script attached, also listed below
library(lme4)
Field<-c("L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L" ,"L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 10" ,"D T2 15" ,"D T2 15" ,"D T2 15" ,"D T2 20" ,"D T2 20" ,"D T2 20" ,"D T3 1" ,"D T3 1" ,"D T3 1" ,"D T3 5" ,"D T3 5" ,"D T3 5" ,"D T3 10" ,"D T3 10" ,"D T3 15" ,"D T3 15" ,"D T3 15" ,"D T3 20" ,"D T3 20" ,"D T3 20" ,
"C T1 1" ,"C T1 1" ,"C T1 1" ,"C T1 5" ,"C T1 5" ,"C T1 5" ,"C T1 10" ,"C T1 10" ,"C T1 10" ,"C T1 15" ,"C T1 15" ,"C T1 15" ,"C T1 20" ,"C T1 20" ,"C T1 20" ,"C T2 1" ,"C T2 1" ,"C T2 1" ,"C T2 5" ,"C T2 5" ,"C T2 5" ,"C T2 10" ,"C T2 10" ,"C T2 10" ,"C T2 15" ,"C T2 15" ,"C T2 15" ,"C T2 20" ,"C T2 20" ,"C T2 20" ,"C T3 1" ,"C T3 1" ,"C T3 1" ,"C T3 5" ,"C T3 5" ,"C T3 5" ,"C T3 10" ,"C T3 10" ,"C T3 10" ,"C T3 15" ,"C T3 15" ,"C T3 15" ,"C T3 20" ,"C T3 20" ,"C T3 20" ,"B T1 1" ,
"B T1 1" ,"B T1 1" ,"B T1 5" ,"B T1 5" ,"B T1 5" ,"B T1 10" ,"B T1 10" ,"B T1 10" ,"B T1 15" ,"B T1 15" ,"B T1 15" ,"B T1 20" ,"B T1 20" ,"B T1 20" ,"B T2 1" ,"B T2 1" ,"B T2 1" ,"B T2 5" ,"B T2 5" ,"B T2 5" ,"B T2 10" ,"B T2 10" ,"B T2 10" ,"B T2 15" ,"B T2 15" ,"B T2 15" ,"B T2 20" ,"B T2 20" ,"B T2 20" ,"B T3 1" ,"B T3 1" ,"B T3 1" ,"B T3 5" ,"B T3 5" ,"B T3 5" ,"B T3 10" ,"B T3 10" ,"B T3 10" ,"B T3 15" ,"B T3 15" ,"B T3 15" ,"B T3 20" ,"B T3 20" ,"B T3 20" ,"A T1 1" ,"A T1 1" ,"A T1 1" ,
"A T1 5" ,"A T1 5" ,"A T1 5" ,"A T1 10" ,"A T1 10" ,"A T1 10" ,"A T1 15" ,"A T1 15" ,"A T1 15" ,"A T1 20" ,"A T1 20" ,"A T1 20" ,"A T2 1" ,"A T2 1" ,"A T2 1" ,"A T2 5" ,"A T2 5" ,"A T2 5" ,"A T2 10" ,"A T2 10" ,"A T2 10" ,"A T2 15" ,"A T2 15" ,"A T2 15" ,"A T2 20" ,"A T2 20" ,"A T2 20" ,"A T3 1" ,"A T3 1" ,"A T3 1" ,"A T3 5" ,"A T3 5" ,"A T3 5" ,"A T3 10" ,"A T3 10" ,"A T3 10" ,"A T3 15" ,"A T3 15" ,"A T3 15" ,"A T3 20" ,"A T3 20" ,"A T3 20")
Bait.ID<-c("ID1" ,"ID2" ,"ID3" ,"ID3" ,"ID4" ,"ID5" ,"ID6" ,"ID7" ,"ID8" ,"ID9" ,"ID10" ,"ID11" ,"ID12" ,"ID13" ,"ID14" ,"ID15" ,"ID16" ,"ID17" ,"ID18" ,"ID19" ,"ID20" ,"ID21" ,"ID22" ,"ID23" ,"ID24" ,"ID25" ,"ID26" ,"ID27" ,"ID28" ,"ID29" ,"ID30" ,"ID31" ,"ID32" ,"ID33" ,"ID34" ,"ID35" ,"ID36" ,"ID37" ,"ID38" ,"ID39" ,"ID40" ,"ID41" ,"ID42" ,"ID43" ,"ID44" ,"ID45" ,"ID46" ,"ID47" ,"ID48" ,"ID49" ,"ID50" ,"ID51" ,"ID52" ,"ID53" ,"ID54" ,"ID55" ,"ID56" ,"ID57" ,"ID58" ,"ID59" ,"ID60" ,"ID61" ,"ID62" ,
"ID63" ,"ID64" ,"ID65" ,"ID66" ,"ID67" ,"ID68" ,"ID69" ,"ID70" ,"ID71" ,"ID72" ,"ID73" ,"ID74" ,"ID75" ,"ID76" ,"ID77" ,"ID78" ,"ID79" ,"ID80" ,"ID81" ,"ID82" ,"ID83" ,"ID84" ,"ID85" ,"ID86" ,"ID87" ,"ID88" ,"ID89" ,"ID90" ,"ID91" ,"ID92" ,"ID93" ,"ID94" ,"ID95" ,"ID96" ,"ID97" ,"ID98" ,"ID99" ,"ID100" ,"ID101" ,"ID102" ,"ID103" ,"ID104" ,"ID105" ,"ID106" ,"ID107" ,"ID108" ,"ID109" ,"ID110" ,"ID111" ,"ID112" ,"ID113" ,"ID114" ,"ID115" ,"ID116" ,"ID117" ,"ID118" ,"ID119" ,"ID120" ,"ID121" ,"ID122" ,
"ID123" ,"ID124" ,"ID125" ,"ID126" ,"ID127" ,"ID128" ,"ID129" ,"ID130" ,"ID131" ,"ID132" ,"ID133" ,"ID134" ,"ID135" ,"ID136" ,"ID137" ,"ID138" ,"ID139" ,"ID140" ,"ID141" ,"ID142" ,"ID143" ,"ID144" ,"ID145" ,"ID146" ,"ID147" ,"ID148" ,"ID149" ,"ID150" ,"ID151" ,"ID152" ,"ID153" ,"ID154" ,"ID155" ,"ID156" ,"ID157" ,"ID158" ,"ID159" ,"ID160" ,"ID161" ,"ID162" ,"ID163" ,"ID164" ,"ID165" ,"ID166" ,"ID167" ,"ID168" ,"ID169" ,"ID170" ,"ID171" ,"ID172" ,"ID173" ,"ID174" ,"ID175" ,"ID176" ,"ID177" ,"ID178" ,
"ID179")
dframe1<-data.frame(Field,Treatment,Field.section,Transect,Distance.m,Aphid.rm.success,Aphid.remain.fail,fffPlot,Bait.ID)
y<-cbind(Aphid.rm.success,Aphid.remain.fail)
model3<-glmer(y~Treatment*Distance.m+(1|Field/Field.section/Transect/fffPlot/Bait.ID), # Bait.ID to remove overdispersion
binomial(link=logit),data=dframe1) # note I kept fffPlot smallest scale in (better residuals)
summary(model3)
plot(model3) # issue? Or just messy ecological data?
______________
Victoria Wickens
PhD student
Room GU08
Centre for Agri-Environmental Research (CAER)
School of Agriculture, Policy & Development
University of Reading
Reading RG6 7BE
____________
Email: v.j.wickens at pgr.reading.ac.uk<mailto:v.j.wickens at pgr.reading.ac.uk>
http://www.reading.ac.uk/caer/staff_students.html
https://www.facebook.com/UniRdgAPD
More information about the R-sig-mixed-models
mailing list