[R-sig-ME] Plotting predicted values mcmcglmm
Lotte van Boheemen
lotteanna at gmail.com
Mon Nov 30 10:55:57 CET 2015
Hi,
Our goal is to plot the predicted values of an 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).
Are we predicting the values of the model incorrectly or are we
interpreting the mcmcglmm output wrong?
Secondly, we have done quite some reading and ran several models on dummy
variables, and we are unsure if we can use offset in mcmcglmm. The offset
variable is in this case duration of the observation, influencing the
response variable as a longer observation will result in higher
NoFeeds. Outputs
of models with and without the offset variable give very similar results,
and correcting for observation duration in different ways leads to
different results.
Thank you in advance,
Lotte van Boheemen
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list