fitzLab-AL / gdm

R package for Generalized Dissimilarity Modeling
GNU General Public License v3.0
33 stars 11 forks source link

Variable importance assessment (knots error) #34

Open marcelglueck opened 9 months ago

marcelglueck commented 9 months ago

Hi all,

I would like to assess variance importance using gdm.varImp. In the manual, it says that if user supplied knots are provided, the knots argument should be the same as used in model fitting. However, this results in an error:

EXPLO_gdmRes <- gdm(data = EXPLO_spt,
                          geo = FALSE,
                          splines = EXPLO_splines_vector,
                          knots = EXPLO_knots_values)

      # OPERATIONS TO PERFORM IF A MODEL WAS SUCCESSFULLY FIT
      if (!is.null(EXPLO_gdmRes)) {
        # 1. PERFORM PREDICTOR AND MODEL SIGNIFICANCE TESTING
        EXPLO_varImp <- gdm.varImp(
          EXPLO_spt,
          geo = FALSE,
          splines = EXPLO_splines_vector,
          knots = EXPLO_knots_values,
          predSelect = TRUE,
          nPerm = 100,
          pValue = 0.05,
          parallel = TRUE,
          cores = 3,
          sampleSites = 1, # the % of sites to use for purmutation routines; 1 = 100 %
          sampleSitePairs = 1, # the % of site pairs to use for purmutation routines; 1 = 100 %
          outFile = paste0(i, "_", y, "_", s, "_varImp_log.RData")
          )

Creating 100 permuted site-pair tables...
Starting model assessment...
Error in gdm(currSitePair, geo = geo, splines = splines, knots = knots) : 
  When knots are supplied by the user, there should be 6 items in the knots argument, not 141 items.

Obviously, following the construction of permuted site-pair tables, the knots argument is not longer the one used for model fitting. How can I solve this issue?

Thank your for your assistance.

fitzLab-AL commented 5 months ago

Can you please provide a fully reproducible example?

marcelglueck commented 5 months ago

Thanks for your reply. Sure, here is the reproducible example.

gdm_reprex.zip