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 in rf.modelSel #7

Open
jcarlis3 opened this issue Jul 1, 2021 · 3 comments
Open

Error in rf.modelSel #7

jcarlis3 opened this issue Jul 1, 2021 · 3 comments

Comments

@jcarlis3
Copy link

jcarlis3 commented Jul 1, 2021

Hi @jeffreyevans ,

I ran rf.modelSel back in 2017 in my sage-grouse research with Melanie et al. I'm dusting that analysis off, and Melanie pointed out that my MIR values should be 0-1, but several were negative. I see v2.2-0 has incorporated some bug fixes in that function, so I installed and attempted to re-run, but now get an error when running the updated rf.modelSel. I can reproduce the same error using the example in the help doc for rf.modelSel:

require(randomForest)
require(rfUtilities)

sessionInfo()
# R version 4.1.0 (2021-05-18)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 19042)
# 
# Matrix products: default
# 
# locale:
#   [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
# [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
# [5] LC_TIME=English_United States.1252    
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] rfUtilities_2.2-0   randomForest_4.6-14
# 
# loaded via a namespace (and not attached):
#   [1] compiler_4.1.0 tools_4.1.0 


# Example from rf.modelSel
data(airquality)
airquality <- na.omit(airquality)

xdata = airquality[,2:6]
ydata = airquality[,1]

#### Regression example

#### Using Breiman's original Fortran code from randomForest package
( rf.regress <- rf.modelSel(airquality[,2:6], airquality[,1], 
                            imp.scale="se") )

#### Using Wright's C++ code from ranger package
( rf.regress <- rf.modelSel(airquality[,2:6], airquality[,1], 
                            method="Wright") )

#### Classification example
ydata = as.factor(ifelse(ydata < 40, 0, 1))

#### Using Breiman's original Fortran code from randomForest package
( rf.class <- rf.modelSel(xdata, ydata, ntree=1000) )


# The above statement returnes this error:
# [1] "ntree"      "y"          "x"          "importance"
# Error in is.nan(errors) : default method not implemented for type 'list'
@jeffreyevans
Copy link
Owner

jeffreyevans commented Jul 2, 2021 via email

@jcarlis3
Copy link
Author

Brief recap of an off-thread discussion (in case others are having this same issue):

Negative MIR values are caused by the original importance values being negative. Suggestion is to use the CRAN version of the package (currently 2.1-5) and manually remove variables with negative MIR. Future developments may build in this sort of screening, but no fixes are imminent.

@jeffreyevans
Copy link
Owner

jeffreyevans commented Oct 18, 2021 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

2 participants