Skip to content
Prev 5924 / 7420 Next

Error in run GAM (Biomod 2)

I don't think the number of presences is the problem. 
"A term has fewer unique covariate combinations than specified maximum degrees of freedom"
One of your covariates has a small number of unique values. 
lapply(your_data_frame, function(x)length(unique(x)))
will print out the number of unique values in each variable. Values < 30 could be problematic -- the docs are a bit ambiguous on the default values of k, the maximum degrees of freedom for a smooth term. Another approach to diagnose the problem is to set k to a low value, like 5, and see if that makes the problem go away. I'm not familiar with biomod2, but I think doing something like
MO <- BIOMOD_ModelingOptions(GAM  = list(k = 5))
BIOMOD_Modeling( ..., models.options = MO, ...) 

should do it. Note that setting k to a low value causes other problems, I would use mcgv::gam.check() to ensure k is large enough, but I don't know how to do that with biomod2. 

hth