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   Ting JIANG <[email protected]>
To   [email protected]
Subject   Re: st: How does xtreg calculate clustered standard error?
Date   Thu, 13 Mar 2014 11:05:51 +0800

Thanks, Steve. I did have consulted pp. 312-314 of [U], and that's how
I manually calculated and confirmed the results of clustered standard
errors for the -reg- and -areg- cases. But the manual didn't mention
whether there is a difference in the computation of clustered standard
errors for panel data models between the within-group demeaning
approach -xtreg- and the least squares dummy variable approach -reg-
and -areg-. My understanding is they should be numerically identical,
but stata reports different numbers.

On Thu, Mar 13, 2014 at 7:54 AM, Steve Samuels <[email protected]> wrote:
>
> In the -xtreg- help is a section on the vce() option. This has a link to
> the -help- for "vce_option" which, in turn, contains links to the Manual
> entry for "Obtaining robust variance estimates". P. 313  of the Stata 13 U
> Manual shows the formulas for the robust independent-data and
> cluster-data variance-covariance matrices.
>
> Steve
> [email protected]
>
>
> On Mar 12, 2014, at 7:59 AM, Ting JIANG <[email protected]> wrote:
>
> Thanks, Austin. I checked xtreg and _robust, but didn't find relevant
> answers to my questions. Would you kindly offer more specific advice?
> Thanks.
>
> On Wed, Mar 12, 2014 at 7:47 PM, Austin Nichols <[email protected]> wrote:
>> 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/
>
> *
> *   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/

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