[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: dropped observations in bootstrap

From   Michael McCulloch <>
To   Statalist <>
Subject   st: dropped observations in bootstrap
Date   Sat, 6 Oct 2007 23:07:41 -0700

Hello, I'd appreciate some guidance on this problem.

I'm running a weighted Cox regression within a bootstrap program.
If I conduct the analysis program, step by step outside the bootstrap it runs just fine.
However, when I conduct the exact same analysis within the bootstrap program, I get the error message:

"Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50
insufficient observations to compute bootstrap standard errors
no results will be saved

What I'd like to learn is: how can I discover what happened to those observations during the bootstrap program? Note that these observations are not dropped during the manual analysis outside the bootstrap program.

I've illustrated my code below, using an adapted version of Stata's system data file cancer.dta.
Note: PART 1 I'm simply setting up cancer.dta for my analysis. My code in question is PART 2 below.

* PART 1
sysuse cancer, replace
ren died failed
tab drug
gen newdrug=0
replace newdrug=1 if drug==2|drug==3
drop drug
rename newdrug drug
tab drug

gen yeartreated=2007
gen monthtreated=10
gen daytreated=05

gen addyear=0
replace addyear=1 if studytime>=12 & studytime<24
replace addyear=2 if studytime>=24 & studytime<36
replace addyear=3 if studytime>=36

gen addmonths=0
replace addmonths=studytime-12 if studytime>=12 & studytime<24
replace addmonths=studytime-24 if studytime>=24 & studytime<36
replace addmonths=studytime-36 if studytime>36

gen yeardied=2007
replace yeardied= yeartreated + addyear if addyear!=0
list yeartreated yeardied addyear

gen monthdied=10
replace monthdied = monthtreated + addmonths if addmonths!=0
list monthtreated monthdied addmonths
replace yeardied=yeardied+1 if monthdied>=12 & monthdied<24
gen newmonthdied=monthdied
replace newmonthdied=monthdied-12 if monthdied>=12 & monthdied<24
replace newmonthdied=monthdied-24 if monthdied>=24
drop monthdied
gen monthdied = newmonthdied
drop newmonthdied

gen daydied=05

replace monthdied=monthdied+studytime if studytime<12
replace yeardied=yeardied+1 if monthdied>12
replace monthdied =monthdied-12 if monthdied>12

gen datedx = mdy(monthtreated, daytreated, yeartreated)
format datedx %d

gen datedied = mdy(monthdied, daydied, yeardied)
format datedied %d

sort datedied

list datedx datedied studytime

* PART 2
capture program drop msm
program define msm, rclass

* fit the full model used in Traditional Cox
logit drug age

*estimate probability of treatment
predict p_tcm_ALL
gen p_notcm_ALL = 1-p_tcm_ALL if drug==0 //want p(drug) for both users and nonusers
replace p_tcm_ALL =p_notcm_ALL if drug==0

*create stabilized weight==P(A)/P(A|W)
logit drug
predict p_ALL
gen p_noALL=1-p_ALL if drug==0
replace p_ALL = p_noALL if drug==0
gen wt_stab_ALL=p_ALL/p_tcm_ALL

* stset the data
stset datedied [iweight=wt_stab_ALL], failure(failed) origin(datedx) scale(30.4375) /*wt: stabilized IPTW*/

* cox
stcox drug
indeplist, local
foreach var of varlist `X' {
return scalar `var' = _b[`var']

end set seed 12358
bootstrap drug=r(drug), eform reps(50): msm

display exp(-1.995311)

* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index