Nuke
Nuke

Reputation: 83

Coxph direction of Hazard Ratio

Let's assume I have the following dataset:

time censor treatment
6 0 A
12 1 A
4 0 B
5 0 B
3 0 C
12 1 C
6 0 B
12 1 C
4 0 A
5 0 C
3 0 B
12 1 A

so what I did is relevel to my reference A and ran:

coxph(Surv(time,censor)~treatment)

I looked at the results and compared with the sample protocol provided and found out that my exp(-coeff) is equal to their exp(coeff) in both cases B and C.

Therefore I have run the code again with reference B and once with reference C and have found out, that both lower and upper limits agree with sample. However I addtionally need the log-rank p-value and this is not provided in this fashion, therefor I would like to find out:

How do I turn around the model, so that inverse hazard ratio and conf. limits and p-values are shown (I mean for inverse model)/ or do you think something else has gone wrong?

Upvotes: 1

Views: 804

Answers (1)

Marco Sandri
Marco Sandri

Reputation: 24262

Use survdiff to perform log-rank test:

dts <- read.table(text='
time censor treatment
6 0 A
12 1 A
4 1 B
5 0 B
3 0 C
12 1 C
6 0 B
12 1 C
4 1 A
5 0 C
3 1 B
12 1 A
', header=T)

cxp <- coxph(Surv(time,censor)~treatment, data=dts)
summary(cxp)

survdiff(formula = Surv(time,censor)~treatment, data=dts)
# Call:
# survdiff(formula = Surv(time, censor) ~ treatment, data = dts)
# 
#             N Observed Expected (O-E)^2/E (O-E)^2/V
# treatment=A 4        4     3.63     0.037      0.15
# treatment=B 4        2     1.10     0.736      1.10
# treatment=C 4        2     3.27     0.491      1.96
# 
#  Chisq= 2.2  on 2 degrees of freedom, p= 0.33

Upvotes: 0

Related Questions