# Longitudinal Cox Regression analysis?

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)
summary(cox1)


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!

• 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?
– EdM
Commented Jun 17, 2019 at 20:17
• These values do change throughout the study, its cohort data. Commented Jun 17, 2019 at 20:29
• 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?
– EdM
Commented Jun 17, 2019 at 20:45
• 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? Commented Jun 17, 2019 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.