Statalist The Stata Listserver

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

st: Re: Bootstrap error

From   Carl Nelson <>
Subject   st: Re: Bootstrap error
Date   Thu, 4 May 2006 18:54:56 -0500

In response to my question, Jeff Pitblado wrote:

Carl Nelson <> 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) 

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

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])) 

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) 

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 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-. 

I used the Stata9 solution and the noisily option with the 
following result:

 do leekuznets

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

. bootstrap kuz = r(kuz), reps(200) idcluster(newid) cluster
(countrycode) noisily: kuznets
bootstrap: First call to kuznets with data as is:

. kuznets
       panel variable:  newid, 1 to 66
        time variable:  year, 1960 to 1990
Warning: Number of instruments may be large relative to 
number of observations.

Arellano-Bond dynamic panel-data estimation, one-step system 
GMM results
Group variable: newid                           Number of 
obs      =      1980
Time variable : year                            Number of 
groups   =        66
Number of instruments = 467                     Obs per 
group: min =        30
Wald chi2(3)  =  
49353.03                                      avg =     30.00
Prob > chi2   =     
0.000                                      max =        30
             |      Coef.   Std. Err.      z    P>|z|     
[95% Conf. Interval]
       lnSEC |
         L1. |   .9473092   .0073076   129.63   
0.000     .9329864    .9616319
      lnGDPC |    .249166   .1239591     2.01   
0.044     .0062106    .4921214
     lnGDPC2 |  -.0116812   .0072525    -1.61   0.107    -
.0258957    .0025334
       _cons |  -1.523963   .5426993    -2.81   0.005    -
2.587634   -.4602916
Sargan test of overid. restrictions: chi2(463) = 943.38   
Prob > chi2 =  0.000

Arellano-Bond test for AR(1) in first differences: z = -
13.36  Pr > z =  0.000
Arellano-Bond test for AR(2) in first differences: z =  -
3.13  Pr > z =  0.002

Bootstrap replications (200)
repeated time values within panel
the most likely cause for this error is misspecifying the 
cluster(), idcluster(), or
group() option

end of do-file

I have been working on this to help a PhD student in my class 
who is trying to run
this model. When he told me of his problems I thought I could 
find an easy fix.
But, the error above is the same error that the student first 
approached me with.
I know that the model estimated above is poorly specified. I 
will help the student
fix that later. The immediate question is why the bootstrap 
command does not seem 
to be working as expected.

I appreciate any help to resolve this puzzle.

Carl Nelson
*   For searches and help try:

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