sylvainschmitt / SSDM

Stacked Species Distribution Modelling R package
Other
41 stars 17 forks source link

Issue applying GAM's models to binomial covariate #103

Closed tatopm91 closed 4 years ago

tatopm91 commented 4 years ago

Hello,

I'm having some trouble applying GAM algorithm with a binomial environmental layer. Giving me the error:

"Error in smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) : A term has fewer unique covariate combinations than specified maximum degrees of freedom"

I have been trying to fix it but it seems is these layers I'm talking about that produce the issue. RF, GLM, MAXENT algorithms work perfectly with it but GAM not... Do you know what could have happened? I attach you the layers I'm talking about

Binomial layers.zip

Thank you very much in advance for your time and help.

PS: this is the code I was using for the SDMs, where the bio_crop_GORG/PAR are biogeoclimatic stacked layers.

GAM2 <- modelling('GAM', spa, bio_crop_GORG, Xcol = 'long', Ycol = 'lat', cv.param = c(0.7, 1))

lukasbaumbach commented 4 years ago

This doesn't sound like an issue related to the SSDM package per se. The underlying gam function comes from the mgcv package, which I would recommend checking. You can supply GAM parameters to the SSDM modelling function by adding gam.args=list(arg1=val1,arg2=val2,...) as an argument. Do I assume correctly from your layers that you only have 2 predictor variables? As far as I know the number of predictors influences the degrees of freedom

tatopm91 commented 4 years ago

Thanks! I will check on the mgcv package as you recommended. About the predictors there would be 4 (temperature, bathymetry, Dis.Oxygen and this biogenic substrate I was talking about)