最近在学习临床数据的生存分析,用的是cancer的数据
代码如下:
rm(list=ls())
cat("\014")
library(survminer)
library(survival)
data1=cancer
str(data1)
#上面的是number形式,再做个分类的factor
data1$ph.ecog.fac<-as.factor(data1$ph.ecog)
str(data1)
datasurv<- Surv(time=data1$time,event=data1$status==2)
data1$datasurv<-with(data1,datasurv)
colnames(data1)
Multicox1<- coxph(datasurv~age+sex+ph.ecog+ph.karno+meal.cal+wt.loss,data=data1)
summary(Multicox1)
testPH1 <- cox.zph(Multicox1)
print(testPH1)
ggforest(model = Multicox1, data = data1, cpositions = c(0.05, 0.15, 0.35),refLabel = 'reference', noDigits = 3,fontsize = 0.8)
Multicox2<- coxph(datasurv~age+sex+ph.ecog.fac+ph.karno+meal.cal+wt.loss,data=data1)
summary(Multicox2)
testPH2 <- cox.zph(Multicox2)
print(testPH2)
ggforest(model = Multicox2, data = data1, cpositions = c(0.05, 0.15, 0.35),refLabel = 'reference', noDigits = 3,fontsize = 0.8)
Multicox1中,ph.ecog只有一个HR值;而Multicox2中,ph.ecog可以得到(n-1)个HR值。
这两种形式有对错之分,或者优劣之分嘛?