簡體   English   中英

R中的Cox比例風險模型和時間相關的Cox模型

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM