Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error in mm %*% object$betas : non-conformable arguments with gridSearch and hinge feature even with addSamplesToBg #38

Open
1 task done
geamaro opened this issue Mar 27, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@geamaro
Copy link

geamaro commented Mar 27, 2024

Describe the bug

Dear Friends,

Every time I add hinge feature (alone) to hyper parameters to fine tune a Maxent model with gridSearch, even using addSamplesToBg before, I get Error in mm %*% object$betas : non-conformable arguments message after RM > 4.

I have the same problema with different occurrence data sets from different species, all using 19 Worldclim 2.1 bioclimatic variables together. The intent is to run a complete model for tuning and then reduce variables.

Steps to reproduce the bug

library(SDMtune)

presence.points.coord <- presence.points.model[c("x", "y")]
background.points.coord <- background.points.model[c("x", "y")]

data.model.SWD <- prepareSWD(
  species = my.species, 
  p = presence.points.coord, 
  a = background.points.coord,
  env = predictors.model,
)

data.model.SWD <- addSamplesToBg(data.model.SWD, all = TRUE)
folds <- randomFolds(
  data.model.SWD,
  k = 4,
  only_presence = FALSE,
  seed = 1968
)

maxent.model.base <- train(
  method = "Maxnet", 
  data = data.model.SWD, 
  folds = folds
)

tune.grid <- list(
  reg = seq(1, 5, 0.5),
  fc = c("l", "q", "h", "lq", "qh", "lqh", "lqph")
)

maxent.model.tune <- gridSearch(
  maxent.model.base,
  hypers = tune.grid,
  metric = "tss",
  # test = val.data.SWD
)

Session information

> sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.7.10

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Boa_Vista
tzcode source: internal

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

other attached packages:
 [1] MASS_7.3-60.0.1          grinnell_0.0.22          rnaturalearthhires_1.0.0
 [4] flexsdm_1.3.4            htmlwidgets_1.6.4        datazoom.amazonia_1.1.0 
 [7] bdc_1.1.4                SDMtune_1.3.1            raster_3.6-26           
[10] sp_2.1-3                 flextable_0.9.5          gtsummary_1.7.2         
[13] officer_0.6.5            tidyr_1.3.1              data.table_1.15.2       
[16] kableExtra_1.4.0         formattable_0.2.1        gt_0.10.1               
[19] ggpubr_0.6.0             countrycode_1.6.0        geobr_1.8.2             
[22] scales_1.3.0             viridis_0.6.5            viridisLite_0.4.2       
[25] ENMeval_2.0.4            magrittr_2.0.3           pROC_1.18.5             
[28] usdm_2.1-7               RColorBrewer_1.1-3       corrplot_0.92           
[31] dplyr_1.1.4              geodata_0.5-9            terra_1.7-71            
[34] CoordinateCleaner_3.0.1  maps_3.4.2               tmap_3.3-4              
[37] sf_1.0-16                ggplot2_3.5.0            pacman_0.5.1            

