3

I read How to calculate specificity from accuracy and sensitivity, but I have two diagnostic performance measures more. Please correct me if I am wrong: if

  • Sensitivity=TP/(TP+FN)
  • Specificity=TN/(TN+FP)
  • Positive predictive value=TP/(TP+FP)
  • Negative predictive value=TN/(TN+FN)
  • Accuracy=(TP+TN)/(TP+TN+FP+FN)
  • Cohen's kappa=1-[(1-Po)/(1-Pe)]

Can I calculate the accuracy if I know the sensitivity, specificity, positive and negative predictive values? Can I calculate the Cohen's kappa too?

Unfortunately, that situation could happen if you read an abstract of a scientific work.

(I use R)

  • 1
    Interesting question. Looking at all possible combinations of TP, TN, FP, FN, each between 0 and 30, it appears like the answer is "yes", i.e., there are no two combinations with the same sensitivities, specificities, PPVs and NPVs but *different* accuracies. Of course, I still argue that you should not use accuracy to evaluate a classifier at all: [Why is accuracy not the best measure for assessing classification models?](https://stats.stackexchange.com/q/312780/1352) and [Is accuracy an improper scoring rule in a binary classification setting?](https://stats.stackexchange.com/q/359909/1352) – Stephan Kolassa Oct 27 '18 at 14:23
  • Thank you for your comment. I do understand accuracy limitations (that is why I asked about Cohen's kappa too), but in some fields it could be a commonly used value to communicate your results. Anyway, I tried to resolve a linear system with 4 equations, but I did not work as I intended (TP, TN, FP and FN were all equal to 0), probably I did something wrong – statisticianwannabe Oct 27 '18 at 20:32

1 Answers1

1

You generally know TP, FN, FP, and TN, so based on this wiki:

Po = (TP + TN) / (TP + TN + FP + FN),

Pe = ((TP + FN) * (TP + FP) + (FP + TN) * (FN + TN)) / (TP + TN + FP + FN)^2

Kappa = (Po - Pe) / (1 - Pe)

Our friend Wolfram can then help to simplify this, leading to:

Kappa = 2 * (TP * TN - FN * FP) / (TP * FN + TP * FP + 2 * TP * TN + FN^2 + FN * TN + FP^2 + FP * TN)

So in R, the function would be:

cohens_kappa <- function(TP, FN, FP, TN) {
  return(2 * (TP * TN - FN * FP) / (TP * FN + TP * FP + 2 * TP * TN + FN^2 + FN * TN + FP^2 + FP * TN))
}
YvanR
  • 111
  • 2
  • Thank you for your answer. Unfortunately, I generally know TP, TN, FP and FN, but sometimes I do not if I am reading an abstract of a scientific work and I have only the sensitivity, specificity, positive and negative predictive values – statisticianwannabe Nov 16 '19 at 21:30