Hazard Ratio were different getting by two ways in cph function in r

235 Views Asked by At

I built the Cox proportional hazards model by using cph function as below:

library("rms")

n <- 20 # sample size
set.seed(1234)
time=sample(10:52, replace=TRUE, size=n)
event<-sample(c(0,1), replace=TRUE, size=n)
x1=sample(40:70, replace=TRUE, size=n)
x2=rnorm(n, mean=20, sd=6)
x3=rnorm(n, mean=7, sd=0.9)
x4=sample(c(1,2), replace=TRUE, size=n)
x4=as.factor(x4)
dd=data.frame(time,event,x1,x2,x3,x4)
dd1<-datadist(dd)
options(datadist="dd1")

f <- cph(Surv(time,event)~x1+x2+x3+x4,data=dd,x=T,y=T,surv=T)

Then I checked the hazard ratio in two ways:

(1) the effects from summary(f)

summary(f)

(2)

exp(f$coefficients)

The effects (I guess it is the hazard ratio) by method (1) was very different from the result of hazard ratio by method (2). And I am wondering why they are not the same. Thanks so much.

0

There are 0 best solutions below