Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generating Confidence Intervals via Bootstrap

    I am attempting to replicate a previously published method using an example dataset. From the bolded line (///KM on original cohort (naive analysis)) the code works, and generates a point estimate of survival and restricted mean survival time. However, I wish to also obtain the 95% confidence intervals via bootstrapping (100 replications) for these endpoints. How can I modify this code to accomplish this aim? Thank you for your time and effort.

    ************************************************** *********************************************
    * VARIABLES

    *id: patient identifier
    *fup_obs: observed follow-up time (time to death or 1 year if censored alive)
    *death: observed event of interest (all-cause death) 1: dead, 0:alive
    *timetosurgery: time to surgery (NA if no surgery)
    *surgery: observed treatment 1 if the patient received surgery within 6 month, 0 otherwise
    *age: age at diagnosis
    *sex: patient's sex
    *perf: performance status at diagnosis
    *stage: stage at diagnosis
    *deprivation: deprivation score
    *charlson: Charlson's comorbidity index
    *emergency: route to diagnosis

    *Dataset: these variables are in a dataset called "SelectedCohort.dta"

    ************************************************** *********************************************

    forval i = 0(1)100 {

    /// selected patients
    use "SelectedCohort.dta", replace
    if `i' > 0 {
    bsample
    }


    /// KM on original cohort (naive analysis)

    stset fup_obs, failure(death)
    sts generate KM_o_s_`i' = s if surgery == 1
    sts generate KM_o_ns_`i' = s if surgery == 0
    integ KM_o_s_`i' _t, gen(RMST_o_s_`i')
    integ KM_o_ns_`i' _t, gen(RMST_o_ns_`i')
    preserve
    rename fup_obs fup
    keep fup KM_o_s_ KM_o_ns_ RMST_o_s_ RMST_o_ns_
    bysort fup (KM_o_s_`i'): replace KM_o_s_`i' = KM_o_s_`i'[1]
    bysort fup (KM_o_ns_`i'): replace KM_o_ns_`i' = KM_o_ns_`i'[1]
    bysort fup (RMST_o_s_`i'): replace RMST_o_s_`i' = RMST_o_s_`i'[1]
    bysort fup (RMST_o_ns_`i'): replace RMST_o_ns_`i' = RMST_o_ns_`i'[1]

    duplicates drop
    keep if fup >365
    sort fup
    cap merge fup using "BootstrapResults.dta"
    cap drop _m
    sort fup
    save "BootstrapResults.dta", replace
    restore


Working...
X