Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: loop for grid-search and bootstrap


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: loop for grid-search and bootstrap
Date   Wed, 2 May 2012 09:55:53 +0200

On Wed, May 2, 2012 at 9:04 AM, econqian222  wrote:
>     Many thanks again! then how to write the loop for the bootstrap program
> and my grid-search program in my last question?

That depends on what program you use and how this mystery program is
implemented. In that sense your question is extremely uninformative,
and ignoring requests to give more details on the program you use is
not going to help you.

If I were to write such a loop to bootstrap -regress- (I would never
do so, as it has the -vce(bootsrap)- option) I would do it something
like this:

*------------ begin example ------------
sysuse auto, clear

gen w = .

tempname memhold
tempfile results
postfile `memhold' foreign turn using `results'

_dots 0, title(Bootstrap) reps(100)
forvalues i = 1/100 {
	bsample ,weight(w)
	qui regress mpg foreign turn [fw=w]
	post `memhold' (_b[foreign]) (_b[turn])
	_dots `i' 0
}
postclose `memhold'

preserve
use `results', clear
sum
restore
*------------ end example ----------------

However, in all likelihood I have just wasted your and my time, as
this might very well not work with your mystery program.

-- Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index