-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Hi,
I am using ENMEval with my case study, where basically I am running several models for different species.
I am testing different subset of environmental predictors, within a loop where also model's tuning is performed.
So far, I used this combination of tuned arguments:
tune.args <- list(fc = c("L","LQ","LQH"), rm = c(0.5, seq(1, 5, by = 1), 7.5, 10))
Now, I was testing also different features, specifically the hinge one:
tune.args <- list(fc = c("L","LQ","H", "LQH"), rm = c(0.5, seq(1, 5, by = 1), 7.5, 10))
When using these tuned arguments,within my loop, I got the error:
> for (i in seq_along(subset_final_bgbias_unique)) {
+ cat("/n➡️ Running subset", i, "of", n_subsets, ".../n")
+
+ vars_subset <- subset_final_bgbias_unique[[i]]
+ gc()
+ env_subset <- terra::subset(envs_ca_set_eros, vars_subset)
+ gc()
+ eval_result <- tryCatch({
+ ENMevaluate(
+ occs = occs_eros[,1:2],
+ envs = env_subset,
+ bg = bg_bias[,1:2],
+ algorithm = "maxnet",
+ tune.args = tune.args,
+ partitions = "block", # check "randomkfold", "checkerboard2", ecc,
+ parallel = TRUE,
+ numCores = 14
+ )
+ }, error = function(e) {
+ cat("❌ Error in subset", i, ":", conditionMessage(e), "/n")
+ return(NULL)
+ })
+ if (!is.null(eval_result)) {
+ results_list_bias[[names(subset_final_bgbias_unique)[i]]] <- eval_result #check subset list
+ gc()
+
+ # Estrai la miglior combinazione per questo subset
+ res <- eval_result@results
+ best_index <- which.min(res$AICc)
+ best_row <- res[best_index, ]
+ gc()
+ model_summary_bias <- rbind(model_summary_bias, data.frame(
+ Subset = names(subset_final_bgbias_unique)[i], #check subset list
+ AICc = best_row$AICc,
+ AUC_val = best_row$auc.val.avg,
+ AUC_train = best_row$auc.train,
+ CBI_val = best_row$cbi.val.avg,
+ CBI_train = best_row$cbi.train,
+ fc = best_row$fc,
+ rm = best_row$rm,
+ Variables = paste(vars_subset, collapse = ", ")
+ ))
+ }
+ }
/n➡️ Running subset 1 of 18 .../n*** Running initial checks... ***
* Removed 1 occurrence points with NA predictor variable values.
* Removed 4 background points with NA predictor variable values.
* Clamping predictor variable rasters...
* Model evaluations with spatial block (4-fold) cross validation and lat_lon orientation...
*** Running ENMeval v2.0.5 with maxnet from maxnet package v0.1.4 ***
Of 24 total cores using 14...
Running in parallel ...
❌ Error in subset 1 : 4 nodes produced errors; first error: non-conformable arguments
However, for the 2nd and 3rd subsets of predictors the loop succedeed:
➡️ Running subset 2 of 18 .../n*** Running initial checks... ***
* Removed 1 occurrence points with NA predictor variable values.
* Removed 4 background points with NA predictor variable values.
* Clamping predictor variable rasters...
* Model evaluations with spatial block (4-fold) cross validation and lat_lon orientation...
*** Running ENMeval v2.0.5 with maxnet from maxnet package v0.1.4 ***
Of 24 total cores using 16...
Running in parallel ...
Making model prediction rasters...
ENMevaluate completed in 13 minutes 34.6 seconds.
/n➡️ Running subset 3 of 18 .../n*** Running initial checks... ***
* Removed 1 occurrence points with NA predictor variable values.
* Removed 4 background points with NA predictor variable values.
* Clamping predictor variable rasters...
* Model evaluations with spatial block (4-fold) cross validation and lat_lon orientation...
*** Running ENMeval v2.0.5 with maxnet from maxnet package v0.1.4 ***
Of 24 total cores using 16...
Running in parallel ...
Making model prediction rasters...
ENMevaluate completed in 11 minutes 20.1 seconds.
Basically, of the 18 subsets, 9 failed and 9 succeeded.
Thus, I tried with executing the first subset (that produced the error) outside the loop, and removing the parallelization, and I got:
vars_subset <- subset_final_bgbias_unique[[1]]
gc()
env_subset <- terra::subset(envs_ca_set_eros, vars_subset)
eval_result_P2 <- ENMevaluate(
occs = occs_eros[,1:2],
envs = env_subset,
bg = bg_bias[,1:2],
algorithm = "maxent.jar",
tune.args = tune.args,
partitions = "block", # check "randomkfold", "checkerboard2", ecc,
parallel = F # switch ogg
)
*** Running initial checks... ***
* Removed 1 occurrence points with NA predictor variable values.
* Removed 4 background points with NA predictor variable values.
* Clamping predictor variable rasters...
* Model evaluations with spatial block (4-fold) cross validation and lat_lon orientation...
*** Running ENMeval v2.0.5 with maxnet from maxnet package v0.1.4 ***
|=================================== | 34%
Error in mm %*% object$betas: non-conformable arguments
The results were NULL for model with settings fc H, rm 2 for partition 3. These settings will have NA results.
|================================================ | 47%Errore in mm %*% object$betas : non-conformable arguments
I checked that this could be related to the hinge feature (#57 and #52), and so far, I decided to delete the hinge feature from the tuning arguments (and the loop is proceeding without errors), but I was wondering if this issue was fixed by the time. I specify that the ENMEval version is 2.0.5.
Thanks in advance,
Best,
Davide