[R-sig-ME] Predicted values and confidence intervals

Renwick, A. R. a.renwick at abdn.ac.uk
Fri Mar 20 20:40:07 CET 2009


Dear All

I have tried to calculate the predicted values of my model estimates based only on the fixed effects from a GLMM model with Binomial error using the lme4 package. I graphed these along with te observed data.
I would be grateful if anybody has any comments on this.

An example of the code is:
#model of tick presence with width, Nhat (vole abundance) and alt(alternative host abundance) as variables
ball<-lmer(TrianPresence~width+Nhat+alt+(1|Farm/LocTran), family=binomial, data=tick, REML=FALSE)

#I then created a function to backtransform the logit estimates
invlogit<-function(x){1/(1+exp(-x))}

#I then created function to jitter the binary observed data while keeping pts between 0 and 1
jitter.binary<-function(a, jitt=0.05){
ifelse(a==0,runif(length(a),0,jitt),runif(length(a),1-jitt,1))}

#I then graphed the observed data against the variable I was interested in (Nhat)
tick.jitter<-jitter.binary(tick$TrianPresence)

plot(tick$Nhat,tick.jitter,xlim=c(0,max(tick$Nhat)),ylab="predicted probability",xlab="vole abundance",cex.axis=1.3,cex.lab=1.3, ylim=c(0,1))

#I then added the predicted probabilities of the fixed effects holding the other variables constant
curve(invlogit(cbind(1,0,x,0)%*%fixef(ball)),add=TRUE,lty=1,lwd=3)


Now this does not produce any standard errors but I was wondering if it was possible to add a 95% confidence interval to this based on 1.95*St Dev of the random effect.  If I had a simple structure such as (1|Group) then this would be simplier but I have a nested structure (1|Farm/LocTran).  I therefore took the St Dev of the between LocTran within Farm to be the most conservative:

#so to add the 95% CI when the St Dev of  between LocTran within Farm is 0.2913
curve(invlogit(cbind(1,0,x,0)%*%fixef(ball)+(1.95*0.2913)),add=TRUE,lty=1,lwd=3)
curve(invlogit(cbind(1,0,x,0)%*%fixef(ball)-(1.95*0.2913)),add=TRUE,lty=1,lwd=3)

Many thanks,
Anna

Anna Renwick
Institute of Biological & Environment Sciences
University of Aberdeen
Zoology Building
Tillydrone Avenue
Aberdeen
AB24 2TZ


The University of Aberdeen is a charity registered in Scotland, No SC013683.




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