{"id":7349,"date":"2024-03-29T10:01:02","date_gmt":"2024-03-29T02:01:02","guid":{"rendered":""},"modified":"2024-03-29T10:01:02","modified_gmt":"2024-03-29T02:01:02","slug":"R\u8bed\u8a00\u7ed8\u5236\u6821\u6b63\u534f\u53d8\u91cf\u540e\u7684ROC\u66f2\u7ebf","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7349.html","title":{"rendered":"R\u8bed\u8a00\u7ed8\u5236\u6821\u6b63\u534f\u53d8\u91cf\u540e\u7684ROC\u66f2\u7ebf"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

ROC\u66f2\u7ebf\u4e5f\u53eb\u53d7\u8bd5\u8005\u5de5\u4f5c\u66f2\u7ebf\uff0c\u539f\u6765\u7528\u5728\u519b\u4e8b\u96f7\u8fbe\u4e2d\uff0c\u540e\u9762\u5e7f\u6cdb\u5e94\u7528\u4e8e\u533b\u5b66\u7edf\u8ba1\u4e2d\u3002ROC\u66f2\u7ebf\u662f\u6839\u636e\u4e00\u7cfb\u5217\u4e0d\u540c\u7684\u4e8c\u5206\u7c7b\u65b9\u5f0f(\u5206\u754c\u503c\u6216\u51b3\u5b9a\u9608)\uff0c\u4ee5\u771f\u9633\u6027\u7387(\u7075\u654f\u5ea6)\u4e3a\u7eb5\u5750\u6807\uff0c\u5047\u9633\u6027\u7387(1-\u7279\u5f02\u5ea6)\u4e3a\u6a2a\u5750\u6807\u7ed8\u5236\u7684\u66f2\u7ebf\u3002
ROC\u66f2\u7ebf\u4e3b\u8981\u5e94\u7528\u4e8e\u4e8c\u5206\u7c7b\u7ed3\u5c40\uff0c\u6bd4\u5982\u662f\u5426\u6b7b\u4ea1\uff0c\u75be\u75c5\u8bca\u65ad\uff0c\u80bf\u7624\u590d\u53d1\u7b49\u7b49\uff0c\u53ef\u4ee5\u7528\u4e8e\u81ea\u53d8\u91cf\u4e3a\u8fde\u7eed\u53d8\u91cf\u7684\u622a\u70b9\u5224\u5b9a\u3002
\"R\u8bed\u8a00\u7ed8\u5236\u6821\u6b63\u534f\u53d8\u91cf\u540e\u7684ROC\u66f2\u7ebf
\u76ee\u524d\u6709\u90e8\u5206SCI\u6587\u7ae0\u4e2d\u4f7f\u7528\u4e86\u6821\u6b63\u534f\u53d8\u91cf\u7684ROC\u66f2\u7ebf\uff0c\u540e\u53f0\u6709\u7c89\u4e1d\u95ee\u6821\u6b63\u534f\u53d8\u91cf\u7684ROC\u66f2\u7ebf\u600e\u4e48\u505a\uff0c\u4eca\u5929\u6211\u4eec\u6765\u6f14\u793a\u4e00\u4e0b\uff0c\u4f7f\u7528\u7684\u662f\u4e00\u4e2a\u80be\u79fb\u690d\u7684\u6570\u636e\uff08\u516c\u4f17\u53f7\u56de\u590d\uff1a\u80be\u79fb\u690d\u6570\u636e\uff0c\u53ef\u4ee5\u83b7\u5f97\u8be5\u6570\u636e\uff09\uff0c\u6211\u4eec\u5148\u5bfc\u5165\u6570\u636e\u548cR\u5305\u770b\u4e00\u4e0b\u770b<\/p>\n

library(<\/span>RISCA)<\/span>\ndataDIVAT3<-<\/span>read.csv(<\/span>\"E:\/r\/test\/shenyizhi.csv\"<\/span>,<\/span>sep=<\/span>','<\/span>,<\/span>header=<\/span>TRUE<\/span>)<\/span> \n<\/code><\/pre>\n

\"R\u8bed\u8a00\u7ed8\u5236\u6821\u6b63\u534f\u53d8\u91cf\u540e\u7684ROC\u66f2\u7ebf
\u8fd9\u662f\u4e00\u4e2a4267 \u540d\u6cd5\u56fd\u80be\u79fb\u690d\u53d7\u8005\u7684\u6570\u636e\uff0cageR\uff1a\u63a5\u53d7\u80be\u79fb\u690d\u60a3\u8005\u5e74\u9f84\uff0csexeR\uff1a\u60a3\u8005\u6027\u522b\uff0cyear.tx\uff1a\u80be\u79fb\u690d\u7684\u65f6\u95f4\uff0cante.diab\uff1a\u662f\u5426\u6709\u7cd6\u5c3f\u75c5\uff0cpra\uff1a\u60a3\u8005\u79fb\u690d\u524d\u7684\u514d\u75ab\u53cd\u5e94\uff081 = \u53ef\u68c0\u6d4b\uff0c0 = \u4e0d\u53ef\u68c0\u6d4b\uff09\uff0cageD\uff1a\u6350\u732e\u80be\u810f\u7684\u6350\u732e\u8005\u7684\u5e74\u9f84\uff0cdeath.time;\u751f\u5b58\u65f6\u95f4\uff0cdeath\uff1a\u6b7b\u4ea1\uff0c\u7ed3\u5c40\u53d8\u91cf
\u6211\u4eec\u53d6\u4e00\u90e8\u5206\u6570\u636e\u6765\u5206\u6790\uff0c\u8fd9\u6837\u6570\u636e\u6ca1\u6709\u8fd9\u4e48\u5927\uff0c\u597d\u5206\u6790\u4e00\u70b9<\/p>\n

dataDIVAT3 <-<\/span> dataDIVAT3[<\/span>1<\/span>:<\/span>400<\/span>,<\/span>]<\/span>\n<\/code><\/pre>\n

\u5047\u8bbe\u6211\u4eec\u60f3\u77e5\u9053\u60a3\u8005\u5e74\u9f84\u548c\u6b7b\u4ea1\u7684ROC\u5173\u7cfb\uff0c\u6211\u4eec\u5148\u6765\u4e2a\u6ca1\u6709\u8fdb\u884c\u6821\u6b63\u7684ROC\uff0cconfounders\u662f\u6df7\u6742\u56e0\u7d20\u7684\u610f\u601d\uff0c\u6ca1\u6709\u6821\u6b63\u7684\u65f6\u5019\u8fd9\u91cc\u586b\u51651\uff0cprecision\u662fROC\u66f2\u7ebf\u7684\u6b65\u957f\uff0c\u4e00\u822c\u90fd\u662f\u56fa\u5b9a\u7684<\/p>\n

roc1 <-<\/span> roc.binary(<\/span>status=<\/span>\"death\"<\/span>,<\/span> variable=<\/span>\"ageR\"<\/span>,<\/span> confounders=<\/span>~<\/span>1<\/span>,<\/span>\n                   data=<\/span>dataDIVAT3,<\/span> precision=<\/span>seq(<\/span>0.1<\/span>,<\/span>0.9<\/span>,<\/span> by=<\/span>0.1<\/span>)<\/span> )<\/span>\n<\/code><\/pre>\n

\u7ed8\u56fe<\/p>\n

plot(<\/span>roc1,<\/span> xlab=<\/span>\"1-specificity\"<\/span>,<\/span> ylab=<\/span>\"sensibility\"<\/span>)<\/span>\n<\/code><\/pre>\n

\"R\u8bed\u8a00\u7ed8\u5236\u6821\u6b63\u534f\u53d8\u91cf\u540e\u7684ROC\u66f2\u7ebf
\u5047\u8bbe\u6211\u4eec\u60f3\u5bf9\u60a3\u8005\u6027\u522b\u548c\u6350\u732e\u8005\u5e74\u9f84\u8fd9\u4e24\u4e2a\u6307\u6807\u8fdb\u884c\u6821\u6b63\uff0c\u6821\u6b63\u7684\u601d\u60f3\u4e3b\u8981\u662f\u901a\u8fc7\u9006\u6982\u7387\u52a0\u6743\uff0c\u751f\u4e00\u4e2a\u52a0\u6743\u540e\u7684\u6807\u51c6\u5316\u5e74\u9f84\u6307\u6807\u8fdb\u884c\u6821\u51c6\uff0c\u5148\u5efa\u7acb\u6a21\u578b<\/p>\n

lm1 <-<\/span> lm(<\/span>ageR ~<\/span> ageD +<\/span> sexeR,<\/span> data=<\/span>dataDIVAT3[<\/span>dataDIVAT3$<\/span>death ==<\/span> 0<\/span>,<\/span>]<\/span>)<\/span>\n<\/code><\/pre>\n

\u751f\u6210\u6821\u6b63\u540e\u7684\u6807\u51c6\u5316\u5e74\u9f84\u6307\u6807<\/p>\n

dataDIVAT3$<\/span>ageR_std <-<\/span> (<\/span>dataDIVAT3$<\/span>ageR -<\/span> (<\/span>lm1$<\/span>coef[<\/span>1<\/span>]<\/span> +<\/span> lm1$<\/span>coef[<\/span>2<\/span>]<\/span> *<\/span>\n                                             dataDIVAT3$<\/span>ageD +<\/span> lm1$<\/span>coef[<\/span>3<\/span>]<\/span> *<\/span> dataDIVAT3$<\/span>sexeR)<\/span>)<\/span> \/<\/span> sd(<\/span>lm1$<\/span>residuals)<\/span>\n<\/code><\/pre>\n

\u751f\u6210ROC\u6570\u636e<\/p>\n

roc2 <-<\/span> roc.binary(<\/span>status=<\/span>\"death\"<\/span>,<\/span> variable=<\/span>\"ageR_std\"<\/span>,<\/span>\n                   confounders=<\/span>~<\/span>bs(<\/span>ageD,<\/span> df=<\/span>3<\/span>)<\/span> +<\/span> sexeR,<\/span> data=<\/span>dataDIVAT3,<\/span> precision=<\/span>seq(<\/span>0.1<\/span>,<\/span>0.9<\/span>,<\/span> by=<\/span>0.1<\/span>)<\/span>)<\/span>\n<\/code><\/pre>\n

\u6700\u540e\u7ed8\u56fe<\/p>\n

plot(<\/span>roc2,<\/span> col=<\/span>2<\/span>,<\/span> pch=<\/span>2<\/span>,<\/span> lty=<\/span>2<\/span>,<\/span> type=<\/span>\"b\"<\/span>,<\/span> xlab=<\/span>\"1-specificity\"<\/span>,<\/span> ylab=<\/span>\"sensibility\"<\/span>)<\/span>\nlines(<\/span>roc1,<\/span> col=<\/span>1<\/span>,<\/span> pch=<\/span>1<\/span>,<\/span> type=<\/span>\"b\"<\/span>)<\/span>\nlegend(<\/span>\"bottomright\"<\/span>,<\/span> lty=<\/span>1<\/span>:<\/span>2<\/span>,<\/span> lwd=<\/span>1<\/span>,<\/span> pch=<\/span>1<\/span>:<\/span>2<\/span>,<\/span> col=<\/span>1<\/span>:<\/span>2<\/span>,<\/span>\n       c(<\/span>paste(<\/span>\"Crude estimation, (AUC=\"<\/span>,<\/span> round(<\/span>roc1$<\/span>auc,<\/span> 2<\/span>)<\/span>,<\/span> \")\"<\/span>,<\/span> sep=<\/span>\"\"<\/span>)<\/span>,<\/span>\n         paste(<\/span>\"Adjusted estimation, (AUC=\"<\/span>,<\/span> round(<\/span>roc2$<\/span>auc,<\/span> 2<\/span>)<\/span>,<\/span> \")\"<\/span>,<\/span> sep=<\/span>\"\"<\/span>)<\/span> )<\/span> )<\/span>\n<\/code><\/pre>\n

\"R\u8bed\u8a00\u7ed8\u5236\u6821\u6b63\u534f\u53d8\u91cf\u540e\u7684ROC\u66f2\u7ebf
\u53ef\u4ee5\u770b\u51fa\uff0c\u7ecf\u8fc7\u6821\u6b63\u540e\uff0cAUC\u9762\u79ef\u548c\u66f2\u7ebf\u53d8\u5316\u5e76\u4e0d\u5927\uff0c\u8bf4\u660e\u8bf4\u660e\u6821\u51c6\u56e0\u7d20\u5f71\u54cd\u5f88\u5c0f\uff0c\u652f\u6301\u4e86\u539f\u7ed3\u8bba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"R\u8bed\u8a00\u7ed8\u5236\u6821\u6b63\u534f\u53d8\u91cf\u540e\u7684ROC\u66f2\u7ebf\u8fd9\u662f\u4e00\u4e2a4267\u540d\u6cd5\u56fd\u80be\u79fb\u690d\u53d7\u8005\u7684\u6570\u636e\uff0cageR\u63a5\u53d7\u80be\u79fb\u690d\u60a3\u8005\u5e74\u9f84\uff0csexeR\u60a3\u8005\u6027\u522b\uff0cyear.tx\u80be\u79fb...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7349"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7349"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7349\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}