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

Specificity returns NaN #32

Open
luca-scr opened this issue Feb 26, 2020 · 0 comments
Open

Specificity returns NaN #32

luca-scr opened this issue Feb 26, 2020 · 0 comments

Comments

@luca-scr
Copy link

I got this behavior which looks like a bug. It appears both in the package from CRAN and in the latest version from GitHub. Here is a reproducible example:

library(ModelMetrics)
observed <- structure(c(1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L), .Label = c("+", 
"-"), class = "factor")
yprob <- c(0.11, 0.19, 0.89, 0.3, 0.33, 0.92, 0.48, 0.03, 0.09, 0.13)

sensitivity(observed, yprob, 0.1)
sensitivity(observed, yprob, 0.2)
sensitivity(observed, yprob, 0.3)
sensitivity(observed, yprob, 0.4)
sensitivity(observed, yprob, 0.5)

specificity(observed, yprob, 0.6)
specificity(observed, yprob, 0.7)
specificity(observed, yprob, 0.8)
specificity(observed, yprob, 0.9)
specificity(observed, yprob, 1.0)

Notice that sensitivity() accepts a factor as input but the same is not valid for specificity(). Using as.numeric(observed) doesn't work, but it is ok if as.numeric(observed == "+") is used.

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

1 participant