Error in smap[-1, ] when model diagnostics on stratified variable with coxph (survival package) in R

23 views Asked by At

I have a question regarding Cox proportional hazard models and violation of the PH assumption. I am working with survival data on a specific type of cancer between two groups. I have been using the function cox.zph() [in the survival package] to test the proportional hazards assumption for each covariate included in the Cox regression model fit. One variable violates the PH assumption. As far as I can see, I have two options: 1) transform it into a time-dependent covariate or 2) stratify by the covariate. I have not been able to transform the variable into a time-dependent covariate so stratification seems like another option.

However, when trying to stratify for the variable I get this error-message:

Error in smap[-1, ] : incorrect number of dimensions

This is my code:

cox_multi <- coxph(Surv(survivaltime, as.factor(death)) ~ group + strata(pathological_stage) + gender + age + creatinine, id = record_id, data = data1)

I get this error-message:

Error in smap[-1, ] : incorrect number of dimensions

What did I do wrong? How do I stratify for pathological stage (the variable is divided into 5 groups)?

Or how do I transform the variable into a time-dependent variable?

When plotting cox.zph for the variable pathological_stage I get this plot showing that the effect of the variable on the hazard rate changes over time.

enter image description here

0

There are 0 answers