I am testing my proportional hazards assumption in R using the cox.zph() function:

km.fit1 <- survfit(Surv(Days[which(Site=="LP")],Status[which(Site=="LP")])~Treat[which(Site=="LP")],
                   data=data2, type="kaplan-meier")    
coxph1 <- coxph(Surv(Days[which(Site=="LP")],Status[which(Site=="LP")])~Treat[which(Site=="LP")],

test <- cox.zph(coxph1)   
                                 rho chisq      p    
Treat[which(Site == "LP")]WC -0.0495  1.55 0.2127    
Treat[which(Site == "LP")]WO -0.0932  5.49 0.0191   
GLOBAL                            NA  5.50 0.0640    

My first problem is why does the output only show for treatments WC and WO and not for my third treatment, W?

My second problem is why when I plot(test) does it come up with two plots (one for WC and one for WO) even though I really only wanted to look at one plot (Treat) which is a 3 level factor (explained by the 3 horizontal lines)?.

schoenfield residuals for proportional hazards assumption

kaplan-meier curve for the three treatments

  • $\begingroup$ I'm voting to close this question as off-topic because the question is addressing programming in R. $\endgroup$ Mar 8, 2017 at 20:45
  • $\begingroup$ The only problem that I have is with interpreting the results that I'm getting--not with the codes that I used $\endgroup$
    – bananna
    Mar 8, 2017 at 21:00

1 Answer 1


In regression models, factor variables are split into contrasts - dummy binary variables. Then the reference level (which I guess is W in your data) is compared pairwise against every other level. It is equivalent to having two binary variables "wasTreatmentWO?" and "wasTreatmentWC?", hence the plots are correct.

If your data is shaped differently, providing a sample would help.

  • $\begingroup$ So how do I interpret my output for the cox.zph function? I figured that if my p-value falls below 0.05, it means that my proportional hazards assumption has been violated. In this case, I have p>0.05 for treatment WC against treatment W,, but p<0.05 for treatment WO against treatment W. Does this mean that one of my treatments violate the assumptions but the other does not? I am having difficulty interpreting these results. I am able to show my kaplan-meier curves if it would help with the interpretation $\endgroup$
    – bananna
    Mar 8, 2017 at 18:40
  • $\begingroup$ If these plots are correct I am having trouble understanding what they are showing. What is the meaning of the 3 horizontal lines? Why do I have 3 lines for beta(t) for each of those 2 treatments? $\endgroup$
    – bananna
    Mar 8, 2017 at 18:49
  • $\begingroup$ For all interpretation matters, your treatment is just two different independent variables, so yes, formally one of the treatments violates the assumptions. Although note that the other p-value is quite low as well. $\endgroup$
    – juod
    Mar 8, 2017 at 18:52
  • $\begingroup$ Hi @juod I've included my kaplan-meier survival curves in case it helps with the interpretation. I expected to have no problem with the proportional hazards assumptions at all. From my results, does this mean that I won't be able to run a cox proportional hazards analysis on my data? $\endgroup$
    – bananna
    Mar 8, 2017 at 19:06
  • $\begingroup$ the reason I ran the coxph() function in the first place was to compare the differences between my survival curves since I have more than 2 levels for treatment. I've also tried using the surfdiff() function to compare between each treatment separately (my results were similar to when I ran the coxph() function in R.) $\endgroup$
    – bananna
    Mar 8, 2017 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.