R Kaplan Meier曲线-按性别和危险因素划分曲线

时间:2018-07-15 16:31:33

标签: r

我想创建一个看起来与此link (Researchgate)的Kaplan Meier曲线相似的Kaplan meier曲线 Kaplan meier

我有2个独立变量:1.性别(1 =男性,2 =女性)2.危险因素(1 =存在0 =不存在) Kaplan meier曲线的危险类别应按性别和第二个危险因素进行划分。

Curve 1 : Male + Risk factor present
Curve 2 : Male + No risk factor
Curve 3: Female + risk factor present
Curve 4: Female+ No risk factor

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

我找到了解决方案: http://www.sthda.com/english/wiki/survminer-r-package-survival-data-analysis-and-visualization#survival-curves-with-multiple-groups

# Fit (complexe) survival curves
#++++++++++++++++++++++++++++++++++++
require("survival")
fit2 <- survfit( Surv(time, status) ~ gender + risk factor,
   data = colon )
# Visualize
#++++++++++++++++++++++++++++++++++++
# Visualize: add p-value, chang y limits
# change color using brewer palette
ggsurvplot(fit2, pval = TRUE, 
       break.time.by = 800,
       risk.table = TRUE,
       risk.table.height = 0.5#Useful when you have multiple groups
       )