[R] need help with understanding coxph encoding
Terry Therneau
therneau at mayo.edu
Wed Feb 8 14:46:35 CET 2012
Coxph is a regression model, so the coefficient for "x" is the change in
prediction value for each 1 unit change in x. Just like regression, it
won't matter if you code it as 0/1 or 1/2 or 105 vs 106. If you code it
as 0 vs 10 the coefficient will be divided by 10 though.
The relative hazard in a coxph model is exp(x beta), so the hazard
ratio for a 0 vs 1 variable is exp(beta); this is shown in the long for
printout given by summary(fit).
If you want to use factors, e.g.
xfac = factor(x, levels=1:2, labels=c("control", "treatment"))
then the labels will carry forward to the printout, but that is their
only advantage.
Terry T.
--- begin included message -----------------
Hi, in coxph,
coxph(Surv(time, status)~x,data=alm).
How to encode x? For example, if x has two groups, the treatment group
and
control group. if I encode them as 1 and 2. Is the HR results
treatment/control? What if I encode them as 0 and 1. I am confused with
how
survival package works for HR. What should I do to get a
treatment/control
HR?
Thank you.
More information about the R-help
mailing list