试图获得预测器"地质学"作为一个因素......它表示它处于栅格级别,rasterstack和数据帧中,所以不确定为什么它不会起作用。
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
非常感谢任何帮助。