Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: question about bsample


From   Woolton Lee <finished07@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: question about bsample
Date   Tue, 6 Apr 2010 17:33:13 -0400

Hello,

I have a question about BSAMPLE.  I am running bsample on a dataset
with roughtly 800,000 observations with about 5% of these in the
treatment group (trmtgp == 1).  I am running bsample to compute
standard errors for fitted values

I am using bsample stratified on treatment group (trmtgp) and ending
year (endyr, there are only two years) and clustered on patient zip
code (pat_zip) however I have been finding that every time I run this
program at least one bootstrapped sample is drawn that has not
observations from the treatment group.  As a result, I get an error on
the line sum afr_lgsum_b2x1 bfe_lgsum_b2x1 if trmtgp == 1 because
there are no observations to compute the stats for this command.  It
seems to me that this should never happen because the sample is being
drawn stratified on trmtgp, or am I missing something?  This same
program worked on several other datasets without this error.  These
other datasets have a larger fraction of observations in the treatment
group but that still leaves me scratching my head because the sampling
is still stratified on treatment group.  Does anyone have any ideas as
to why this is occurring?

***************************************************** The program I've
used follows

forvalue i=1/100{

cd "O:\Descriptive\Esther\Data\SNH_project\GBdata\GroupedLogitData\new_ca\datasets"
use Complete_CAmkt6_11JAN09, clear

keep if endyr==0
keep if dist_chgzipcer <5
drop if cnt_dup==2 & trmtgp==0    /* Dec10.09 decide to exclude
overlap zipcode from comparision market*/

// bsample step
bsample, strata (trmtgp endyr) cluster (pat_zip)

qui multin patzpgp_hosp $othvar $nv, group(newgp)
estimates save basemodel, replace
drop $nv

#delimit;
collapse (mean) bfe_lgsum_b2x1=lgsum_b2x1, by (newgp trmtgp) ;
save bfe_logsum, replace;
#delimit cr;
restore

/*after excluding operating status change hospitals*/
preserve
foreach x of global v {
		gen nv_`x'=`x'
}

estimates use basemodel
drop $nv


/*Closure simulation*/
/*a switch for the simulation...if not doing simulation, this comment
should comment out*/
drop if given_ahaid == "6932845"
drop if given_ahaid == "6930605"   /*a switch for the simulation*/

display "BOOTSTRAPPING STANDARD ERRORS, BOOTSTAP # `i'  marker 2"

#delimit;
collapse (mean) afr_lgsum_b2x1=lgsum_b2x1, by (newgp trmtgp) ;
save afr_logsum, replace;
#delimit cr;
restore

* to merge new datasets
clear
use bfe_logsum, clear
sort newgp trmtgp
save, replace

use afr_logsum, clear
sort newgp trmtgp
save, replace

merge newgp trmtgp using bfe_logsum afr_logsum
save simu_result, replace


use simu_result, clear

display "BOOTSTRAPPING STANDARD ERRORS, BOOTSTAP # `i'  marker 3"

gen dd_priv_white=(afr_lgsum_b2x1-bfe_lgsum_b2x1)

#delimit;
sum afr_lgsum_b2x1 bfe_lgsum_b2x1 if trmtgp == 1;

display "BOOTSTRAPPING STANDARD ERRORS, BOOTSTAP # `i'  marker 4";

#delimit cr;

/* privately insured*/
mean dd_priv_white if trmtgp == 1

if `i'==1 {
	mat a_priv_white=e(b)
     }
      else if `i'>1 {
      mat b=e(b)
	mat a_priv_white=(a_priv_white\b)
     }
}
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index