# Model suggestion for a Cox regression with time dependent covariates

I´m modeling the effect of pregnancy on the outcome of a disease (dead-alive). Approx 40% of the patients did become pregnant after the time of diagnosis-but at different points in time. So far I´ve done KM plots showing a clear protective effect of pregnancy on survival and also a regular Cox model-however these have been modeled using only a dichotomised pregnancy variable and assuming the effect is present from the time of diagnosis which is clearly unrealistic since the median time to pregnancy is 4 years from diagnosis.

What kind of model would absorb the effect of multiple pregnancies at different time points after diagnosis? Would it be correct to model the pregnancies interacting with time (which would require some serious data reconstruction-any automated software that could help with this?) or is there another preferred modeling strategy for these problems? Also what is the preferred plotting strategy for these problems?

• interesting question (+1)... this recent paper might be of help: ncbi.nlm.nih.gov/pubmed/21328605 – ocram Nov 14 '12 at 7:25
• Interesting-but I believe the main topic there is time varying effects.//M – Misha Nov 14 '12 at 7:55
• time-varying effects is the topic of the paper... – ocram Nov 14 '12 at 8:00
• This reminds me of the "classical" survival analysis example of the heart transplant data: bit.ly/UFX71v - what you need is a time varying covariate, not necessarily a time-varying coefficient. You can plot your data using KM curves. – boscovich Nov 14 '12 at 8:25
• With this method you would also able to handle the fact that some women may have had more than 1 pregnancy during the follow-up. – boscovich Nov 14 '12 at 8:31

What you need here is a time-varying covariate and not necessarily a time-varying coefficient. A known example that could help you with your analyses is the Stanford heart transplant data.

To present your results you can use the classic Kaplan-Meier estimator that handles time-varying covariates with no problems (remember, though, that this is a crude - or unadjusted analysis with all its well-known limitations).

As an example, the following graph shows the analysis of the Stanford HT data when correctly accounting for the time-varying transplant status (top panel) and without accounting for it (bottom panel).

• I finally managed to do this and I get the following plot – Misha Dec 31 '12 at 9:24
• Regular KM is NOT the proper way of graphing these models. Rather it is an extension to KM by Simon and Makuch that is implemented in Stata. stats.stackexchange.com/posts/46754 – Misha Jan 1 '13 at 0:19
• You can not use the KM like this. Consider the pregnancies with e.g. age as underlying time: Let's say that women are at least 20 when they get their second child and at least 22 when they get their third. Let's assume constant hazard for all ages and all groups (number of children born). Then the 2- and 3-groups will die at the same rate, but the 3-group estimate will (most likely) be larger at any time t , simply because the 3-groups starts dying at a later age. This is a misrepresentation of data. – swmo Feb 19 '15 at 18:24

In R, this can be addressed with the start/stop version of a Survival object, e.g.

fit <- coxph(Surv(time1, time2, status) ~ is.pregnant + other.covariates, data=mydata)


This paper discusses this in more detail: http://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf

Beware immortal time bias in this situation. Your pregnant group will inevitably have a better survival than the non-pregnant group since you can't become pregnant after you die (to the best of my knowledge!)