# Violation of proportional hazard for covariate but not for interaction it's part of in a Cox Proportional Hazards model

I have a problem in which one of the covariates in my model violates the assumption of proportional hazards, but the interaction it is part of does not.

Data info:
Lifespan - mosquito time to death (not censored)
feed_time - categorical variable: AM / PM
treatment - categorical variable: infected / uninfected
clutch - continuous variable
cage - cages in which my mosquitoes are housed (i'm using cluster(cage) as mosquitoes within a cage are not independent)

Results of min model: Cox Proportional Hazards Model

 cph(formula = Surv(lifespan) ~ feed_time + treatment * clutch1 +
cluster(cage), data = df, x = T, y = T)

Frequencies of Missing Values Due to Each Variable
Surv(lifespan)      feed_time      treatment        clutch1      feed_time
2              0              0              0              0

Model Tests       Discrimination
Indexes
Obs        298    LR chi2     17.47    R2       0.057
Events     298    d.f.            4    Dxy      0.133
Center -0.2016    Pr(> chi2) 0.0016    g        0.281
Score chi2  17.84    gr       1.324
Pr(> chi2) 0.0013

Coef    S.E.   Wald Z Pr(>|Z|)
feed_time=PM                 -0.3300 0.1402 -2.35  0.0185
treatment=Infected           -0.2582 0.1564 -1.65  0.0988
clutch1                      -0.0008 0.0017 -0.48  0.6346
treatment=Infected * clutch1  0.0073 0.0023  3.18  0.0015


Results of cox.zph:

                                rho    chisq     p
feed_time=PM                  0.000771 0.000251 0.987
treatment=Infected            0.117886 4.548338 0.033
clutch1                       0.072919 1.551721 0.213
treatment=Infected * clutch1 -0.066628 1.084940 0.298


So i've had a read of literature and i'm aware that in cases of violated prop hazard i can either create an interaction between the covariate and time (which wouldn't be ideal as i'm interested in the effect of Treatment) OR stratify my covariate (which i'm not sure you can do with a categorical variable? I've only seen examples with continuous variables).

However, i don't know what is appropriate to do when a covariate lies within an interaction in the same model. If someone could prod me in the right direction for what to do next that would be amazing. I've been knocking my head against this for a while.

edit: Here's the log-log plot for treatment

 myfit <- npsurv(Surv(lifespan) ~ treatment, data=df)
survplot(myfit, loglog=T)


In your model you need to add an interaction term for the infected:

cph(formula = Surv(start_time, end_time, event) ~ feed_time +
treatment * clutch1 + treatment:start_time +
cluster(cage), data = df, x = T, y = T)


See my own answer here and my blog about this here. Since you have a limited amount of data you can also use the tt() approach although I'm uncertain if it works as expected with the rms::cph wrapper.

coxph(formula = Surv(lifespan) ~ feed_time +
treatment * clutch1 + tt(treatment) +
cluster(cage), data = df, x = T, y = T,
tt = function(x, t, ...){
ns(x + t, 2)
})


If you stratify on your main variable you won't get an estimate and you can't do an interaction variable with the clutch1 variable. I may have misread your question but just to be sure, stratification can only be used with categorical variables and not continuous. You can categorize continuous variables but I wouldn't recommend that.

• Ah ok many thanks for helping, so it is ok to have the interaction term with time and treatment without that interaction also being part of the clutch1 interaction? My data is not censored so my Surv object is simply Surv(lifespan) which means treament:lifespan doesn't play nice. Treatment*lifespan will but then that adds lifespan as a main effect which is a bit silly. The start time will be 1 for everyone. I thought stratification was essentially binning your data? How can you bin a categorical variable that's essentially already binned? – Aidan O'Donnell Mar 30 '16 at 12:42
• @AidanO'Donnell - There is no need for a time interaction term with the clutch1 interaction as there is no issue there according to your cox.zph output. You will need to time-split the data or use the tt functionality to get this to work. You can't use the lifespan as it is strongly correlated with the outcome and will be highly significant by design. Stratification is dividing your model into submodels, doing a regression and then combining them at the end. See my links for details. – Max Gordon Mar 30 '16 at 19:11
• I would make a log-log plot with more curves to represent treatment and the interacting variable, by forming 4 groups. And note that cph slightly prefers for you to handle cluster after modeling using robcov. – Frank Harrell Nov 25 '17 at 13:25