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]

st: GMM bug when clustering on string var


From   Julian Reif <[email protected]>
To   [email protected]
Subject   st: GMM bug when clustering on string var
Date   Thu, 7 Jul 2011 11:41:40 -0500

The -gmm- command appears to be reporting incorrect standard errors when clustering on a string variable. I am running Stata 11.2 on Windows XP. The following code gives an example:

---------------------
---------------------
clear all
set more off
set seed 29

set obs 100
gen i = _n
gen gamma_i = invnorm(uniform()) + 3
expand 10
bysort i: gen t = _n
gen x1 = invnorm(uniform())*5
gen e = invnorm(uniform())
gen y = 3*x1 + gamma_i + e

gen string_i = string(i)

* Same results for standard errors
reg y x1, vce(cluster i)
reg y x1, vce(cluster string_i)

* These two commands report different results for standard errors
gmm (y - {b1}*x1 - {b0}), instruments(x1) onestep vce(cluster i)
gmm (y - {b1}*x1 - {b0}), instruments(x1) onestep vce(cluster string_i)
---------------------
---------------------



Here is the output from the -reg- and -gmm- commands:



. * Same results for standard errors

. 
. reg y x1, vce(cluster i)

Linear regression                                      Number of obs =    1000
                                                       F(  1,    99) =       .
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.9913
                                                       Root MSE      =  1.3998

                                    (Std. Err. adjusted for 100 clusters in i)
------------------------------------------------------------------------------
             |               Robust
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   2.998964    .007909   379.18   0.000     2.983271    3.014658
       _cons |   3.042796   .1064039    28.60   0.000     2.831667    3.253924
------------------------------------------------------------------------------

. 
. reg y x1, vce(cluster string_i)

Linear regression                                      Number of obs =    1000
                                                       F(  1,    99) =       .
                                                       Prob > F      =  0.0000
                                                       R-squared     =  0.9913
                                                       Root MSE      =  1.3998

                             (Std. Err. adjusted for 100 clusters in string_i)
------------------------------------------------------------------------------
             |               Robust
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   2.998964    .007909   379.18   0.000     2.983271    3.014658
       _cons |   3.042796   .1064039    28.60   0.000     2.831667    3.253924
------------------------------------------------------------------------------

. 
. 
. 
. * These two commands report different results for standard errors

. 
. gmm (y - {b1}*x1 - {b0}), instruments(x1) onestep vce(cluster i)

Step 1
Iteration 0:   GMM criterion Q(b) =  232.29144  
Iteration 1:   GMM criterion Q(b) =  9.907e-25  
Iteration 2:   GMM criterion Q(b) =  2.820e-32  

GMM estimation 

Number of parameters =   2
Number of moments    =   2
Initial weight matrix: Unadjusted                     Number of obs  =    1000

                                    (Std. Err. adjusted for 100 clusters in i)
------------------------------------------------------------------------------
             |               Robust
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         /b1 |   2.998964   .0078654   381.29   0.000     2.983549     3.01438
         /b0 |   3.042796   .1058175    28.76   0.000     2.835397    3.250194
------------------------------------------------------------------------------
Instruments for equation 1: x1 _cons

. 
. gmm (y - {b1}*x1 - {b0}), instruments(x1) onestep vce(cluster string_i)

Step 1
Iteration 0:   GMM criterion Q(b) =  232.29144  
Iteration 1:   GMM criterion Q(b) =  9.907e-25  
Iteration 2:   GMM criterion Q(b) =  2.820e-32  

GMM estimation 

Number of parameters =   2
Number of moments    =   2
Initial weight matrix: Unadjusted                     Number of obs  =    1000

                               (Std. Err. adjusted for 1 clusters in string_i)
------------------------------------------------------------------------------
             |               Robust
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         /b1 |   2.998964   2.85e-17  1.1e+17   0.000     2.998964    2.998964
         /b0 |   3.042796   6.46e-17  4.7e+16   0.000     3.042796    3.042796
------------------------------------------------------------------------------
Instruments for equation 1: x1 _cons


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