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: How does xtreg calculate clustered standard error?


From   Austin Nichols <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: How does xtreg calculate clustered standard error?
Date   Wed, 12 Mar 2014 07:47:45 -0400

Ting JIANG <[email protected]>:

 See manual entries on e.g. -xtreg- for methods and formulas.

On Wed, Mar 12, 2014 at 2:30 AM, Ting JIANG <[email protected]> wrote:
> Dear all,
>
> I'm using Stata 12, and I'm trying to understand xtreg with simulated
> panel data. When I try the following three lines,
>
> reg y x i.id, cluster(id)
>
> areg y x, a(id) cluster(id)
>
> xtreg y x, fe robust
>
> Theoretically they should give identical results. I noticed that they
> give the same coefficient estimates as expected, but the clustered
> standard errors are different.
>
> The results from OLS (the first and second lines) are in accordance
> with the fact that Stata has a multiplier (finite sample adjustment)
> for clustered variance G/(G-1) *(n-1)/(n-k), where G is the number of
> clusters.
>
> But the clustered standard error reported after xtreg (the third line)
> does not match those I got after reg and areg. They are different from
> the numbers without finite sample adjustment too.
>
> On the other hand, if conditional homoskedasticity is assumed, reg,
> areg, xtreg give exactly the same results.
>
> So my questions are:
>
> (1) How exactly does Stata calculate standard errors in the ``xtreg +
> cluster'' case?
>
> (2) Can I expect reg and xtreg to give the same answer when properly specified?
>
> (3) By the way, I also noticed that the t-statistic produced after
> xtreg with cluster option does not follow Stock & Watson's (ECMA,
> 2008) suggestion -- multiply the traditional t-statistic by
> sqrt(G/(G-1)). Am I correct?
>
> Thanks.
>
> I'm providing details of my simulation exercise below.
>
> clear all
> set seed 20140312
> set obs 10
> gen id=_n
> gen u=rnormal()
> expand 4
> sort id
> gen t=mod(_n-1,4)+1
> gen x=rnormal()
> gen y=x+u+rnormal()
> tab id, gen(d)
>
> xtset id t
> reg y x i.id
> areg y x, a(id)
> xtreg y x, fe
>
> /*
> In all three cases, coefficient estimates on x is 1.138147, with
> standard error .2372135
> */
>
> reg y x i.id, cluster(id)
> areg y x, a(id) cluster(id)
> xtreg y x, fe robust
>
> /*
> In the first two cases, standard error of the coefficient estimate on
> x is .2779968, whereas in the third case, it is .2428549. Coefficient
> estimates remain unchanged.
> */
>
> reg y x d*
> predict e, residual
> mat opaccum A=x d2-d10, group(id) op(e)
> mat accum B=x d2-d10
> mat V=invsym(B)*A*invsym(B)
> di sqrt(V[1,1]*10/(10-1)*(40-1)/(40-11))
> di sqrt(V[1,1])
>
> /*
> The numbers displayed are .27799676 and .22741949. The first number
> coincides with the results after reg and areg when specifying cluster
> option. The standard error after xtreg matches neither of the numbers.
> ×/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index