感度と特異度

計算方法

Diease + Diease -
Test + A B
Test - C D
library(caret)
## Loading required package: lattice
## Loading required package: ggplot2

有病率と感度・特異度

PCR検査の感度は60%、特異度は99%程度と言われている。

1万人のうち0.1%にあたる10人が感染しているとする。

Diease + Diease -
Test + 6 100
Test - 4 9890

これを解釈すると以下のようになる。 1万人にPCR検査を行ったところ、106人の陽性者が出た。 このうち、真陽性者は6人、の陽性的中率は、わずかに5.7% となる。

つまり、感度と特異度の解釈は、有病率に大きく影響を受ける。

様々なカットオフ値の感度・特異度

感度・特異度とχ二乗検定

chisq.test(matrix(c(6, 100, 4, 9890), ncol=2, byrow=T))
## Warning in chisq.test(matrix(c(6, 100, 4, 9890), ncol = 2, byrow = T)): Chi-
## squared approximation may be incorrect
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  matrix(c(6, 100, 4, 9890), ncol = 2, byrow = T)
## X-squared = 277.7, df = 1, p-value < 2.2e-16

ROC曲線

  1. x軸を 偽陽性率 (1-特異度)、y軸を感度とする。
  2. 検査値ごとの感度、特異度をプロットする。
  3. 点をつなぐ(これを、Receiver Operator Curve, ROC という)
  4. 全体の面積を1としたときの ROC の下の面積 (Area Under the Curve, AUC) が、0.7以上であればスクリーニングとして適すると判断する。
  5. 以下の方式で、最適なカットオフ値を求める (カッコ内は pROC の print.thres.best.method, OptimalCutpoints での methods, cutpointr の metric)
  • 感度 + (1 - 特異度) が最大の点 (youden, Youden, youden)
  • 左上からの距離が最小の点 (closest.topleft, ROC01, roc01)
  • 感度 \(\times\) 特異度が最大の点 (MaxProdSpSe, prod_sens_spec)
  • その他多数(CRANパッケージ内の説明を参照)

CRAN パッケージ

  • pROC
  • OptimalCutpoints
  • cutpointr
library(OptimalCutpoints)
library(DT)

## data
data("elas")
datatable(elas)

cutpointr

library(cutpointr)
## 
## Attaching package: 'cutpointr'
## The following objects are masked from 'package:caret':
## 
##     precision, recall, sensitivity, specificity
cp <- cutpointr(elas, elas, status, 
                method = maximize_metric, metric = sum_sens_spec)
## Assuming the positive class is 1
## Assuming the positive class has higher x values
summary(cp)
## Method: maximize_metric 
## Predictor: elas 
## Outcome: status 
## Direction: >= 
## 
##     AUC   n n_pos n_neg
##  0.7436 141    96    45
## 
##  optimal_cutpoint sum_sens_spec    acc sensitivity specificity tp fn fp tn
##                37        1.3542 0.6809      0.6875      0.6667 66 30 15 30
## 
## Predictor summary: 
##     Data Min. 5% 1st Qu. Median     Mean 3rd Qu.  95% Max.       SD NAs
##  Overall    5 13      27     39 43.28014   51.00 86.0  163 25.83079   0
##        0    5 10      15     31 29.52222   41.00 52.6   56 14.61862   0
##        1   13 22      32     43 49.72917   60.25 96.5  163 27.43393   0
plot(cp)