Trying to get the predictor "geology" to act as a factor...it says it is at the raster level, in the rasterstack, and in the dataframe, so not sure why it won't work.
is.factor(geology)
# [1] TRUE
is.factor(tstack$geology)
# [1] TRUE
is.factor(mbdata$geology)
# [1] TRUE
library(gam)
mel.gam.forw <- gam(mel.bur ~ s(aus35.s,3) + s(firefreq.s,4) + geology +
s(slope.s,2) + s(wetness.s,3), family = binomial (link="logit"),
data = mbdata)
mb.gam.f.pred <- predict(tstack, mel.gam.forw, type="response")
Error in `contrasts<-`(`*tmp*`, value = contrasts.arg[[nn]]) :
contrasts apply only to factors
In addition: Warning message:
In model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) :
variable 'geology' is not a factor
Any help would be much appreciated.