【问题标题】:Sensitivity and Specificity in RR中的敏感性和特异性
【发布时间】:2020-08-23 03:06:21
【问题描述】:

我想知道如何编写函数 Sensitivity() 和 Specificity() 来帮助我使用 R 计算灵敏度和特异性?哪些选项可以帮助我?

【问题讨论】:

  • 如果您能提供更多信息,您将更有可能收到此类问题的回复。你的数据是什么样的?您可以分享到目前为止您尝试过的任何代码吗?

标签: r functional-programming


【解决方案1】:

这是一个使用 caret 包的方法,它包括一个来自 caret 包的帮助文件的可重现示例(即有人可以快速运行以帮助您的一些代码)。 @llottmanhill 是正确的,当您告诉我们您要做什么时,您将获得更多帮助。现在你的问题很模糊。但是,试一试:

library(caret)
library(MASS)

fit <- lda(Species ~ ., data = iris)
model <- predict(fit)$class

irisTabs <- table(model, iris$Species)

## When passing factors, an error occurs with more
## than two levels
sensitivity(model, iris$Species)

## When passing a table, more than two levels can
## be used
sensitivity(irisTabs, "versicolor")
specificity(irisTabs, c("setosa", "virginica"))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-01
    • 2017-05-17
    • 1970-01-01
    • 2019-12-08
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    相关资源
    最近更新 更多