Dear mixed modelers,

Can anyone confirm that there is no way to make predictions from a gamm4 model including the random effects?
I assume it is the same issue as with mgcv:gamm as discussed here 
http://r.789695.n4.nabble.com/mgcv-gamm-predict-to-reflect-random-s-effects-td3622738.html

I believe predict.merMod would include the random effects by default, but it doesn’t recognize the variable names given by gamm4.

Here is code in case you want to try something
x <- runif(100)
fac <- sample(1:20,100,replace=TRUE)
eta <- x^2*3 + fac/20; fac <- as.factor(fac)
y <- rpois(100,exp(eta))
dat=data.frame(x=x, fac=fac, eta=eta, y=y)
## fit model and examine it...
bp <- gamm4(y~s(x),family=poisson,random=~(1|fac), data=dat)

pred=predict(bp$gam, newdata=dat, type="response")
pred2=predict(bp$mer, newdata=dat, type="response")
#Error in eval(expr, envir, enclos) : object 'X' not found

Is the best alternative still to use gam?
bp2=gam(y~s(x)+s(fac, bs="re"), method="REML", family=poisson, data=dat)

Thanks,
Mollie

------------------------
Mollie Brooks, PhD
Postdoctoral Researcher, Population Ecology Research Group http://www.popecol.org
Institute of Evolutionary Biology & Environmental Studies, University of Zürich




	[[alternative HTML version deleted]]

