I'm trying to run discrete-time survival analysis using the survival package on R. My goal is to generate a graph that shows separate survival plot lines for each level of the "group" variable.
I tried to do this by using:
cox <- coxph(Surv(timepoint,graduation)~lowincome + strata(group) + (1|districtID/schoolID/studentID), data=mydata)
But I receive an error message that says: Error in model.matrix.default(Terms2, mf, constrasts.arg = contrast.arg) : model frame and formula mismatch in model.matrix()
I'm not sure how to resolve this! I did see people who ran into similar errors on stackflow, but I can't figure out how to apply the solution to my dataset. My dataset includes 9 timepoints for each student ID, which are nested in school IDs, which are also nested in district IDs. This is a typical educational data structure (student-school-district).
I can provide a sample of my dataset, too, if that's helpful! Please advise how I could attach it.
Thank you.