預測模型在腫瘤學中的應用越來越多,如何比較診斷模型中的敏感性和特異性呢?小編,今天用R語言帶大家一起來解鎖。
上代碼:
install.packages("rio")library(rio)zwang <- import("zwang.xlsx")head(zwang)結果1:
result p p2 p3 p4 E E2 E3 E4 pcorrection chuanglian binglian combind5
1 0 14 0 1 1 6 0 1 0 14 0 0 0
2 0 5 0 1 1 7 0 1 0 9 0 0 0
3 0 7 0 1 1 11 0 1 1 10 0 0 1
4 0 37 1 2 2 20 0 1 1 23 1 1 2
5 1 54 1 3 3 37 1 3 3 30 1 1 NA
6 1 75 1 3 4 27 1 2 2 40 1 1 3install.packages("OptimalCutpoints")library(OptimalCutpoints)optimal.cutpoint.Youden.p<-optimal.cutpoints(X = "p", status = "result", tag.healthy = 0, methods = "Youden", ci.fit = TRUE,data =zwang )summary(optimal.cutpoint.Youden.p)結果2:
Estimate 95% CI lower limit 95% CI upper limit
cutoff 34.00 - -
Se 0.75 0.69 0.80
Sp 0.75 0.71 0.79
PPV 0.63 0.58 0.70
NPV 0.84 0.80 0.87
DLR.Positive 3.02 2.51 3.64
DLR.Negative 0.34 0.27 0.42
FP 102.00 - -
FN 59.00 - -
Optimal criterion 0.50 - -在ROC曲線上繪製cutoff點
plot(optimal.cutpoint.Youden.p)結果3:
另一個模型:
optimal.cutpoint.Youden.e<-optimal.cutpoints(X = "E", status = "result", tag.healthy = 0,methods = "Youden", ci.fit = TRUE,data =zwang )summary(optimal.cutpoint.Youden.e)結果4:
Estimate 95% CI lower limit 95% CI upper limit
cutoff 20.00 - -
Se 0.63 0.56 0.69
Sp 0.81 0.77 0.85
PPV 0.65 0.59 0.71
NPV 0.79 0.75 0.83
DLR.Positive 3.32 2.65 4.15
DLR.Negative 0.46 0.39 0.55
FP 78.00 - -
FN 87.00 - -
Optimal criterion 0.44 - -敏感性比較:
zwang$groupp <- as.numeric(zwang$p>=34)zwang$groupe <- as.numeric(zwang$E>=20)zwang1 <- zwang[ zwang$result==1,]lm1 <- table(zwang1$groupp,zwang1$groupe)mcnemar.test(lm1,correct = F)zwang2 <- zwang[zwang$result==0,]ty1<- table(zwang2$groupp,zwang2$groupe)mcnemar.test(ty1,correct = F)install.packages("DTComPair")library(DTComPair)paired.layout <- tab.paired(d=result, y1=groupp, y2=groupe, data=zwang)paired.layoutnew.df <- generate.paired(paired.layout)ftable(new.df)exact.results <- sesp.mcnemar(paired.layout)exact.resultsstr(exact.results)結果5:
List of 3
$ sensitivity:List of 5
..$ test1 : num 0.747
..$ test2 : num 0.627
..$ diff : num -0.12
..$ test.statistic: num 12.2
..$ p.value : num 0.000465
$ specificity:List of 5
..$ test1 : num 0.753
..$ test2 : num 0.811
..$ diff : num 0.0581
..$ test.statistic: num 6.55
..$ p.value : num 0.0105
$ method : chr "mcnemar"以上由小編編輯整理後發布,
如有侵權,請及時聯繫我,謝謝。
往期回顧:
森林圖(R語言)
生存曲線 (R語言)
SCI寫作神器: AI幫你寫論文
SCI寫作神器: 改寫助手