Dear Fellows,
I?m sorry if my question is very basic, but I'm still new in the field of R
and the GLMM.
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!
Sorry for attaching the dataset, but it is too long.
##GLMM
Lac=read.table("loxoacc10.txt",header=T)
library(lme4)
glmm1 <- glmer(Acc ~ Prey + (1 | Sp), family=binomial)
summary(glmm1)
overdisp_fun <- function(model) {
## number of variance parameters in
## an n-by-n variance-covariance matrix
vpars <- function(m) {
nrow(m)*(nrow(m)+1)/2
}
overdisp_fun(glmm1)#Check for overdispersal
-------------- next part --------------
Sp Acc Prey
1 1 hormiga
1 1 termita
1 1 larva
1 0 cochinilla
2 0 hormiga
2 1 termita
2 0 larva
2 0 cochinilla
3 0 hormiga
3 1 termita
3 1 larva
3 1 cochinilla
4 1 hormiga
4 0 termita
4 0 larva
4 1 cochinilla
5 1 hormiga
5 0 termita
5 1 larva
5 0 cochinilla
6 1 hormiga
6 1 termita
6 1 larva
6 0 cochinilla
7 1 hormiga
7 1 termita
7 1 larva
7 1 cochinilla
8 1 hormiga
8 1 termita
8 1 larva
8 1 cochinilla
9 1 hormiga
9 1 termita
9 1 larva
9 0 cochinilla
10 1 hormiga
10 1 termita
10 0 larva
10 1 cochinilla
11 1 hormiga
11 1 termita
11 1 larva
11 0 cochinilla
12 1 hormiga
12 1 termita
12 1 larva
12 1 cochinilla
13 1 hormiga
13 1 termita
13 1 larva
13 1 cochinilla
14 1 hormiga
14 1 termita
14 1 larva
14 0 cochinilla
15 1 hormiga
15 1 termita
15 1 larva
15 0 cochinilla
16 1 hormiga
16 1 termita
16 1 larva
16 0 cochinilla
17 1 hormiga
17 0 termita
17 1 larva
17 0 cochinilla
18 1 hormiga
18 1 termita
18 1 larva
18 1 cochinilla
19 0 hormiga
19 1 termita
19 1 larva
19 0 cochinilla
20 0 hormiga
20 1 termita
20 1 larva
20 1 cochinilla
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 ...