biomodhub / biomod2

BIOMOD is a computer platform for ensemble forecasting of species distributions, enabling the treatment of a range of methodological uncertainties in models and the examination of species-environment relationships.
77 stars 20 forks source link

Help with BIOMOD_4.2-6 - In BIOMOD_Modeling run, some models don't work. #479

Open gsatta opened 4 days ago

gsatta commented 4 days ago

Context and question Hello everyone, for a few days, when I run the BIOMOD_Modeling() function, the following error appears: in some models:

Error in x$formula : oggetto di tipo 'closure' non suddivisibile

What does it mean? what exactly is the option that can cause this problem?

Thank You

Here is the code and the information:

**Code used:**
# Load the train and test points
myResp_train <- vect("./INPUT/VECTOR/train_data.gpkg")
myResp_test <- vect("./INPUT/VECTOR/test_data.gpkg")

# Load the environmental raster  at 50 m of spatial resolution
myExpl_0 <- rast("./INPUT/RASTER/environmental_50m.tiff")

myExpl <- subset(myExpl_0, c("BIO03", "green",
                             "BIO06", "fla","wo",
                             'roads', "soc",
                             "rivers"))

n_PA_3 <- length(myResp_train) 
n_PA_3 <- length(myResp_train) 

# Format Data with pseudo - absences: random method
myBiomodData <- BIOMOD_FormatingData(expl.var = myExpl,
                                     resp.var = myResp_train,
                                     eval.resp.var = myResp_test,
                                     resp.name = "Phytophthora",
                                     PA.nb.rep = 20,
                                     PA.nb.absences =  c(rep(n_PA_3, 10), rep(1000, 10)),
                                     PA.strategy = 'random',
                                     filter.raster = TRUE,
                                     dir.name = getwd(),
                                     seed.val = 1234)
myBiomodData

# plot(myBiomodData)

# Definisci i nomi delle colonne disponibili all'interno di bm.format@PA.table
PA_used <- colnames(myBiomodData@PA.table)

# Definisci i vettori per ciascun modello che indicano quali colonne di pseudo-assenza utilizzare
{
  PA1_10 <- paste0("PA", 1:10)
  PA11_20 <- paste0("PA", 11:20)

  # CTA <- PA1_10
  FDA <- PA1_10
  RF <- PA1_10
  RFd <- PA1_10
  XGBOOST <- PA1_10
  GLM <- PA11_20
  GAM <- PA11_20
  MAXENT <- PA11_20
  MAXNET <- PA11_20
  GBM <- PA11_20
}

# Costruisci la lista models.pa contenente questi vettori per ciascun modello
models.pa <- list(FDA = FDA, GBM = GBM, RF = RF, RFd = RFd, XGBOOST = XGBOOST, 
                  GLM = GLM, GAM = GAM, MAXENT = MAXENT)

################################################################################

#                             Run Single Models

################################################################################

allModels  <- c("FDA", "GAM", "GBM", "GLM", "MAXENT", "RF", "RFd", "XGBOOST")

user.rf <- list('_allData_allRun' = list(type = 'classification', importance = TRUE, 
                                         nodesize = 10, oob.prox = T, ntree = 250, 
                                         mtry = 2, maxnodes = 5))

user.maxent <- list('_allData_allRun' = list(visible = TRUE,
                                             beta_threshold = 0))

user.XGBOOST <- list('_allData_allRun' = list(objective = "binary:logistic",
                                              params =list(max_depth = 5, eta = 0.2, gamma = 1 ),
                                              nrounds = 20, subsample = 0.5))

form.GLM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
                           expl.var = head(myBiomodData@data.env.var),
                           type = 's_smoother',
                           interaction.level = 0)

user.GLM <- list('_allData_allRun' = list(formula = form.GLM))

form.GAM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
                           expl.var = head(myBiomodData@data.env.var),
                           type = 's_smoother',
                           interaction.level = 0)

user.GAM <- list('_allData_allRun' = list(algo = 'GAM_mgcv'))

# user.GAM <- list('_allData_allRun' = list(formula = form.GAM))

user.val <- list(RF.binary.randomForest.randomForest = user.rf,
                 MAXENT.binary.MAXENT.MAXENT = user.maxent,
                 XGBOOST.binary.xgboost.xgboost = user.XGBOOST,
                 GLM.binary.stats.glm= user.GLM,
                 GAM.binary.mgcv.gam= user.GAM)

