实用文库汇编

上传人:夏** 文档编号:470668737 上传时间:2022-09-19 格式:DOCX 页数:8 大小:96.33KB
返回 下载 相关 举报
实用文库汇编_第1页
第1页 / 共8页
实用文库汇编_第2页
第2页 / 共8页
实用文库汇编_第3页
第3页 / 共8页
实用文库汇编_第4页
第4页 / 共8页
实用文库汇编_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《实用文库汇编》由会员分享,可在线阅读,更多相关《实用文库汇编(8页珍藏版)》请在金锄头文库上搜索。

1、*作者:座殿角*作品编号 48877446331144215458创作日期 :2020年12月20日实用文库汇编之随机森林模型在生存分析中的应用【摘要】目的:本文探讨随机森林方法用于高维度、强相关、 小样本的生存资料分析时,可以起到变量筛选的作用。方法:以乳 腺癌数据集构建乳腺癌转移风险评估模型为实例进行实证分析,使 用随机森林模型进行变量选择,然后拟合cox回归模型。结果:随 机森林模型通过对变量的选择,有效的解决数据维度高且强相关的 情况,得到了较高的AUC值。一、数据说明该乳腺癌数据集来自于NCBI,有77个观测值以及22286个基因 变量。通过筛选选取454个基因变量。将数据随机分为训

2、练集合测 试集,其中2/3为训练集,1/3为测试集。绘制K-M曲线图:Kg pl a n -Mei e r esti mate with 95% confidence bounds二、随机森林模型随机森林由许多的决策树组成,因为这些决策树的形成采用了 随机的方法,因此也叫做随机决策树。随机森林中的树之间是没有 关联的。当测试数据进入随机森林时,其实就是让每一颗决策树进 行分类,最后取所有决策树中分类结果最多的那类为最终的结果。 因此随机森林是一个包含多个决策树的分类器,并且其输出的类别 是由个别树输出的类别的众数而定。使用randomForestSRC包得到的随机森林模型具有以下性质:Numb

3、er of deaths: 27Number of trees: 800Minimum terminal node size: 3Average no. of terminal nodes: 14.4275No. of variables tried at each split: 3Total no. of variables: 452Analysis: RSFFamily: survSplitting rule: logrankError rate: 19.87%发现直接使用随机森林得到的模型,预测误差很大,达到了 19.8%,进一步考虑使用随机森林模型进行变量选择,结果如下: our.rf

4、$rfsrc.refit.objSample size: 52Number of deaths: 19Number of trees: 500Minimum terminal node size: 2Average no. of terminal nodes: 11.554No. of variables tried at each split: 3Total no. of variables: 9Analysis: RSFFamily: survSplitting rule: logrank *random*Number of random split points: 10Error rat

5、e: 11.4% our.rf$topvars1 213821_s_at 219778_at204690_at220788_s_at202202_s_at6 211603_s_at 213055_at219336_s_at 37892_at一共选取了 9个变量,同时误差只有11.4%接下来,使用这些变量做cox回归,剔除模型中不显著(0.01 )的 变量,最终参与模型建立的变量共有4个。模型结果如下:218150_atexp(coef) exp(-coef) lower .95 upper .951.65410.60460.1108624.6800200914_x_at0.99151.0086

6、0.340942.8833220788_s_at0.26493.77500.059441.1805201398_s_at1.74570.57290.331099.2038201719_s_at2.47080.40470.938086.5081202945_at0.41182.42840.039904.2499203261_at3.15020.31740.3364129.4983203757_s_at0.78611.27200.616561.0024205068_s_at0.10739.31800.022230.5181最后选取六个变量拟合生存模型,绘制生存曲线如下:Cox Model匚0五00

7、0_下面绘制ROC曲线,分别在训练集和测试集上绘制ROC曲线,结果 如下:训练集:Time-dependent ROC curve0.00.20.40.60.8False Positive Rate测试集:Time-dependent ROC curve0.00.20.40.60.81.0False Positive Rate由于测试集上的样本过少,所以得到的 AUC值波动大,考虑使用 bootstrap多次计算训练集上的AUC值并求平均来测试模型的效 果:AUC at 1 year: 0.8039456AUC at 3 year: 0.6956907AUC at 5 year: 0.7024

8、846由此可以看到,随机森林通过删除贡献较低的变量,完成变量选择 的工作,在测试集上具有较高的auc值,但是比lasso-cox模型 得到的AUC略低。附录:load(/R/brea.rda)library(survival)set.seed(10)i-sample(1:77,52)train-dati,test-dat-i,library(randomForestSRC)disease.rf-rfsrc(Surv(time,status).,data = train, ntree = 800,mtry = 3, nodesize = 3,splitrule = logrank)disease

9、.rfour.rf- var.select(object=disease.rf, vdv,method = vh.vimp, nrep = 50)our.rf$rfsrc.refit.objour.rf$topvarsindex-numeric(var.rf$modelsize)for(i in 1:var.rf$modelsize)indexi-which(names(dat)=var.rf$topvarsi)data-dat,c(1,2,index)i-sample(1:77,52) train-datai,test-data-i,mod.brea-coxph(Surv(time,stat

10、us).,data=train)train_data-train,c(1,2,which(summary(mod.brea)$coefficients,5=0.1)+2)tset_data-test,c(1,2,which(summary(mod.brea)$coefficients,5=0.1)+2)mod.brea1-coxph(Surv(time,status).,data=train_data)summary(mod.brea1)names(coef(mod.brea1)作者:座殿角作品编号 48877446331144215458创作日期:2020年12月20日plot(survfi

11、t(mod.brea1),xlab=Time”,ylab = Proportion,main=CoxModel”,conf.int=TRUE,col=c(black”,red”,red),ylim=c(0.6,1)index0-numeric(length(coef(mod.brea1)coefficients-coef(mod.brea1)name-gsub(”,”,names(coefficients)for(j in 1:length(index0)index0j-which(names(dat)=namej)library(survivalROC)riskscore-as.matrix

12、(dati,index0)%*% as.matrix(coefficients)y1-survivalROC(Stime=train$time,status=train$status,marker=riskscore,predict.time=1,span = 0.25*(nrow(train)A(-0.20)y3-survivalROC(Stime=train$time,status=train$status,marker=riskscore,predict.time=3,span = 0.25*(nrow(train)A(-0.20)y5-survivalROC(Stime=train$t

13、ime,status=train$status,marker=riskscore,predict.time=5,span = 0.25*(nrow(train)A(-0.20)a-matrix(data=c(y1”,y3”,y5”,y1$AUC,y3$AUC,y5$AUC),nrow=3,ncol=2);a plot(y1$FP,y1$TP,type=l,xlab=False Positive Rate,ylab = True Positive Rate,main=Time-dependent ROC curve,col=green) lines(y3$FP,y3$TP,col=red”,lt

14、y=2)lines(y5$FP,y5$TP,col=blue”,lty=3)legend(bottomright,bty=n,legend = c(AUC at 1 year:0.9271”,AUC at3years:0.8621”,AUCat5years:0.8263”),col=c(green”,red”,blue),lty=c(1,2,3),cex=0.9) abline(0,1)riskscore-as.matrix(dat-i,index0)%*% as.matrix(coefficients)y1-survivalROC(Stime=test$time,status=test$status,marker=riskscore,predic t.time=1,span = 0.25*(nrow(train)A(-0.20)y3-survivalROC(Stime=test$time,status=test$status,marker=riskscore,predic t.time=3,span = 0.25*(nrow(train)A(-0.20)y5-survivalROC(Stime=test$time,status=test$status,marker=riskscore,

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号