fitzLab-AL / gdm

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

Error when running gdm.varImp() #23

Closed fsdias closed 2 years ago

fsdias commented 2 years ago

Running gdm.varImp() with the example works as expected

library(gdm)

sppData <- southwest[c(1,2,13,14)]
envTab <- southwest[c(2:ncol(southwest))]
sitePairTab <- formatsitepair(sppData, 2, XColumn="Long", YColumn="Lat",
                              sppColumn="species", siteColumn="site", predData=envTab)

modTest <- gdm.varImp(sitePairTab, geo=T, nPerm=50, parallel=T, cores=10)

However, when I try to run it with only a few covariates, it returns an error:

library(tidyverse)
test<- sitePairTab %>% select(distance,weights,s1.xCoord,s1.yCoord,s2.xCoord,
                              s2.yCoord,s1.awcA,s1.phTotal,s2.awcA,s2.phTotal)

modTest <- gdm.varImp(test, geo=F, nPerm=50, parallel=T, cores=10)

Fitting initial model with all 2 predictors...
Error in matrix(NA, 4, nVars, dimnames = list(c("Model deviance", "Percent deviance explained",  : 
  length of 'dimnames' [2] not equal to array extent

Am I doing something wrong?

fitzLab-AL commented 2 years ago

That was a bug - should be fixed now in latest version of the package. Let me know if you have any other issues.

willright28 commented 2 years ago

I update gdm to version1.5.0-3, but running gdm.varImp still has this issue. I used one predictors: spp_tab <- read.csv("./sppTab.csv") env_tab<- cbind(spp_tab[,c(2,3,4)],pred_tab[,1])

gdmTab.dis <- formatsitepair(gdmdis, bioFormat=3, XColumn="New_long", YColumn="New_lat", predData=env_tab, siteColumn="site") per <- gdm.varImp(gdmTab.dis, geo=F,parallel = T,cores = 10,nPerm = 100)

fitzLab-AL commented 2 years ago

The gdm.varImp function does not work with only one predictor.

willright28 commented 2 years ago

Thanks,it works. But return another error message"Error in nulldev -vardevtab: has non-numeric parameters" I checked my dataframe all of them were numeric.

---Original--- From: "Fitzpatrick @.> Date: Thu, Jul 14, 2022 20:27 PM To: @.>; Cc: @.**@.>; Subject: Re: [fitzLab-AL/gdm] Error when running gdm.varImp() (Issue #23)

The gdm.varImp function does not work with only one predictor.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>