# bigboss parameters
myBiomodOption <- bm_ModelingOptions(data.type = 'binary',
                            models = allModels,
                            strategy = "user.defined",
                            user.base = 'bigboss',
                            user.val = user.val)

############################# Run the single models ############################
# single models
myBiomodModelOut <- BIOMOD_Modeling(
  bm.format = myBiomodData,
  OPT.user = myBiomodOption,
  modeling.id = as.character(format(Sys.time(), "%Y%m%d_%H%M_%S")),
  models = allModels,
  models.pa = models.pa,
  CV.strategy = 'kfold',
  CV.nb.rep = 1,
  CV.k = 5,
  var.import = 3,
  metric.eval = c("ROC", "TSS", "KAPPA", "ACCURACY", "BIAS", "POD", "FAR",
                  "SR", "BOYCE"),
  seed.val = 123,
  do.progress = TRUE,
)

Session info

> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=Italian_Italy.utf8  LC_CTYPE=Italian_Italy.utf8   
[3] LC_MONETARY=Italian_Italy.utf8 LC_NUMERIC=C                  
[5] LC_TIME=Italian_Italy.utf8    

time zone: Europe/Rome
tzcode source: internal

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets 
[7] methods   base     

other attached packages:
 [1] xgboost_1.7.7.1      randomForest_4.7-1.1 maxnet_0.1.4        
 [4] earth_5.3.3          plotmo_3.6.3         plotrix_3.8-4       
 [7] Formula_1.2-5        gbm_2.2.2            mgcv_1.9-0          
[10] nlme_3.1-163         gam_1.22-3           foreach_1.5.2       
[13] mda_0.5-4            class_7.3-22         rpart_4.1.21        
[16] nnet_7.3-19          biomod2_4.2-6        terra_1.7-71        
[19] sf_1.0-16            readr_2.1.5          devtools_2.4.5      
[22] usethis_2.2.3       

loaded via a namespace (and not attached):
 [1] DBI_1.2.3              pROC_1.18.5           
 [3] remotes_2.4.2.1        rlang_1.1.3           
 [5] magrittr_2.0.3         e1071_1.7-14          
 [7] compiler_4.3.2         callr_3.7.6           
 [9] vctrs_0.6.5            reshape2_1.4.4        
[11] stringr_1.5.1          profvis_0.3.8         
[13] pkgconfig_2.0.3        fastmap_1.1.1         
[15] ellipsis_0.3.2         utf8_1.2.4            
[17] promises_1.2.1         sessioninfo_1.2.2     
[19] tzdb_0.4.0             ps_1.7.7              
[21] purrr_1.0.2            cachem_1.0.8          
[23] jsonlite_1.8.8         PresenceAbsence_1.1.11
[25] later_1.3.2            reshape_0.8.9         
[27] R6_2.5.1               stringi_1.8.3         
[29] pkgload_1.4.0          Rcpp_1.0.12           
[31] iterators_1.0.14       httpuv_1.6.14         
[33] Matrix_1.6-1.1         tidyselect_1.2.1      
[35] rstudioapi_0.16.0      abind_1.4-5           
[37] codetools_0.2-19       miniUI_0.1.1.1        
[39] curl_5.2.1             processx_3.8.4        
[41] pkgbuild_1.4.4         lattice_0.22-5        
[43] tibble_3.2.1           intervals_0.15.4      
[45] plyr_1.8.9             shiny_1.8.1.1         
[47] withr_3.0.0            desc_1.4.3            
[49] survival_3.7-0         units_0.8-5           
[51] proxy_0.4-27           urlchecker_1.0.1      
[53] pillar_1.9.0           KernSmooth_2.23-22    
[55] generics_0.1.3         sp_2.1-3              
[57] hms_1.1.3              ggplot2_3.5.1         
[59] munsell_0.5.1          scales_1.3.0          
[61] xtable_1.8-4           glue_1.7.0            
[63] tools_4.3.2            data.table_1.15.4     
[65] fs_1.6.3               grid_4.3.2            
[67] colorspace_2.1-0       raster_3.6-26         
[69] cli_3.6.2              fansi_1.0.6           
[71] dplyr_1.1.4            gtable_0.3.5          
[73] digest_0.6.34          classInt_0.4-10       
[75] htmlwidgets_1.6.4      memoise_2.0.1         
[77] htmltools_0.5.7        lifecycle_1.0.4       
[79] dismo_1.3-14           mime_0.12     

