Dear All,
I want to estimate confidence intervals on the estimated cumulative incidence functions generated by stcurve after running a stccreg regression. The non-parametric stcompet option is not what I am looking for. Here is my dataex:
I thought I could bootstrap the CI's using the following code, but cif is not an option for predict. Might there be another way?
I will be grateful for any help anyone may be able to offer.
Many thanks,
Sumedha
I want to estimate confidence intervals on the estimated cumulative incidence functions generated by stcurve after running a stccreg regression. The non-parametric stcompet option is not what I am looking for. Here is my dataex:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(COVID deaths_rate cum_num_vacpct tavg lnprcp grpatidtreat monthlydate) str24 state byte(Female age80plus) float(CumMonthsSAH lnnursing_visits) byte(_st _d _t _t0) float(stop start) 0 0 0 26.89387 4.625463 4825785 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4296350 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2609232 714 "AL" 0 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3845592 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2931233 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4855171 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3097706 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3141305 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2406805 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2627631 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2672092 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4786947 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2959691 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3792777 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2937359 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2738875 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2700808 714 "AL" 0 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3011217 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3351107 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3001171 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4434278 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3102923 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3342011 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3513849 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3135530 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2713157 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4257263 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2599746 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2524957 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4436744 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3060035 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4202188 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3070228 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2666122 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3801665 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4313203 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2457749 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3808970 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4894145 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4622302 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3225875 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4419240 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4561300 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2716008 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4904120 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3161244 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2359942 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3441568 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3230359 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4735391 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2929492 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4512910 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4136783 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 5005909 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4607796 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2575344 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3238279 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2705306 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3186045 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4641303 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4745426 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4737993 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4572224 714 "AL" 0 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3102996 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3241614 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3402434 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2939381 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3844655 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4733580 714 "AL" 0 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2461308 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4509034 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2598118 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2473039 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2616427 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4124404 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4315043 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4555432 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4907557 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3601099 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4841560 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2596517 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2742700 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4082672 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4170902 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4601678 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4438548 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4702746 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3592304 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4587829 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4369520 714 "AL" 0 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4796518 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4845602 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4247550 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3933713 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2422566 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4063063 714 "AL" 0 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3687858 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 3092223 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 4830458 714 "AL" 1 0 0 11.36908 1 0 1 0 1 0 0 0 0 26.89387 4.625463 2615431 714 "AL" 1 1 0 11.36908 1 0 1 0 1 0 end format %tm monthlydate label values COVID COVID label def COVID 0 "No confirmed COVID-19", modify
Code:
stset stop, id(grpatid) enter(start) failure(d2=1) time0(start) . program define cif_boot_covid, rclass 1. version 17 2. syntax 3. . * Re-run the 2SRI model within each bootstrap sample . reghdfe COVID deaths_rate cum_num_vacpct tavg lnprcp, absorb(grpatid monthlydate state, save) cluster(grpatid) res > iduals(resid) 4. predict double COVID_fe, r 5. stcrreg Female age80plus CumMonthsSAH lnnursing_visits COVID COVID_fe, compete(d2=2) 6. drop resid COVID_fe 7. * Predict CIF for COVID==0 . predict cif0, cif at(COVID=0) 8. summarize cif0 9. return scalar cif0_mean = r(mean) 10. . * Predict CIF for COVID==1 . predict cif1, cif at(COVID=1) 11. summarize cif1 12. return scalar cif1_mean = r(mean) 13. end . . bootstrap r(cif0_mean) r(cif1_mean), reps(10) seed(12345) /// > bca level(95) saving(cif_boot_covid_results_Black, replace): cif_boot_covid option cif not allowed an error occurred when bootstrap executed cif_boot_covid r(198);
Many thanks,
Sumedha
Comment