So I have a dataset that is currently in wide format and I have multiple waves recording data such as age, death, diagnosis etc. I have done a simple Cox regression analysis:

summary(fit1 <- survfit(Surv(data$surv_time, data$status) ~ 1, data = data, conf.int=0.95))
plot(fit1, xlab = "Time to Dementia (years)", ylab = "Dementia Probability", main="Kaplan-Meier Estimate of S(t) for data")

cox1 <- coxph(Surv(dat$surv_time, dat$status) ~ sex + age_b, data = dat)

Where I have created my variable for survival/follow up time and also a status variable that records the desired outcome for each individual as equal to 1.

So my first question is, how would I go about doing a multivariate Cox regression if I wanted to i.e. adjust for a categorical variable that records educational attainment that is currently recorded in wide format (education_wave_1, education_wave_2, and so on) would I simply have to convert this variable into long format? Would adjusting for a variable in this way be correct and would I need to take into account the fact that this variable was recorded at different time points somehow? Or, would I just need to adjust for the variables at baseline?

so my other question is, how would I go about doing a longitudinal cox regression model? Is there such a thing?

Hope the post somewhat makes sense, thank you!

  • $\begingroup$ Do any of these additional covariate values change during the time of the study, or are they all represented with their final values at the date of study entry? $\endgroup$ – EdM Jun 17 '19 at 20:17
  • $\begingroup$ These values do change throughout the study, its cohort data. $\endgroup$ – Daria Jun 17 '19 at 20:29
  • $\begingroup$ Do you have covariate values (e.g., educational attainment) for each individual in the study, or do you just have estimates of values shared among all individuals in a "wave" of data? Also, what are you taking as time=0, the date of study entry? $\endgroup$ – EdM Jun 17 '19 at 20:45
  • $\begingroup$ I have covariate values for each individual in the study and for time I have used age at entry to the study (as the cohort is replenished every few years). I also used age at outcome/loss to follow-up/death to ascertain the overall follow up time by minusing the two separate variables from one another if that sorta makes some sense? $\endgroup$ – Daria Jun 17 '19 at 21:21

You certainly can do Cox regression with time-dependent covariates, as explained for R in this vignette. You need to specify, for each data line, a 3-part Surv() object that represents (start_time, stop_time, status at stop_time) along with all covariate values that hold during that time frame for a patient, and thus you must add an additional data line each time that a patient has a change in a covariate value. Tools for changing from wide format to this long format and how to proceed with such analyses are explained in the linked vignette.

Whether you should do this, however, is another question. Remember that the Cox model assumes that the hazard of a change in status at any time is a function of the covariate values at that particular time. As you seem to be modeling dementia, with a presumably long time course before diagnosis, it's not clear how well that assumption would hold for covariates whose values change comparatively rapidly during the course of your study. Next, models with time-dependent covariates can't always be used reliably for predictions. The fact that a patient has survived (in your case, survival without diagnosis) to a particular point in time and now has an updated value of a covariate is by itself related to longer such survival, a type of potential survivorship bias. Furthermore, if you are modeling dementia it seems that you should be including death from other causes as a competing risk. So before you continue with this analysis, and particularly if you choose to go down the path of time-dependent covariates, you should consult closely with a statistician who has expertise in such matters.

Also, one terminology note: what you are proposing with multiple predictors (whether constant in time or time-varying) is best called "Cox multiple regression." "Multivariate" is terminology best reserved for multiple outcomes rather than multiple predictors, although your usage does show up frequently in the literature (and I am to blame for at least one such instance myself).

  • $\begingroup$ Thank you for taking the time to respond, your explanation has really helped. $\endgroup$ – Daria Jun 18 '19 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.