[R] help plotting glmm values

Ben Bolker bbolker at gmail.com
Fri Aug 7 18:12:25 CEST 2015


Luis Fernando García <luysgarcia <at> gmail.com> writes:

> 
> Dear Fellows,
> 
> I´m sorry if my question is very basic, but I'm still new in the field of R
> and the GLMM.

  In future, you might consider posting to r-sig-mixed-models at r-project.org
instead ...

> I have made a following glmm, and I need to plot the predicted mean values
> from the model and the CI, with this barplot +/- the CI, using the prey as
> explanatory factor.
> 
>  Although I have been looking for it, I have not found 
> a website which show
> the way to do this, so  I'm unsure about the right procedure. 
> If any of you
> could help me with the correct procedure I would really apprreciate it!

See:

http://glmm.wikidot.com/faq#predconf
http://ms.mcmaster.ca/~bolker/R/misc/foxchapter/  

Some modified analysis:

library(lme4)
glmm1 <- glmer(Acc ~ Prey + (1 | Sp), data=Lac, family=binomial)
summary(glmm1)
deviance(glmm1)/df.residual(glmm1)
glmm2 <- update(glmm1,nAGQ=10)

## aggregate
library(plyr)
Lac_agg <- ddply(Lac,c("Prey","Sp"),
                 summarise,
                 N=length(Acc),
                 p=mean(Acc))
Lac_agg <- aggregate(Acc~Prey*Sp,FUN=function(x) c(k=sum(x),N=length(x)),
                     data=Lac)
glmm3 <- glmer(p ~ Prey + (1 | Sp), weights=N,
               data=Lac_agg, family=binomial)
deviance(glmm3)/df.residual(glmm3)
## model with ind-level obs blows up: leave it alone ...


More information about the R-help mailing list