EvolEcolGroup / tidysdm

R package to fit species distribution models (SDMs) using the 'tidymodels' framework
https://evolecolgroup.github.io/tidysdm/
GNU Affero General Public License v3.0
15 stars 5 forks source link

Categorical predictors not supported? #44

Open djensing opened 2 months ago

djensing commented 2 months ago

Hello, I've run into an issue with unexpected behaviour when using categorical predictor layers (decimal place values for generating variable response curves, etc.), the levels of which are coded with numbers. Things fail if I coerce the raster to a factor... I'm not surprised necessarily that it treats my categorical input layer as a numeric layer (which generates the weird response curves, of course), but as far as I can tell, categorical predictors (e.g. land cover types) are not mentioned in the tidysdm vignettes (searches for 'factor', 'categor', 'ordinal' returned 0 hits) . tidymodels has some discussion of how categorical predictors are handled in the 'Dummies' vignette, but it's not immediately clear to me how this would translate to tidysdm. Mixed predictor variable types are a feature of random forests, maxent etc. that make them appealing options for niche modeling, so are categorical predictors supported in tidysdm, and if so, how do I ensure they're being treated correctly by the models? Thanks for the great package and vignettes!

dramanica commented 1 month ago

Hi @djensing, My apologies, I thought I had already responded to this. Would you be able to please provide a simple example of what you are trying to do that shows why using dummy variables fails? I can then have a go at fixing it.