I'm working with cox proportional hazard (cox-PH) in R. I'm using the smoothed scaled Schoenfeld residual plot to assess the PH assumption.
Suppose I have this model in R, disease as outcome and genetics as exposure:
#Residual plot for genetics:
cox_model <- coxph(Surv(start, end, disease)~1+factor(genetics)+strata(gender), robust =T, data=mydata)
#Residual plot:
test.ph <- cox.zph(cox_model)
plot(test.ph, resid = FALSE)
The covariate genetics has levels in it. Meaning I have made a loop for the cox regression so it can run (make the analysis) for every single level in the covariate genetics. The levels are named like this geneA and geneB. So the covariate genetics has two levels.
When I run a PH test in R, and I look at the residual plot, then it says that the covariate on the plot is genetics. It does not show me if it is geneA or geneB. Then I tried to specify the model, so I can visualise the residual plot seperatly for geneA and geneB, like this:
#Residual plot for geneA:
cox_model <- coxph(Surv(start, end, disease)~1+factor(genetics==geneA)+strata(gender), robust =T, data=mydata)
#Residual plot
test.ph <- cox.zph(cox_model)
plot(test.ph, resid = FALSE)
#Residual plot for geneB:
cox_model <- coxph(Surv(start, end, disease)~1+factor(genetics==geneB)+strata(gender), robust =T, data=mydata)
#Residual plot
test.ph <- cox.zph(cox_model)
plot(test.ph, resid = FALSE)
I get two different plots (which is not a surprise). But what I'm confused about is, that the first plot I get with genetics as the covariate, looks different from the plots of geneA and geneB. So the conclusion is I get three different residual plots, one for geneA, second for geneB and a third for the covariate genetics with both levels?
My question is, how should I interpret the smooth scaled Schoenfeld residual plot that shows the covariate genetics? Is it a combination of both geneA and geneB? And what does that combination mean?
Many thanks in advance !!! :)
Update: I'm using a 3 level co-factor, meaning genetics has 3 levels saying geneA, geneB and none. EdM has answered my Q below
cox.zph()
function (in recent versions) can provide either an overall plot for the predictor or plots for individual levels versus the reference. When you edit the question, please specify the version of the software that you are using. $\endgroup$