Information about myBiomodData

> myBiomodData

-=-=-=-=-=-=-=-=-=-=-=-= BIOMOD.formated.data -=-=-=-=-=-=-=-=-=-=-=-=

dir.name =  
D:/DOTTORATO/PROGETTI/PAULLILATINO/PAPER_2/SDM_R_PROJECT/SDM_biomod2_50m

sp.name =  Phytophthora

     31 presences,  0 true absences and  9233 
undefined points in dataset

     8 explanatory variables

     BIO03           green             BIO06            fla         
 Min.   :36.78   Min.   :0.07764   Min.   :3.807   Min.   :   99.6  
 1st Qu.:37.85   1st Qu.:0.09675   1st Qu.:4.932   1st Qu.: 1068.7  
 Median :38.28   Median :0.10375   Median :5.179   Median : 1970.9  
 Mean   :38.43   Mean   :0.10651   Mean   :5.092   Mean   : 3767.1  
 3rd Qu.:38.78   3rd Qu.:0.11343   3rd Qu.:5.282   3rd Qu.: 3793.7  
 Max.   :41.84   Max.   :0.18920   Max.   :5.776   Max.   :99479.9  
       wo             roads               soc       
 Min.   :0.0000   Min.   :  0.3286   Min.   : 0.00  
 1st Qu.:1.0000   1st Qu.: 46.4330   1st Qu.:21.25  
 Median :1.0000   Median :101.5691   Median :22.85  
 Mean   :0.8448   Mean   :132.1504   Mean   :23.07  
 3rd Qu.:1.0000   3rd Qu.:185.7224   3rd Qu.:24.89  
 Max.   :1.0000   Max.   :907.2587   Max.   :32.68  
     rivers        
 Min.   :   0.127  
 1st Qu.: 114.346  
 Median : 250.679  
 Mean   : 322.091  
 3rd Qu.: 458.322  
 Max.   :1608.111  

Evaluation data :

     14 presences,  14 true absences and  0 undefined points in dataset

     BIO03           green             BIO06            fla         
 Min.   :37.05   Min.   :0.08691   Min.   :4.540   Min.   :  259.8  
 1st Qu.:37.81   1st Qu.:0.09492   1st Qu.:5.096   1st Qu.:  750.4  
 Median :38.32   Median :0.10230   Median :5.216   Median : 1467.9  
 Mean   :38.47   Mean   :0.10441   Mean   :5.192   Mean   : 2066.2  
 3rd Qu.:38.73   3rd Qu.:0.11226   3rd Qu.:5.354   3rd Qu.: 2503.7  
 Max.   :41.01   Max.   :0.13800   Max.   :5.668   Max.   :10850.0  
       wo        roads             soc            rivers      
 Min.   :1   Min.   : 13.30   Min.   :17.99   Min.   : 28.98  
 1st Qu.:1   1st Qu.: 44.14   1st Qu.:20.93   1st Qu.:101.76  
 Median :1   Median : 91.11   Median :22.26   Median :270.17  
 Mean   :1   Mean   :111.03   Mean   :22.66   Mean   :309.61  
 3rd Qu.:1   3rd Qu.:151.07   3rd Qu.:24.33   3rd Qu.:506.55  
 Max.   :1   Max.   :432.51   Max.   :30.30   Max.   :745.11  

 20 Pseudo Absences dataset available ( 
PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13, PA14, PA15, PA16, PA17, PA18, PA19, PA20 
) with  
31 (PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10), 1000 (PA11, PA12, PA13, PA14, PA15, PA16, PA17, PA18, PA19, PA20) 
pseudo absences

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> summary(myBiomodData)
       dataset run   PA Presences True_Absences Pseudo_Absences
