[英]Cox proportional hazard model and time dependent Cox model in R
我有这个生存数据 ,描述了十年时间研究中三种类型的服务(轿车,餐厅和快递)的死亡率。
数据包含三个变量:服务类型(1 =轿车,2 =餐馆和3 =快捷),年(1到11的整数,其中11表示大于10年)和检查器。
我有两个问题:
1)我已经拟合了Cox比例风险模型,但是检查比例风险假设的方法是什么。 也就是说,我们假设每个人的危险比和基线危险与时间无关。
2)如何在R中拟合时间相关的Cox模型?
这是我的代码:
#Cox Proportional Hazards
cox <- coxph(Surv(Years, Censor) ~ data$`Service Type` )
summary(cox)
pkg生存率中的cox.zph函数会检查比例。 请注意,将“服务类型”用作列名提供了编程麻烦,可以通过允许使用句点代替空格来轻松避免编程麻烦,这是read.table的默认操作:
data <- read.table(url("http://www.stat.ufl.edu/~winner/data/bizmort.dat"), col.names=c("Service Type","Years", "Censor")
# Also note that the censoring indicatior is reversed so will use 1-Censor
require(survival)
cox <- coxph(Surv(Years, 1-Censor) ~ factor(Service.Type), data=data )
# The test fro proportionality:
> cox.zph(cox)
rho chisq p
factor(Service.Type)2 0.0306 0.98 0.322
factor(Service.Type)3 0.0429 1.91 0.167
GLOBAL NA 2.33 0.312
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.