当 new_outcome == 1 时计算 NPV、PPV、敏感性、特异性

问题描述 投票:0回答:0

本人是韩国硕士研究生。所以可能你觉得我这句话很别扭。。反正我有数据。

   new_outcome   A      B      C

1: 0 0 1 1 2: 0 0 0 0 3: 0 0 0 0 4: 0 0 0 0 5: 0 0 0 0 6: 0 0 1 0

所以我想在 new_outcome == 1 时计算 NPV、PPV、灵敏度、特异性。 我寻求谷歌,chatGPT。但我没有得到我想要的答案..

帮我 TnT

我试过了..

data_sub <- subset(mydata, new_outcome == 1)

创建混淆矩阵

conf_mat <- confusionMatrix(factor(data_sub$new_outcome), factor(ifelse(data_sub$A + data_sub$B+ data_sub$C >= 2, 1, 0)))

计算指标

NPV <- conf_mat$byClass[["Neg Pred Value"]]
PPV <- conf_mat$byClass[["Pos Pred Value"]]
sensitivity <- conf_mat$byClass[["Sensitivity"]]
specificity <- conf_mat$byClass[["Specificity"]]

r confusion-matrix
© www.soinside.com 2019 - 2024. All rights reserved.