Hi all,
I am using the stscox and stsgraph commands to attempt a survival curve analysis. A little bit of code below on what I am trying to do. I have a panel data set where I observe a caseworker each month, and I observe the number of cases of type X they have each month (count_* includes count_dv, count_neglect, etc--count of types of child abuse cases they are handling). I have some other varibles including the number of hours regular and overtime they work in a month, as well as the max risk on the cases they work. I am trying to think about correlates/predictors of quitting. I am using a survival curve because my data is right censored, but caseworkers also enter my data at different times (trying to think about the right way to deal with this)?
So basically from 2018-2022, I have caseworkers who are already hired who are observed, who enter and are observed, and who leave and are no longer observed. Code below with "quit_outcome" being a 0/1 var if a caseworker quit in a month. (they drop out of sample after quitting).
A big question I have is this: when I get the hazard ratios, I get a coefficeint around 4 for count_truancy (continuous var of truancy cases a caseworker handles in a month). I divided the data into groups of above and below median handling of truancy cases, but the survival curve for above median is ABOVE the survival curve for below median. Additionally, it looks a bit weird...it looks like caseworkers don't quit until month 20, but when I plot their quit dates, like 60% of them are within the first 16 months.....am I missing something here? TIA

I am using the stscox and stsgraph commands to attempt a survival curve analysis. A little bit of code below on what I am trying to do. I have a panel data set where I observe a caseworker each month, and I observe the number of cases of type X they have each month (count_* includes count_dv, count_neglect, etc--count of types of child abuse cases they are handling). I have some other varibles including the number of hours regular and overtime they work in a month, as well as the max risk on the cases they work. I am trying to think about correlates/predictors of quitting. I am using a survival curve because my data is right censored, but caseworkers also enter my data at different times (trying to think about the right way to deal with this)?
So basically from 2018-2022, I have caseworkers who are already hired who are observed, who enter and are observed, and who leave and are no longer observed. Code below with "quit_outcome" being a 0/1 var if a caseworker quit in a month. (they drop out of sample after quitting).
A big question I have is this: when I get the hazard ratios, I get a coefficeint around 4 for count_truancy (continuous var of truancy cases a caseworker handles in a month). I divided the data into groups of above and below median handling of truancy cases, but the survival curve for above median is ABOVE the survival curve for below median. Additionally, it looks a bit weird...it looks like caseworkers don't quit until month 20, but when I plot their quit dates, like 60% of them are within the first 16 months.....am I missing something here? TIA
Code:
stset time, id(staff_id) failure(quit_outcome) stcox count_* max_score hours_overtime hours_reg stcurve, surv bys staff_id: egen total_truancy_cases=count(count_truancy) replace total_tr=0 if total_tr==. gen truancy_group=(total_truan>33)