loaded via a namespace (and not attached):
  [1] splines_4.3.3           later_1.3.2             rnaturalearth_1.0.1    
  [4] fields_15.2             tibble_3.2.1            cellranger_1.1.0       
  [7] XML_3.99-0.16.1         lifecycle_1.0.4         rstatix_0.7.2          
 [10] rprojroot_2.0.4         doParallel_1.0.17       processx_3.8.4         
 [13] lattice_0.22-6          crosstalk_1.2.1         exactextractr_0.10.0   
 [16] backports_1.4.1         rmarkdown_2.26          remotes_2.5.0          
 [19] httpuv_1.6.15           spam_2.10-0             zip_2.3.1              
 [22] askpass_1.2.0           pkgbuild_1.4.4          DBI_1.2.2              
 [25] abind_1.4-5             purrr_1.0.2             nnet_7.3-19            
 [28] openxlsx2_1.5           gdtools_0.3.7           gbm_2.1.9              
 [31] crul_1.4.0              ellipse_0.5.0           units_0.8-5            
 [34] svglite_2.1.3           codetools_0.2-19        dismo_1.3-14           
 [37] RApiSerialize_0.1.2     DT_0.32                 xml2_1.3.6             
 [40] shape_1.4.6.1           tidyselect_1.2.1        farver_2.1.1           
 [43] httpcode_0.3.0          base64enc_0.1-3         broom.helpers_1.14.0   
 [46] jsonlite_1.8.8          rgnparser_0.3.0         e1071_1.7-14           
 [49] survival_3.5-8          iterators_1.0.14        systemfonts_1.0.6      
 [52] foreach_1.5.2           tools_4.3.3             ragg_1.3.0             
 [55] Rcpp_1.0.12             glue_1.7.0              contentid_0.0.18       
 [58] gridExtra_2.3           here_1.0.1              xfun_0.43              
 [61] mgcv_1.9-1              withr_3.0.0             fastmap_1.1.1          
 [64] fansi_1.0.6             openssl_2.1.1           callr_3.7.6            
 [67] digest_0.6.35           R6_2.5.1                mime_0.12              
 [70] wk_0.9.1                textshaping_0.3.7       colorspace_2.1-0       
 [73] maxnet_0.1.4            dichromat_2.0-0.1       utf8_1.2.4             
 [76] generics_0.1.3          fontLiberation_0.1.0    class_7.3-22           
 [79] httr_1.4.7              tmaptools_3.1-1         whisker_0.4.1          
 [82] pkgconfig_2.0.3         gtable_0.3.4            sys_3.4.2              
 [85] htmltools_0.5.8         fontBitstreamVera_0.1.1 carData_3.0-5          
 [88] dotCall64_1.1-1         spThin_0.2.0            png_0.1-8              
 [91] knitr_1.45              rstudioapi_0.16.0       tzdb_0.4.0             
 [94] geosphere_1.5-18        rgbif_3.7.9             uuid_1.2-0             
 [97] nlme_3.1-164            curl_5.2.1              cachem_1.0.8           
[100] proxy_0.4-27            stringr_1.5.1           KernSmooth_2.23-22     
[103] parallel_4.3.3          desc_1.4.3              s2_1.1.6               
[106] leafsync_0.1.0          pillar_1.9.0            grid_4.3.3             
[109] vctrs_0.6.5             promises_1.2.1          randomForest_4.7-1.1   
[112] stringfish_0.16.0       car_3.1-2               dbplyr_2.5.0           
[115] xtable_1.8-4            evaluate_0.23           oai_0.4.0              
[118] readr_2.1.5             cli_3.6.2               compiler_4.3.3         
[121] rlang_1.1.3             crayon_1.5.2            ggsignif_0.6.4         
[124] labeling_0.4.3          classInt_0.4-10         ps_1.7.6               
[127] plyr_1.8.9              fs_1.6.3                stringi_1.8.3          
[130] stars_0.6-4             taxadb_0.2.1            munsell_0.5.0          
[133] lazyeval_0.2.2          leaflet_2.2.2           glmnet_4.1-8           
[136] fontquiver_0.2.1        Matrix_1.6-5            hms_1.1.3              
[139] patchwork_1.2.0         leafem_0.2.3            gfonts_0.2.0           
[142] shiny_1.8.1             qs_0.26.1               kernlab_0.9-32         
[145] memoise_2.0.1           broom_1.0.5             RcppParallel_5.1.7     
[148] lwgeom_0.2-14           readxl_1.4.3            ape_5.7-1

Additional information

Bactrocera dorsalis Filtered Clean Occ 2024-03-27.xlsx

Occurrences used to model.

Reproducible example

  • I have done my best to provide the steps to reproduce the bug
@geamaro geamaro added the bug Something isn't working label Mar 27, 2024
@bappa10085
Copy link

I am also facing the same issue. Any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants