Skip to content
Prev 16183 / 20628 Next

Plotting MCMCglmm regression with credible intervals

Hi Jon,

You can use predict on newdata:

newdata<-df
newdata$x<-seq(min(df$x), max(df$x), length=100)

p1<-predict(model1, newdata=newdata, interval="confidence")

plot(df$x,df$y)
lines(p1[,1]~newdata$x,col="red")
lines(p1[,2]~newdata$x,col="red",lty=2)
lines(p1[,3]~newdata$x,col="red", lty=2)

The predict function with default arguments is quite slow with 
non-Gaussian data because it uses numerical integration to integrate 
over the random effects (if they are to be marginalised). However, the 
integrals can be approximated using Taylor expansion (approx="taylor") 
or if the response involves a logit link (as here) it can be approximate 
using approx="diggle" or approx="mculloch". These are much faster, and 
the latter two especially can be very accurate. However, if you try to 
use these approximations on your model MCMCglmm will tell you they are 
not implemented for this distribution.? This isn't true, and I will put 
a new version on CRAN ASAP that allows you to use these approximations. 
I can also send you a version in the mean time if you let me know your OS.

Cheers,

Jarrod
On 09/02/2018 20:26, jonnations wrote: