I fitted a zero inflated poisson model using gam() from the mgcv package
ziplss.fit.mixed <- gam(
list(
n.ind ~ as.factor(data.type) + s(year) +s(enz,bs="re") + s(clc.3,bs="re") + te(lon, lat),
~ as.factor(data.type) + s(year) + s(enz,bs="re") + s(clc.3,bs="re") + te(lon, lat)),
family=ziplss(),
data = dat,
control = gam.control(keepData = TRUE)
)
Every time I try to do predictions I get the following message
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
I even tried to predict using the data I used for the fit. It gives the same error
predict.gam(ziplss.fit.mixed, newdata = ziplss.fit.mixed$data, newdata.guaranteed = TRUE)
If I change back to a regular poisson gam with the same formula then it works.
Any idea why the ziplss option triggers the error ?
Thanks for your help