I was trying to bootstrap medians in two groups for a survival analysis in order to eventually bootstrap their difference. I use stsum to find the medians in each group. I'm finding that bootstrap fails with an "insufficient observations" even if there is no censoring(program boot2, below) but succeeds when the command is sum, detail (program boot1, below). boot2 works if not bootstrapped. Any thoughts?
Code:
webuse catheter, clear
replace infect = 1 // no censoring
stset time, fail(infect)
cap program drop _all
/* sum */
program define boot1 , rclass
sum time if female, det
return scalar m1 = r(p50)
sum time if !female, det
return scalar m2 = r(p50)
end
/* stsum*/
program define boot2 , rclass
stsum if female
return scalar m1 = r(p50)
stsum if !female
return scalar m2 = r(p50)
end
bootstrap m1 = r(m1) m2 =r(m2), ///
strata(female) reps(50): boot1
Number of strata = 2 Number of obs = 76
Replications = 50
command: boot1
m1: r(m1)
m2: r(m2)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
m1 | 56 23.67985 2.36 0.018 9.588355 102.4116
m2 | 16.5 4.808581 3.43 0.001 7.075355 25.92465
------------------------------------------------------------------------------
/* boot2 by itself: gives nearly identical results */
boot2
return list
scalars:
r(m2) = 16
r(m1) = 54
/* but not with bootstrap */
bootstrap m1 = r(m1) m2 =r(m2), ///
strata(female) reps(50): boot2
Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50
insufficient observations to compute bootstrap standard errors
no results will be saved
r(2000);

Comment