1      initial  NA <NA>        31             0               0
2   evaluation  NA <NA>        14            14               0
3  calibration  NA  PA1        31             0              31
4  calibration  NA  PA2        31             0              31
5  calibration  NA  PA3        31             0              31
6  calibration  NA  PA4        31             0              31
7  calibration  NA  PA5        31             0              31
8  calibration  NA  PA6        31             0              31
9  calibration  NA  PA7        31             0              31
10 calibration  NA  PA8        31             0              31
11 calibration  NA  PA9        31             0              31
12 calibration  NA PA10        31             0              31
13 calibration  NA PA11        31             0            1000
14 calibration  NA PA12        31             0            1000
15 calibration  NA PA13        31             0            1000
16 calibration  NA PA14        31             0            1000
17 calibration  NA PA15        31             0            1000
18 calibration  NA PA16        31             0            1000
19 calibration  NA PA17        31             0            1000
20 calibration  NA PA18        31             0            1000
21 calibration  NA PA19        31             0            1000
22 calibration  NA PA20        31             0            1000
   Undefined
1       9233
2          0
3         NA
4         NA
5         NA
6         NA
7         NA
8         NA
9         NA
10        NA
11        NA
12        NA
13        NA
14        NA
15        NA
16        NA
17        NA
18        NA
19        NA
20        NA
21        NA
22        NA
HeleneBlt commented 3 days ago

Hi Gabriele,

Glad to see that you use the new features of biomod2 4.2-6 as RFd ! 🏆

When you run bm_ModelingOptions, you didn't give myBiomodData. Normally, you have this warning :

