Statalist


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

Re: st: Leave the full dataset in memory when bootstraping


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Leave the full dataset in memory when bootstraping
Date   Fri, 30 May 2008 15:51:01 +0100 (BST)

--- [email protected] wrote:
> I am creating a loop to run a probit model with boostrapped data  
> (using the bsample command).  Unfortunately, I find that with each  
> iteration of my loop, the sample size decreases.  Eventually, the  
> sample size is so small that the loop crashes (due, most typically,
> to one of the independent variables perfectly predicting the
> dependent variable).
> 
> Using the "weight" option with "bsample" preserves the full dataset, 
> but this creates another problem.  Specifically, it causes STATA to  
> pull the exact same sample with each iteration of the loop (which, of
> course, defeats the purpose of iterating the process).

The whole point of -bsample- (and the bootstrap in general) is that it
draws sample with replacement, so you can draw N out of N observations
and the bootstrap sample will differ from the original sample.
-bsample- does that in my Stata. Can you run the example below and see
if it reproduces the error you report? You reproduce that error if the
standard deviation reported in the -sum- command at the bottom is zero.


-- Maarten

*--------------- begin example ------------------
set more off
sysuse auto, clear
gen bw = 1
set seed 123456

tempname memhold
tempfile results
postfile `memhold' rep using `results'
forvalues i = 1/100 {
    bsample, weight(bw)
    qui logit foreign rep78 [fw=bw]
    post `memhold' (_b[rep78])
}
postclose `memhold'
use `results' ,clear
sum rep
*----------------- end example --------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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