Hello,

I am trying to run covariate-adjusted discrete-time survival analysis, specifically using the Cox model. I've been referring to the survival package guidebook, but am struggling to understand how to properly execute what I hope to achieve.

For some background, I have a person-period dataset, where I have the following variables: studentID, schoolID, districtID, math_disability, lowincome, timepoint, and group. Within a 9-year time period, each studentID can have timepoints that range from 3 to 9. Basically, there are a certain number of timepoints nested in each student ID, studentIDs nested in schoolIDs, and schoolIDs nested in districtIDs. This is a typical educational dataset structure, as you can see. Outcome of interest is math_disability (0/1) and student-level covariate is lowincome (0/1). Each student ID has a group identifier, which includes 9 possible values (A, B, C, D, E, F, G, H, I).

I want to generate a survival probability plot that presents 9 different lines (1 for each "group") for the probability of receiving math_disability (=1) across the 9 timepoints (0-8). I've tried using the stset to set my person-period dataset and use stcox to generate survival probabilities, but I can't generate by-timepoint survival probabilities by "group" while also controlling for the student-level covariate, "lowincome".

I'd very much appreciate any guidance on this. I'm happy to clarify, of course!