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!