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

Error when running gdm.varImp() #23

Closed
fsdias opened this issue May 1, 2022 · 4 comments
Closed

Error when running gdm.varImp() #23

fsdias opened this issue May 1, 2022 · 4 comments

Comments

@fsdias
Copy link

fsdias commented May 1, 2022

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
Copy link
Owner

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

@willright28
Copy link

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
Copy link
Owner

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

@willright28
Copy link

willright28 commented Jul 14, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants