I am testing my proportional hazards assumption in R using the cox.zph()
function:
library(survival)
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")],
data=data2)
test <- cox.zph(coxph1)
test
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
par(mfrow=c(1,3))
plot(test)
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)?.