Dans .local(strategy, user.val, user.base, tuning.fun, bm.format,  :
  No bm.format provided. No definition of formula through bm_MakeFormula.

So after, FDA and GBM have failed because they don't have a normal formula, resulting in the error Error in x$formula : oggetto di tipo 'closure' non suddivisibile.

You just need to add bm.format = myBiomodData in bm_ModelingOptions or you can give a simple formula to FDA and GBM as you do for GAM or GLM.

I'll see if I can change the code to avoid this problem in the future :wink:

Hope it helps !

Hélène

gsatta commented 3 days ago

Hi Hélène thank you for your quickly answer.

After your suggestion, I changed some parts in the code and now I have this new warmings when I run bm_ModelingOptions():

warnings:

-=-=-=-=-=-=-=-=-= Build Modeling Options -=-=-=-=-=-=-=-=-=

    >  FDA options (datatype: binary , package: mda , function: fda )...
    >  GAM options (datatype: binary , package: mgcv , function: gam )...
    >  GBM options (datatype: binary , package: gbm , function: gbm )...
    >  GLM options (datatype: binary , package: stats , function: glm )...
    >  MAXENT options (datatype: binary , package: MAXENT , function: MAXENT )...
    >  RF options (datatype: binary , package: randomForest , function: randomForest )...
    >  RFd options (datatype: binary , package: randomForest , function: randomForest )...
    >  XGBOOST options (datatype: binary , package: xgboost , function: xgboost )...

-=-=-=-=-=-=-=-=-=-=-=-=-= Done -=-=-=-=-=-=-=-=-=-=-=-=-=
Messaggi di avvertimento:
1: In .bm_ModelingOptions.check.args(data.type = data.type, models = models,  :
  Only one GAM model can be activated. 'GAM.mgcv.gam' has been set (other available : 'GAM.gam.gam' or 'GAM.mgcv.bam')
2: In .local(strategy, user.val, user.base, tuning.fun, bm.format,  :
  No bm.format provided. No definition of formula through bm_MakeFormula.
3: In .local(strategy, user.val, user.base, tuning.fun, bm.format,  :
  No bm.format provided. No definition of formula through bm_MakeFormula.
4: In .local(strategy, user.val, user.base, tuning.fun, bm.format,  :
  No bm.format provided. No definition of formula through bm_MakeFormula.
5: In .local(strategy, user.val, user.base, tuning.fun, bm.format,  :
  No bm.format provided. No definition of formula through bm_MakeFormula.

Code used:

allModels  <- c("FDA", "GAM", "GBM", "GLM", "MAXENT", "RF", "RFd", "XGBOOST")

user.rf <- list('_allData_allRun' = list(type = 'classification', importance = TRUE, 
                nodesize = 10, oob.prox = TRUE, ntree = 250, 
                mtry = 2, maxnodes = 5))
user.maxent <- list('_allData_allRun' = list(visible = TRUE, beta_threshold = 0))

user.XGBOOST <- list('_allData_allRun' = list(objective = "binary:logistic",
                     params = list(max_depth = 5, eta = 0.2, gamma = 1),
                     nrounds = 20, subsample = 0.5))

form.GLM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
                           expl.var = head(myBiomodData@data.env.var),
                           type = 's_smoother',
                           interaction.level = 0)
user.GLM <- list('_allData_allRun' = list(formula = form.GLM))

form.GAM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
                           expl.var = head(myBiomodData@data.env.var),
                           type = 's_smoother',
                           interaction.level = 0)
user.GAM <- list('_allData_allRun' = list(algo = 'GAM.mgcv.gam'))

form.GBM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
                           expl.var = head(myBiomodData@data.env.var),
                           type = 's_smoother',
                           interaction.level = 0)
user.GBM <- list('_allData_allRun' = list(formula = form.GBM))

form.FDA <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
                           expl.var = head(myBiomodData@data.env.var),
                           type = 's_smoother',
                           interaction.level = 0)
user.FDA <- list('_allData_allRun' = list(formula = form.FDA))

user.val <- list(RF.binary.randomForest.randomForest = user.rf,
                 MAXENT.binary.MAXENT.MAXENT = user.maxent,
                 XGBOOST.binary.xgboost.xgboost = user.XGBOOST,
                 GLM.binary.stats.glm= user.GLM,
                 GAM.binary.mgcv.gam= user.GAM,
                 GBM.binary.gbm.gbm = user.GBM,
                 FDA.binary.mda.fda = user.FDA)

# starting from bigboss parameters
myBiomodOption <- bm_ModelingOptions(data.type = 'binary',
                                     models = allModels,
                                     strategy = "user.defined",
                                     user.base = 'bigboss',
                                     user.val = user.val)

How can I solve these warnings?

Also I would like to ask, if possible , a little clarification regarding the meaning of _allData_allRun. What exactly does it mean? Does it refer to all data and all model runs?

Thank you very much !

HeleneBlt commented 3 days ago

Hello again,

In this case, you didn't specify bm.format so bm_ModelingOptions cannot create a formula: the warnings appear. However, you should have add a formula for all the algorithms that need one (for example, RF can deal without it). So, you can ignore the warnings and it should run without problems.

For _allData_allRun, I admit it can be confusing at time 😬 _allData_allRun refers to all your data points without any split for the pseudo-absences or the cross-validation.

If you want to attribute your options for all the models (e.g. PA1_RUN1, PA1_RUN2, ... ), you can use "for_all_datasets". user.FDA <- list('for_all_datatsets' = list(formula = form.FDA)) However, in this case, you must add bm.format = myBiomodData in bm_ModelingOptions !

Don't hesitate if it's still not clear !

Hélène

gsatta commented 3 days ago

Thank you Hélène !

I just did what you suggested, adding the parameter bm.format = myBiomodData in the bm_ModelingOptions() function and changed _allData_allRun to for_all_datatsets.

Omitting the warnings, the following error appears:

Error:

-=-=-=-=-=-=-= Build Modeling Options -=-=-=-=-=-=-=

    >  FDA options (datatype: binary , package: mda , function: fda )...
    >  GAM options (datatype: binary , package: mgcv , function: gam )...
    >  GBM options (datatype: binary , package: gbm , function: gbm )...
    >  GLM options (datatype: binary , package: stats , function: glm )...
    >  MAXENT options (datatype: binary , package: MAXENT , function: MAXENT )...
    >  RF options (datatype: binary , package: randomForest , function: randomForest )...
    >  RFd options (datatype: binary , package: randomForest , function: randomForest )...
    >  XGBOOST options (datatype: binary , package: xgboost , function: xgboost )...Errore in { : task 1 failed - "task 1 failed - "
names(user.val) must be '_allData_allRun', '_PA1_allRun', '_PA2_allRun', '_PA3_allRun', '_PA4_allRun', '_PA5_allRun', '_PA6_allRun', '_PA7_allRun', '_PA8_allRun', '_PA9_allRun', '_PA10_allRun', '_PA11_allRun', '_PA12_allRun', '_PA13_allRun', '_PA14_allRun', '_PA15_allRun', '_PA16_allRun', '_PA17_allRun', '_PA18_allRun', '_PA19_allRun' or '_PA20_allRun""
In aggiunta: Messaggio di avvertimento:
In .bm_ModelingOptions.check.args(data.type = data.type, models = models,  :
  Only one GAM model can be activated. 'GAM.mgcv.gam' has been set (other available : 'GAM.gam.gam' or 'GAM.mgcv.bam')

Code:

> allModels  <- c("FDA", "GAM", "GBM", "GLM", "MAXENT", "RF", "RFd", "XGBOOST")
> user.rf <- list('for_all_datatsets' = list(type = 'classification', importance = TRUE, 
+                 nodesize = 10, oob.prox = TRUE, ntree = 250, 
+                 mtry = 2, maxnodes = 5))
> user.maxent <- list('for_all_datatsets' = list(visible = TRUE, beta_threshold = 0))
> user.XGBOOST <- list('for_all_datatsets' = list(objective = "binary:logistic",
+                      params = list(max_depth = 5, eta = 0.2, gamma = 1),
+                      nrounds = 20, subsample = 0.5))
> form.GLM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+                            expl.var = head(myBiomodData@data.env.var),
+                            type = 's_smoother',
+                            interaction.level = 0)
> user.GLM <- list('for_all_datatsets' = list(formula = form.GLM))
> form.GAM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+                            expl.var = head(myBiomodData@data.env.var),
+                            type = 's_smoother',
+                            interaction.level = 0)
> user.GAM <- list('for_all_datatsets' = list(algo = 'GAM.mgcv.gam'))
> form.GBM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+                            expl.var = head(myBiomodData@data.env.var),
+                            type = 's_smoother',
+                            interaction.level = 0)
> user.GBM <- list('for_all_datatsets' = list(formula = form.GBM))
> form.FDA <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+                            expl.var = head(myBiomodData@data.env.var),
+                            type = 's_smoother',
+                            interaction.level = 0)
> user.FDA <- list('for_all_datatsets' = list(formula = form.FDA))
> user.val <- list(RF.binary.randomForest.randomForest = user.rf,
+                  MAXENT.binary.MAXENT.MAXENT = user.maxent,
+                  XGBOOST.binary.xgboost.xgboost = user.XGBOOST,
+                  GLM.binary.stats.glm= user.GLM,
+                  GAM.binary.mgcv.gam= user.GAM,
+                  GBM.binary.gbm.gbm = user.GBM,
+                  FDA.binary.mda.fda = user.FDA)
> # starting from bigboss parameters
> myBiomodOption <- bm_ModelingOptions(data.type = 'binary',
+                                      models = allModels,
+                                      strategy = "user.defined",
+                                      user.base = 'bigboss',
+                                      user.val = user.val,
+                                      bm.format = myBiomodData)
HeleneBlt commented 3 days ago

