Statalist The Stata Listserver


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

Re: st: Bootstrap error


From   jpitblado@stata.com (Jeff Pitblado, StataCorp LP)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Bootstrap error
Date   Thu, 04 May 2006 17:11:27 -0500

Carl Nelson <chnelson@uiuc.edu> is using -bootstrap- (Stata 8 syntax) with
-xtabond2-, but all of the replications appear to be missing:

> I created the following do file to obtain bootstrapped confidence intervals.
> 
> program kuznets, rclass
> 	args lnSEC lnGDPC lnGDPC2
> 	tsset countrycode year
> 	xtabond2 lnSEC l1.lnSEC lnGDPC lnGDPC2, gmm(l1.lnSEC) iv(lnGDPC lnGDPC2)
> 	gen kuz = exp(-_coef[lnGDPC]/(2*_coef[lnGDPC2]))
> 	return scalar x1 = kuz
> end
> 
> bootstrap "kuznets" kuz, reps(25) cluster(countrycode) idcluster(countryrs)

Nick Cox replied with a comment on the -reps()- option and some other
suggestions.

Carl later mentioned he was using Stata 8 syntax, but has Stata 9; so I'll
provide Stata 8 and Stata 9 solutions.

Here is how I would change Carl's -kuznets- program:

	program kuznets, rclass
		tsset newid year
		xtabond2 lnSEC l1.lnSEC lnGDPC lnGDPC2,	///
			gmm(l1.lnSEC) iv(lnGDPC lnGDPC2)
		return scalar kuz = exp(-_coef[lnGDPC]/(2*_coef[lnGDPC2]))
	end

Notice the variable 'newid'.  This variable should identify the resampled
panels uniquely, generated by the -idcluster()- option of -bootstrap-.  Also,
the new -kuznets- program returns the statistic of interest in -r(kuz)-.

In Stata 8, Carl will have to generate the original copy of the 'newid'
variable, then he can call -bootstrap- with the -idcluster(newid)- and
-cluster(countrycode)- options.

	. gen newid = countrycode
	. bootstrap "kuznets" kuz = r(kuz), reps(25) idcluster(newid) cluster(countrycode)

In Stata 9, -bootstrap- will automatically generate a copy of the -cluster()-
variable when the -idcluster()- option is specified, thus Carl can just call
-bootstrap-.

	. bootstrap kuz = r(kuz), reps(25) idcluster(newid) cluster(countrycode) : kuznets

If Carl continues to have trouble, try using the -noisily- option to see what
error messages are being reported by the calls to -kuznets-.

--Jeff
jpitblado@stata.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index