[R-sig-ME] Plotting predicted values mcmcglmm

Lotte van Boheemen lotte.van.boheemen at monash.edu
Mon Nov 23 23:58:48 CET 2015


Hi,

My goal is to plot the predicted values of the mcmcglmm model with
variables: NoFeeds ~  offset(ObsDuration) + Month + AnnualInsects +
TQc_Combined + NoOffspring + NoH*Status + Status*WatchType ,
random=~idh(Status):BirdID + NestID:NestWatchID + Obs

Predicted values are calculated as:
mpred0 <- predict(model,interval="confidence")
colnames(mpred0) <- paste("mpred0",c("fit","lwr","upr"),sep=".")
mpred1 <- predict(model,interval="confidence",marginal=~ BirdID + MateID +
NestID:NestWatchID + Year:Month + Obs)
colnames(mpred1) <- paste("mpred1",c("fit","lwr","upr"),sep=".")
dataf <- data.frame(data_UnID,mpred0,mpred1)

g0 <- ggplot(dataf,aes(x=NoH,y=FeedsPerHour))+
  stat_sum(aes(size=factor(..n..)),alpha=0.5)+
  facet_grid(~Status+WatchType)+
  scale_size_discrete(name="n",range=c(2,5))
g0 + geom_line(aes(x=as.numeric(NoH),y=mpred0.fit),colour="red")+
  geom_ribbon(aes(x=as.numeric(NoH),y=mpred0.fit,
                  ymin=mpred0.lwr,ymax=mpred0.upr),fill="red",
              alpha=0.3)


However, the plots this results in show 'jagged' predictions for the model,
e.g. it seems like at one particular value of NoH, the model predicts 2
different values, which is not the case (figure attached).

Lotte Anna van Boheemen
PhD Research Candidate
School of Biological Sciences
Monash University

   -
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sel.pdf
Type: application/pdf
Size: 52439 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20151124/150647fd/attachment-0001.pdf>


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