{"id":27639,"date":"2024-02-01T17:25:40","date_gmt":"2024-02-01T09:25:40","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=27639"},"modified":"2024-02-01T17:25:42","modified_gmt":"2024-02-01T09:25:42","slug":"%e7%94%9f%e5%ad%98%e5%88%86%e6%9e%90%e5%88%ab%e5%8f%aa%e7%94%a8cox%e5%9b%9e%e5%bd%92%e4%ba%86%ef%bc%8c%e8%b7%9f%e7%9d%80%e5%b0%8f%e6%9e%9c%e8%af%95%e8%af%95%e9%9a%8f%e6%9c%ba%e6%a3%ae%e6%9e%97","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=27639","title":{"rendered":"\u751f\u5b58\u5206\u6790\u522b\u53ea\u7528Cox\u56de\u5f52\u4e86\uff0c\u8ddf\u7740\u5c0f\u679c\u8bd5\u8bd5\u968f\u673a\u68ee\u6797\u751f\u5b58\u5206\u6790\uff01-randomForestSRC"},"content":{"rendered":"<p>\u5c0f\u4f19\u4f34\u505a\u751f\u5b58\u5206\u6790\u7684\u65f6\u5019\u907f\u514d\u4e0d\u4e86\u6784\u5efaCox\u56de\u5f52\u98ce\u9669\u6a21\u578b\uff0c\u5c0f\u679c\u544a\u8bc9\u5927\u5bb6\u4e00\u4e2a\u65b0\u7684\u65b9\u5f0f\uff0c\u5c0f\u4f19\u4f34\u53ef\u4ee5\u4e0d\u518d\u7528Cox\u56de\u5f52\u4e86\uff0c\u6211\u4eec\u53bb\u8bd5\u8bd5\u673a\u68b0\u5b66\u4e60\u7684\u65b9\u6cd5\u4e4b\u4e00\u968f\u673a\u68ee\u6797\u7684\u751f\u5b58\u5206\u6790\u4e5f\u5c31\u662frandomForestSRC\u3002\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b\u65b9\u6cd5\uff0c<\/p>\n<p>\u968f\u673a\u751f\u5b58\u68ee\u6797\u5462\uff0c\u5176\u5b9e\u662f\u901a\u8fc7\u8bad\u7ec3\u5927\u91cf\u751f\u5b58\u6811\uff0c\u4ee5\u8868\u51b3\u7684\u5f62\u5f0f\uff0c\u4ece\u4e2a\u4f53\u6811\u4e4b\u4e2d\u52a0\u6743\u9009\u4e3e\u51fa\u6700\u7ec8\u7684\u9884\u6d4b\u7ed3\u679c\u3002<\/p>\n<p>\u6784\u5efa\u968f\u673a\u751f\u5b58\u68ee\u6797\u5462\u4e00\u822c\u6709\u4e0b\u9762\u51e0\u4e2a\u6d41\u7a0b<\/p>\n<p>\u2160. \u6a21\u578b\u901a\u8fc7\u201c\u81ea\u52a9\u6cd5\u201d\uff08Bootstrap\uff09\u5c06\u539f\u59cb\u6570\u636e\u4ee5\u6709\u653e\u56de\u7684\u5f62\u5f0f\u968f\u673a\u62bd\u53d6\u6837\u672c\uff0c\u5efa\u7acb\u6837\u672c\u5b50\u96c6\uff0c\u5e76\u5c06\u6bcf\u4e2a\u6837\u672c\u4e2d37%\u7684\u6570\u636e\u4f5c\u4e3a\u888b\u5916\u6570\u636e\uff08Out-of-Bag Data\uff09\u6392\u9664\u5728\u5916\uff1b<\/p>\n<p>\u2161. \u5bf9\u6bcf\u4e00\u4e2a\u6837\u672c\u968f\u673a\u9009\u62e9\u7279\u5f81\u6784\u5efa\u5176\u5bf9\u5e94\u7684\u751f\u5b58\u6811\uff1b<\/p>\n<p>\u2162. \u5229\u7528Nelson-Aalen\u6cd5\u4f30\u8ba1\u968f\u673a\u751f\u5b58\u68ee\u6797\u6a21\u578b\u7684\u603b\u7d2f\u79ef\u98ce\u9669\uff1b \u2163. \u4f7f\u7528\u888b\u5916\u6570\u636e\u8ba1\u7b97\u6a21\u578b\u51c6\u786e\u5ea6\u3002<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5f00\u59cb\u5427\uff0c\u6211\u4eec\u5148\u6309\u7167\u4e00\u4e0bR\u5305\uff0c\u6ca1\u6709\u7684\u5c0f\u4f19\u4f34\u5148\u5b89\u88c5\u4e00\u4e0b\u54e6<\/p>\n<p>if (!require(randomForestSRC)) install.packages(&#8220;randomForestSRC&#8221;)<\/p>\n<p>if (!require(survival)) install.packages(&#8220;survival&#8221;)<\/p>\n<p>library(randomForestSRC)<\/p>\n<p>library(survival)<\/p>\n<p>\u6211\u4eec\u5148\u8bfb\u53d6\u4e0b\u793a\u4f8b\u6570\u636e\u770b\u770b\uff0c\u8fd9\u662fR\u5305\u81ea\u5e26\u7684<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u7528\u8fd9\u51e0\u4e2a\u6570\u636e\u8fdb\u884c\u5b66\u4e60\u548c\u5c55\u793a<\/p>\n<p>data(veteran, package = &#8220;randomForestSRC&#8221;)<\/p>\n<p>head(veteran)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"503\" height=\"157\" class=\"wp-image-27642\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-1.png?resize=503%2C157\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-1.png?w=503 503w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-1.png?resize=300%2C94 300w\" sizes=\"(max-width: 503px) 100vw, 503px\" data-recalc-dims=\"1\" \/><\/p>\n<p>data(pbc, package = &#8220;randomForestSRC&#8221;)<\/p>\n<p>head(pbc)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"189\" class=\"wp-image-27643\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-2.png?resize=640%2C189\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-2.png?w=1003 1003w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-2.png?resize=300%2C89 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-2.png?resize=768%2C227 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-2.png?resize=600%2C177 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>data(wihs, package = &#8220;randomForestSRC&#8221;)<\/p>\n<p>head(wihs)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"448\" height=\"158\" class=\"wp-image-27644\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-3.png?resize=448%2C158\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-3.png?w=448 448w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-3.png?resize=300%2C106 300w\" sizes=\"(max-width: 448px) 100vw, 448px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u6211\u4eec\u4f7f\u7528\u80ba\u764c\u7684\u6570\u636e\u96c6\u8fdb\u884c\u5206\u6790<\/p>\n<p>\u80ba\u764c\u7684\u4e24\u79cd\u6cbb\u7597\u65b9\u6848\u7684\u662f\u968f\u673a\u8bd5\u9a8c<\/p>\n<p>\u4f8b\u5b50\u4e00<\/p>\n<p>v.obj &lt;- rfsrc(Surv(time, status) ~ ., data = veteran, ntree = 100, nsplit = 10,<\/p>\n<p>na.action = &#8220;na.impute&#8221;, tree.err = TRUE, importance = TRUE, block.size = 1)<\/p>\n<p>###\u8bbe\u7f6e\u6811\u7684\u4e2a\u6570\u4e3a3\uff1a<\/p>\n<p>## plot tree number 3<\/p>\n<p>plot(get.tree(v.obj, 3))<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"427\" height=\"665\" class=\"wp-image-27645\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-4.png?resize=427%2C665\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-4.png?w=427 427w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-4.png?resize=193%2C300 193w\" sizes=\"(max-width: 427px) 100vw, 427px\" data-recalc-dims=\"1\" \/><\/p>\n<p>###\u7ed8\u5236\u8bad\u7ec3\u68ee\u6797\u7684\u7ed3\u679c<\/p>\n<p>## plot results of trained forest<\/p>\n<p>plot(v.obj)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"636\" class=\"wp-image-27646\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-5.png?resize=640%2C636\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-5.png?w=664 664w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-5.png?resize=300%2C298 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-5.png?resize=150%2C150 150w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-5.png?resize=600%2C596 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-5.png?resize=100%2C100 100w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u6211\u4eec\u76f4\u63a5\u7ed8\u5236\u524d10\u4e2a\u4e2a\u4f53\u7684\u751f\u5b58\u66f2\u7ebf<\/p>\n<p>#\u7ed8\u5236\u524d\u5341\u4e2a\u4e2a\u4f53\u751f\u5b58\u66f2\u7ebf<\/p>\n<p>matplot(v.obj$time.interest, 100 * t(v.obj$survival.oob[1:10, ]), xlab = &#8220;Time&#8221;,<\/p>\n<p>ylab = &#8220;Survival&#8221;, type = &#8220;l&#8221;, lty = 1)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"372\" height=\"608\" class=\"wp-image-27647\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-6.png?resize=372%2C608\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-6.png?w=372 372w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-6.png?resize=184%2C300 184w\" sizes=\"(max-width: 372px) 100vw, 372px\" data-recalc-dims=\"1\" \/><\/p>\n<p>##\u4f7f\u7528\u51fd\u6570plot.survival\u7ed8\u5236\u524d10\u4e2a\u4e2a\u4f53\u7684\u751f\u5b58\u66f2\u7ebf<\/p>\n<p>plot.survival(v.obj, subset = 1:10)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"628\" class=\"wp-image-27648\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-7.png?resize=640%2C628\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-7.png?w=661 661w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-7.png?resize=300%2C295 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-7.png?resize=600%2C589 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0b\u9762\u6211\u4eec###\u5feb\u901f\u4f18\u5316\u8001\u6570\u636e\u7684\u8282\u70b9\u5927\u5c0f##\u6700\u4f18\u7684\u751f\u5b58\u8282\u70b9\u5927\u5c0f\u6bd4\u5176\u4ed6\u5bb6\u65cf#<\/p>\n<p>tune.nodesize(Surv(time, status) ~ ., veteran)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"496\" height=\"338\" class=\"wp-image-27649\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-8.png?resize=496%2C338\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-8.png?w=496 496w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-8.png?resize=300%2C204 300w\" sizes=\"(max-width: 496px) 100vw, 496px\" data-recalc-dims=\"1\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"229\" height=\"390\" class=\"wp-image-27650\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-9.png?resize=229%2C390\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-9.png?w=229 229w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-9.png?resize=176%2C300 176w\" sizes=\"(max-width: 229px) 100vw, 229px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4f8b\u5b502<\/p>\n<p>vd &lt;- veteran<\/p>\n<p>vd$celltype = factor(vd$celltype)<\/p>\n<p>vd$diagtime = factor(vd$diagtime)<\/p>\n<p>vd.obj &lt;- rfsrc(Surv(time, status) ~ ., vd, ntree = 100, nodesize = 5)<\/p>\n<p>plot(get.tree(vd.obj, 3))<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"451\" class=\"wp-image-27651\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-10.png?resize=640%2C451\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-10.png?w=652 652w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-10.png?resize=300%2C211 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-10.png?resize=600%2C422 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u75be\u75c5\u7684\u4f8b\u5b50\u6f14\u793a<\/p>\n<p>\u539f\u53d1\u6027\u80c6\u6c41\u6027\u809d\u786c\u5316PBC<\/p>\n<p>\u6765\u770b\u4e00\u4e0b<\/p>\n<p>pbc.obj &lt;- rfsrc(Surv(days, status) ~ ., pbc)<\/p>\n<p>print(pbc.obj)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"545\" height=\"310\" class=\"wp-image-27652\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-11.png?resize=545%2C310\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-11.png?w=545 545w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-11.png?resize=300%2C171 300w\" sizes=\"(max-width: 545px) 100vw, 545px\" data-recalc-dims=\"1\" \/><\/p>\n<p>#<\/p>\n<p>pbc.obj2 &lt;- rfsrc(Surv(days, status) ~ ., pbc, nsplit = 10, na.action = &#8220;na.impute&#8221;)<\/p>\n<p>##\u4e0e\u4e0a\u9762\u76f8\u540c\uff0c\u4f46\u8fed\u4ee3\u4e22\u5931\u7684\u6570\u636e\u7b97\u6cd5<\/p>\n<p>pbc.obj3 &lt;- rfsrc(Surv(days, status) ~ ., pbc, na.action = &#8220;na.impute&#8221;, nimpute = 3)<\/p>\n<p>## \u4f30\u7b97\u6570\u636e\u7684\u5feb\u901f\u65b9\u6cd5\uff08\u4e0d\u8fdb\u884c\u63a8\u65ad\uff09<\/p>\n<p>pbc.imp &lt;- impute(Surv(days, status) ~ ., pbc, splitrule = &#8220;random&#8221;)<\/p>\n<p>\u6211\u4eec\u5bf9\u4e24\u79cd\u65b9\u6cd5\u6bd4\u8f83\u4e00\u4e0b<\/p>\n<p>\u6bd4\u8f83RF-SRC\u548cCox\u56de\u5f52\uff0c\u8bf4\u660e\u6027\u80fd\u7684c\u6307\u6570\u548cBrier\u8bc4\u5206\u63aa\u65bd\uff0c\u5047\u8bbe\u52a0\u8f7d\u4e86\u201cpec\u201d\u548c\u201csurvival\u201d<\/p>\n<p>##\u6bd4\u8f83RF-SRC\u548cCOX<\/p>\n<p>require(&#8220;survival&#8221;)<\/p>\n<p>require(&#8220;pec&#8221;)<\/p>\n<p>require(&#8220;prodlim&#8221;)<\/p>\n<p>## pec\u6240\u9700\u7684\u9884\u6d4b\u51fd\u6570<\/p>\n<p>predictSurvProb.rfsrc &lt;- function(object, newdata, times, &#8230;) {<\/p>\n<p>ptemp &lt;- predict(object, newdata = newdata, &#8230;)$survival<\/p>\n<p>pos &lt;- sindex(jump.times = object$time.interest, eval.times = times)<\/p>\n<p>p &lt;- cbind(1, ptemp)[, pos + 1]<\/p>\n<p>if (NROW(p) != NROW(newdata) || NCOL(p) != length(times))<\/p>\n<p>stop(&#8220;Prediction failed&#8221;)<\/p>\n<p>p<\/p>\n<p>}<\/p>\n<p>## \u6570\u636e\uff0c\u516c\u5f0f\u89c4\u8303<\/p>\n<p>data(pbc, package = &#8220;randomForestSRC&#8221;)<\/p>\n<p>pbc.na &lt;- na.omit(pbc) ##remove NA&#8217;s<\/p>\n<p>surv.f &lt;- as.formula(Surv(days, status) ~ .)<\/p>\n<p>pec.f &lt;- as.formula(Hist(days, status) ~ 1)<\/p>\n<p>## \u8fd0\u884ccox\/rfsrc\u6a21\u578b\u8fdb\u884c\u8bf4\u660e\u6211\u4eec\u4f7f\u7528\u4e86\u5c11\u91cf\u7684\u6811<\/p>\n<p>cox.obj &lt;- coxph(surv.f, data = pbc.na, x = TRUE)<\/p>\n<p>rfsrc.obj &lt;- rfsrc(surv.f, pbc.na, ntree = 150)<\/p>\n<p>## \u8ba1\u7b97\u671f\u671bBrier\u5206\u6570\u7684bootstrap\u4ea4\u53c9\u9a8c\u8bc1\u4f30\u8ba1<\/p>\n<p>set.seed(17743)<\/p>\n<p>prederror.pbc &lt;- pec(list(cox.obj, rfsrc.obj), data = pbc.na, formula = pec.f, splitMethod = &#8220;bootcv&#8221;,<\/p>\n<p>B = 50)<\/p>\n<p>print(prederror.pbc)<\/p>\n<p>##<\/p>\n<p>plot(prederror.pbc)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"334\" height=\"626\" class=\"wp-image-27653\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-12.png?resize=334%2C626\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-12.png?w=334 334w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-12.png?resize=160%2C300 160w\" sizes=\"(max-width: 334px) 100vw, 334px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u8ba1\u7b97Cox\u56de\u5f52<\/p>\n<p>#Cox<\/p>\n<p>## \u8ba1\u7b97cox\u56de\u5f52\u7684\u888b\u5916C\u6307\u6570\u5e76\u4e0erfsrc\u8fdb\u884c\u6bd4\u8f83<\/p>\n<p>rfsrc.obj &lt;- rfsrc(surv.f, pbc.na)<\/p>\n<p>cat(&#8220;out-of-bag Cox Analysis &#8230;&#8221;, &#8220;\\n&#8221;)<\/p>\n<p>## out-of-bag Cox Analysis &#8230;<\/p>\n<p>cox.err &lt;- sapply(1:100, function(b) {<\/p>\n<p>if (b%%10 == 0)<\/p>\n<p>cat(&#8220;cox bootstrap:&#8221;, b, &#8220;\\n&#8221;)<\/p>\n<p>train &lt;- sample(1:nrow(pbc.na), nrow(pbc.na), replace = TRUE)<\/p>\n<p>cox.obj &lt;- tryCatch({<\/p>\n<p>coxph(surv.f, pbc.na[train, ])<\/p>\n<p>}, error = function(ex) {<\/p>\n<p>NULL<\/p>\n<p>})<\/p>\n<p>if (!is.null(cox.obj)) {<\/p>\n<p>get.cindex(pbc.na$days[-train], pbc.na$status[-train], predict(cox.obj, pbc.na[-train,<\/p>\n<p>]))<\/p>\n<p>} else NA<\/p>\n<p>})<\/p>\n<p>cat(&#8220;E:\\\\SXG&#8221;)<\/p>\n<p>##<\/p>\n<p>## OOB error rates<\/p>\n<p>cat(&#8220;\\tRSF : &#8220;, rfsrc.obj$err.rate[rfsrc.obj$ntree], &#8220;\\n&#8221;)<\/p>\n<p>## RSF : 0.1714494<\/p>\n<p>cat(&#8220;\\tCox regression : &#8220;, mean(cox.err, na.rm = TRUE), &#8220;\\n&#8221;)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"181\" class=\"wp-image-27654\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-13.png?resize=640%2C181\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-13.png?w=715 715w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-13.png?resize=300%2C85 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-13.png?resize=600%2C170 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5bf9\u751f\u5b58\u7ade\u4e89\u98ce\u9669\u6bd4\u4f8b\u6a21\u578b\u8fdb\u884c\u6784\u5efa<\/p>\n<p>\u6765\u770b\u4e00\u4e0b<\/p>\n<p>#\u751f\u5b58\u7ade\u4e89\u98ce\u9669\u6bd4\u4f8b<\/p>\n<p>wihs.obj &lt;- rfsrc(Surv(time, status) ~ ., wihs, nsplit = 3, ntree = 100)<\/p>\n<p>plot.competing.risk(wihs.obj)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"604\" class=\"wp-image-27655\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-14.png?resize=640%2C604\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-14.png?w=668 668w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-14.png?resize=300%2C283 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-14.png?resize=600%2C566 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>cif &lt;- wihs.obj$cif.oob<\/p>\n<p>Time &lt;- wihs.obj$time.interest<\/p>\n<p>idu &lt;- wihs$idu<\/p>\n<p>cif.haart &lt;- cbind(apply(cif[, , 1][idu == 0, ], 2, mean), apply(cif[, , 1][idu ==<\/p>\n<p>1, ], 2, mean))<\/p>\n<p>cif.aids &lt;- cbind(apply(cif[, , 2][idu == 0, ], 2, mean), apply(cif[, , 2][idu ==<\/p>\n<p>1, ], 2, mean))<\/p>\n<p>matplot(Time, cbind(cif.haart, cif.aids), type = &#8220;l&#8221;, lty = c(1, 2, 1, 2), col = c(4,<\/p>\n<p>4, 2, 2), lwd = 3, ylab = &#8220;Cumulative Incidence&#8221;)<\/p>\n<p>legend(&#8220;bottomright&#8221;, legend = c(&#8220;HAART (Non-IDU)&#8221;, &#8220;HAART (IDU)&#8221;, &#8220;AIDS (Non-IDU)&#8221;,<\/p>\n<p>&#8220;AIDS (IDU)&#8221;), lty = c(1, 2, 1, 2), col = c(4, 4, 2, 2), lwd = 3, cex = 0.6)#\u56fe\u6ce8<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"392\" height=\"619\" class=\"wp-image-27656\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-15.png?resize=392%2C619\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-15.png?w=392 392w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/word-image-27639-15.png?resize=190%2C300 190w\" sizes=\"(max-width: 392px) 100vw, 392px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u5c0f\u4f19\u4f34\u53ef\u80fd\u4e0d\u592a\u61c2\u7ed3\u679c\u7684\u542b\u4e49\uff0c\u5c0f\u679c\u8fd9\u91cc\u7b80\u5355\u89e3\u8bfb\u4e00\u4e9b<\/p>\n<p>\u968f\u673a\u751f\u5b58\u68ee\u6797\u53ef\u4ee5\u5bf9\u53d8\u91cf\u91cd\u8981\u6027\u8fdb\u884c\u6392\u540d\uff0cVIMP\u6cd5\u548c\u6700\u5c0f\u6df1\u5ea6\u6cd5\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff1a\u53d8\u91cfVIMP\u503c\u5c0f\u4e8e0\u8bf4\u660e\u8be5\u53d8\u91cf\u964d\u4f4e\u4e86\u9884\u6d4b\u7684\u51c6\u786e\u6027\uff0c\u800c\u5f53VIMP\u503c\u5927\u4e8e0\u5219\u8bf4\u660e\u8be5\u53d8\u91cf\u63d0\u9ad8\u4e86\u9884\u6d4b\u7684\u51c6\u786e\u6027\uff1b\u6700\u5c0f\u6df1\u5ea6\u6cd5\u901a\u8fc7\u8ba1\u7b97\u8fd0\u884c\u5230\u6700\u7ec8\u8282\u70b9\u65f6\u7684\u6700\u5c0f\u6df1\u5ea6\u6765\u7ed9\u51fa\u5404\u53d8\u91cf\u5bf9\u4e8e\u7ed3\u5c40\u4e8b\u4ef6\u7684\u91cd\u8981\u6027\u3002<\/p>\n<p>\u4e0a\u8ff0\u4e3a\u7efc\u5408\u4e24\u79cd\u65b9\u6cd5\u7684\u6563\u70b9\u56fe\uff0c\u5176\u4e2d\uff0c\u84dd\u8272\u70b9\u4ee3\u8868VIMP\u503c\u5927\u4e8e0\uff0c\u7ea2\u8272\u5219\u4ee3\u8868VIMP\u503c\u5c0f\u4e8e0\uff1b\u5728\u7ea2\u8272\u5bf9\u89d2\u865a\u7ebf\u4e0a\u7684\u70b9\u4ee3\u8868\u4e24\u79cd\u65b9\u6cd5\u5bf9\u8be5\u53d8\u91cf\u7684\u6392\u540d\u76f8\u540c\uff0c\u9ad8\u4e8e\u5bf9\u89d2\u865a\u7ebf\u7684\u70b9\u4ee3\u8868\u5176VIMP\u6392\u540d\u66f4\u9ad8\uff0c\u4f4e\u4e8e\u5bf9\u89d2\u865a\u7ebf\u7684\u70b9\u5219\u4ee3\u8868\u5176\u6700\u5c0f\u6df1\u5ea6\u6392\u540d\u66f4\u9ad8\u3002\u76f8\u8f83\u4e8eCox\u6bd4\u4f8b\u98ce\u9669\u56de\u5f52\u6a21\u578b\u7b49\u4f20\u7edf\u751f\u5b58\u5206\u6790\u65b9\u6cd5\uff0c\u968f\u673a\u751f\u5b58\u68ee\u6797\u6a21\u578b\u7684\u9884\u6d4b\u51c6\u786e\u5ea6\u81f3\u5c11\u7b49\u540c\u6216\u4f18\u4e8e\u4f20\u7edf\u751f\u5b58\u5206\u6790\u65b9\u6cd5\u3002<\/p>\n<p>\u968f\u673a\u68ee\u6797\u5462\u5176\u5b9e\u6709\u5f88\u591a\u7684\u4f18\u52bf\uff0c\u5c0f\u679c\u8fd9\u91cc\u5c31\u4e0d\u4e00\u4e00\u4ecb\u7ecd\u4e86\uff0c\u5c0f\u4f19\u4f34\u5b66\u4f1a\u4e86\u5417\uff0c\u5c06\u81ea\u5df1\u7684\u6570\u636e\u53bb\u505a\u4e2a\u5b9e\u9a8c\uff0c\u52a8\u624b\u8bd5\u8bd5\u8fd9\u4e2a\u65b0\u65b9\u6cd5\u5427\uff01<\/p>\n<p>\u5c0f\u4f19\u4f34\u591a\u591a\u7406\u89e3\u4ee3\u7801\u7684\u610f\u4e49\u54e6~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u4f19\u4f34\u505a\u751f\u5b58\u5206\u6790\u7684\u65f6\u5019\u907f\u514d\u4e0d\u4e86\u6784\u5efaCox\u56de\u5f52\u98ce\u9669\u6a21\u578b\uff0c\u5c0f\u679c\u544a\u8bc9\u5927\u5bb6\u4e00\u4e2a\u65b0\u7684\u65b9\u5f0f\uff0c\u5c0f\u4f19\u4f34\u53ef\u4ee5\u4e0d\u518d\u7528Cox\u56de\u5f52\u4e86\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/27639"}],"collection":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27639"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/27639\/revisions"}],"predecessor-version":[{"id":27657,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/27639\/revisions\/27657"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27639"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}