excel学习库

excel表格_excel函数公式大全_execl从入门到精通

快速完成批量单因素Cox回归分析,并将结果导出为excel

作为生存数据最长用的统计学方法,COX回归出镜率非常高,无论是SCI还是国内期刊,无论是统计专业人员还是普通医学科研工作者,在统计软件普及的今天,实现起来都比较容易。

无论是生存结局影响因素研究,还是近些年非常火爆的临床预测模型(基于生存数据建立的临床预测模型通常称为预后模型),单因素COX回归常用来进行危险因素的筛选,如果指标不多,10个以内,工作量还可以接受。如果指标(变量)达到10个,甚至是几十个,这个工作量就会有些太大了。

掌握一个批量完成单因素COX回归的方法显然是很有必要的。

1、安装ezcox包并调用

#install.packages("ezcox")library(ezcox)library(survival) #为了使用自带数据集

2、查看所用数据集

lungstr(lung)?lung
lung {survival}  R DocumentationNCCTG Lung Cancer Data
DescriptionSurvival in patients with advanced lung cancer from the North Central Cancer Treatment Group. Performance scores rate how well the patient can perform usual daily activities.
inst: Institution codetime: Survival time in daysstatus: censoring status 1=censored, 2=deadage: Age in yearssex: Male=1 Female=2ph.ecog: ECOG performance score as rated by the physician. 0=asymptomatic, 1= symptomatic but completely ambulatory, 2= in bed <50% of the day, 3= in bed > 50% of the day but not bedbound, 4 = bedboundph.karno: Karnofsky performance score (bad=0-good=100) rated by physicianpat.karno: Karnofsky performance score as rated by patientmeal.cal: Calories consumed at mealswt.loss: Weight loss in last six months

3、分类变量因子化

lung$sex <- factor(lung$sex)lung$ph.ecog <- factor(lung$ph.ecog)str(lung)

4、批量完成单因素Cox回归分析

results <- ezcox(lung, time = "time",status = "status",covariates = c("age", "sex", "ph.ecog","ph.karno","pat.karno","meal.cal","wt.loss"))

5、查看单因素COX回归分析结果,并导出为CSV文件

5.1直接查看

results

5.2表格查看

knitr::kable(results)

5.3把结果直接输出为CSV格式,可以直接用EXCEL打开。

write.csv(results,"results.csv")

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

«    2024年12月    »
1
2345678
9101112131415
16171819202122
23242526272829
3031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
    文章归档
      友情链接