Oh I'm sorry: I'm mistyped! 😅 It's "for_all_datasets" and not "for_all_datatsets" !!

However, you're right: I need to change the error message and add "for_all_datasets" ! I will push a commit soon !

Hélène

gsatta commented 3 days ago

Thank you again Hélène !

Now everything seems to be running except the GBM model. In fact, this error appears: Error:

=-=-=--=-=-=- Phytophthora_PA11_RUN2_GBM 
CV: 1 
CV: 2 
CV: 3 
Error in `[.data.frame`(data, flag, model$var.names, drop = FALSE) : 
  selezionate colonne non definite

*** Error in  GBM , calibration failed
*** inherits(g.pred,'try-error')
   ! Note :  Phytophthora_PA11_RUN1_GBM failed!

Why is it selecting undefined columns?

Thank you again !

HeleneBlt commented 2 days ago

It's a stranger error. It seems GBM doesn't allow several CV folds if you use a quadratic or s_smoother formula. You can simplify your formula :

form.GBM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
                           expl.var = head(myBiomodData@data.env.var),
                           type = 'simple',
                           interaction.level = 0)

Or you can deactivate the cv fold inside GBM :

user.GBM <- list('for_all_datasets' = list(formula = form.GBM, cv.folds = 0))

I'll have to investigate more. I don't remember seeing this issue before. In the meantime, I hope these solutions work for you.

Hélène