1

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?

user438383
  • 5,716
  • 8
  • 28
  • 43
Nuke
  • 83
  • 1
  • 9
  • 1
    Most likely you think censor==0 is an event and you are telling [r] that censor==1 is an event. But you need to provide reproducible code. People need to be able to cut and paste your code into R and have it work. – Harlan Nelson Oct 26 '17 at 16:03
  • With that data I get an aliased response for treatmentB ( an NA coef) and basically zero for treatmentC. Aliased columns occur when there is colinearity. – IRTFM Oct 26 '17 at 16:06
  • Could you explain in more detail your question "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?" – Marco Sandri Oct 26 '17 at 17:41

1 Answers1

0

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
Marco Sandri
  • 23,289
  • 7
  • 54
  • 58