<p>Use <strong>-areg-</strong> in Stata, and the standard errors will come out as in the textbook. Specifically, the command </p>

<pre><code>areg lpassen lfare ldist ldistsq y98 y99 y00, absorb(id) vce(robust)
</code></pre>

<p>will produce the desired result.</p>

<p>-xtreg- with fixed effects and the -vce(robust)- option will automatically give standard errors <em>clustered</em> at the <em>id</em> level, whereas -areg- with -vce(robust)- gives the <em>non-clustered</em> robust standard errors. The latter seems to be what Wooldridge estimated.</p>

<p>Moreover, -xtreg- assumes that the number of -xtset- groups (id in your example) grows when more data is added to the sample. -areg-, however, assumes that the number of groups is <em>fixed</em>. I.e., the two estimators have different asymptotic properties. The point estimates will be identical, but standard errors will be different, sometimes substantially so.</p>

<p>Old versions of Stata (e.g. Stata 9) did not make the appropriate degrees of freedom adjustment when -xtreg, vce(robust)- was called, which is why you get a bigger standard error when specifying -version 9-. In fact, those standard errors are identical to -areg, absorb(id) vce(cluster id)- in newer versions of Stata.</p>

<p>As a side note, it is puzzling that Wooldridge got non-clustered robust standard errors when calling -xtreg, vce(robust)- in version 9, but perhaps I have a flawed understanding of what the call -version 9- does.</p>

<p>For more information on -xtreg- vs -areg-, see the blogpost and comments <a href="https://www.fionaburlig.com/blog/2016/8/16/is-the-file-drawer-too-large" rel="nofollow noreferrer">here</a>.</p>

<p>(I recognize that this is a year-old thread, and that the question might have been answered on the Statalist. Consider my answer as "for future reference".)</p>

CC BY-SA 3.0
2017-11-16T18:28:36.437Z
Thanks for your reply. This is very helpful information!
jmbejara
CC BY-SA 3.0
2016-10-07T11:45:06.437Z
2017-11-17T16:10:29.720Z
2017-11-17T16:10:29.720Z
eivindhammers
<p>I'm still not sure if I'm doing something wrong. However, it is useful to note that I get the same results in R.</p>

<pre><code>library(foreign)
library(plm)
library(lmtest)

df &lt;- read.dta("airfare.dta")
fe.out &lt;- plm(lpassen ~ lfare + ldist + ldistsq + y98 + y99 + y00,
         data=df, index = c("id", "year"), 
         method = "within", effect = "individual")
summary(fe.out)
#robust standard errors
coeftest(fe.out, vcov. = vcovHC)
</code></pre>

<p>gives the same results. In fact, none of these seem to match the answer given in the book:</p>

<pre><code>coeftest(fe.out, vcov. = vcovBK)
coeftest(fe.out, vcov. = vcovHC)
coeftest(fe.out, vcov. = vcovSCC)
</code></pre>

<p>The robust standard errors on <code>lfare</code>, for example, that I get in both Stata and R (using vcovHC) is 0.108. The book gives 0.083. </p>

<p>For reference, the output of <code>coeftest(fe.out, vcov. = vcovHC)</code> is</p>

<pre><code>t test of coefficients:

        Estimate Std. Error  t value  Pr(&gt;|t|)    
lfare -1.1550389  0.1085628 -10.6394 &lt; 2.2e-16 ***
y98    0.0464889  0.0049076   9.4728 &lt; 2.2e-16 ***
y99    0.1023612  0.0063086  16.2256 &lt; 2.2e-16 ***
y00    0.1946548  0.0097015  20.0644 &lt; 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
</code></pre>

CC BY-SA 3.0
2016-10-27T06:15:49.853Z
I think what you did is correct. I think it's an error in the book. You could report it to Jeff Wooldridge if you haven't yet.
chan1142
CC BY-SA 3.0
2015-10-24T20:11:18.440Z
2015-10-24T21:34:52.100Z
2015-10-24T21:34:52.100Z
jmbejara
<p>To understand the issue let's review what is the so call robust variance-covariance matrix estimates (VCE) and the implied "robust" standard errors. The robustness is meant to allow for violations of homoscedasticity in the cross-sectional dimension or heteroscedasticity. There are various heteroscedastic robust VCE which are known as the Sandwich estimators or heteroscedasticity consistent (HC) standard errors due to their form: $\gamma(X'X)^{-1}\hat{\Omega}(X'X)^{-1}$. Stata by default uses HC1 which uses the residuals just as HC0, but has a degrees of freedom adjustment. However, one can request HC2 or HC3 through the vce option after a compatible command, e.g., <code>reg y x, vce(hc3)</code>.</p>

<p>However, in the case of unobserved effects models such as the one-way error component (<code>xtreg</code>) one should not use HC estimators and choose an appropriate VCE which allows for dependence of the error term. These are known as CRVE or cluster robust Variance-Covariance estimators. Stata <code>xtreg</code> and <code>xtivreg</code> and similar commands are for short-panels one-way error models (one can include the temporal intercept for two-way error models manually). Therefore, independence in the temporal dimension might be a valid assumption, but rarely we can get away with independence through the cross-sectional dimension and thus one should <strong>always</strong> cluster at least at the panel id level. Stata does not allow for two-way clustering, but the most important one for short-panels should be the <code>cl(pid)</code> option. Stata's CRVE implementation is known as Roger's standard errors and is one of the first estimators... in the future newer solution might be implemented.</p>

<p>In the case of fixed effects models, one should note that the coefficients can be estimated through the within estimator (<code>xtreg</code> or LSDV: <code>reg y x i.pid</code>). The asymptotic standard errors are correct for the LSDV and and for the within after correcting the degree of freedom (which all implementations should do). However, HC standard errors are inconsistent for the fixed effects model. Therefore, it is the norm and what everyone should do to use cluster standard errors as oppose to some sandwich estimator. Stata took the decision to change the <code>robust</code> option after <code>xtreg y x, fe</code> to automatically give you <code>xtreg y x, fe cl(pid)</code> in order to make it more fool-proof and people making a mistake. CRVE are heteroscedastic, autocorrelation, and cluster robust.</p>

<p>As an aside, due to the small size corrections one obtains different cluster robust standard errors with <code>reg y x i.pid, cl(pid)</code> and <code>xtreg y x, fe</code> or equivalent <code>xtreg y x, fe vce(pid)</code>. The correct ones are the latter ones.</p>

<p>PD:
For REIV and FEIV, most implementations including Stata when using 2SLS use a GLS Anova method which by default is the Swamy-Arora which uses the residuals from the between and within models rather than P2SLS.</p>

<p>References:</p>

<p>Cameron, Colin A., and Douglas L. Miller. 2015. "A Practitioner’s Guide to Cluster-Robust Inference." Journal of Human Resources 50 (2): 317–372. doi:10.3368/jhr.50.2.317.</p>

<p>Stock, J. H., and M. W. Watson. 2008. Heteroskedasticity-robust standard errors for fixed effects panel data regression. Econometrica 76: 155–174.</p>

CC BY-SA 3.0
2017-06-29T07:26:37.720Z
2017-06-29T22:53:04.107Z
2017-06-29T22:53:04.107Z
José Bayoán Santiago Calderón
<p>I'm trying to figure out the commands necessary to replicate the following table in Stata. This table is taken from Chapter 11, p. 357 of <em>Econometric Analysis of Cross Section and Panel Data, Second Edition</em> by Jeffrey M Wooldridge. Here I'm specifically trying to figure out how to obtain the robust standard errors (shown in square brackets) in column (2). I'm trying to do this in Stata. I was able to to get the conventional standard errors using the command</p>

<pre><code>xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) fe
</code></pre>

<p>. I was able to get column (1) with</p>

<pre><code>xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id)
</code></pre>

<p>and the corresponding standard errors with</p>

<pre><code>xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) vce(robust)
</code></pre>

<p>. However, the command</p>

<pre><code>xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) fe vce(robust)
</code></pre>

<p>does not work for column (2). It gives results that are different from the book. Could someone explain how to obtain these standard
errors in Stata?</p>

<p>Note that the data to go along with this question can be found here: <a href="https://mitpress.mit.edu/books/econometric-analysis-cross-section-and-panel-data" rel="noreferrer">https://mitpress.mit.edu/books/econometric-analysis-cross-section-and-panel-data</a>
Alternatively, you can load it directly into Stata using </p>

<pre><code>use http://www.stata.com/data/jwooldridge/eacsap/airfare, clear
</code></pre>

<p><a href="https://i.sstatic.net/4iHh2.jpg" rel="noreferrer"><img src="https://i.sstatic.net/4iHh2.jpg" alt="Wooldridge, Panel Book Table 11.1, 2nd Edition, p.357"></a></p>

CC BY-SA 3.0
2015-10-29T15:22:03.880Z
Have you tried using the version command to see if earlier versions of Stata give the desired result? They may have improved or broken things in the version changes since publication. I doubt this is the problem given that it replicates in R. Might be something to try.
BKay
CC BY-SA 3.0
2015-10-29T15:30:22.163Z
I tried using the "version 9.0" and the regression you provided (xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) fe vce(robust)). It actually makes it worse  and increases the standard error to 0.1254713 instead of the 0.1086574  it gives in version 13.
BKay
CC BY-SA 3.0
2015-10-30T01:38:07.383Z
@BKay `xtreg, fe` used to adjust the VCE for the within transformation when the `cluster()` option was specified. The cluster-robust VCE no longer adjusts unless the `dfadj` is specified.
dimitriy
CC BY-SA 3.0
2015-10-30T01:45:10.733Z
@jmbejara JW answers questions on Statalist pretty frequently. I am guessing that might get you an answer.
dimitriy
<econometrics><statistics><regression><stata><paneldata>
Robust Standard Errors in Fixed Effects Model (using Stata)
jmbejara
# Robust Standard Errors in Fixed Effects Model (using Stata)

(Asked by: username_0 on 2015-10-24)

I'm trying to figure out the commands necessary to replicate the following table in Stata. This table is taken from Chapter 11, p. 357 of Econometric Analysis of Cross Section and Panel Data, Second Edition by Jeffrey M Wooldridge. Here I'm specifically trying to figure out how to obtain the robust standard errors (shown in square brackets) in column (2). I'm trying to do this in Stata. I was able to to get the conventional standard errors using the command
xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) fe

. I was able to get column (1) with
xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id)

and the corresponding standard errors with
xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) vce(robust)

. However, the command
xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) fe vce(robust)

does not work for column (2). It gives results that are different from the book. Could someone explain how to obtain these standard
errors in Stata?
Note that the data to go along with this question can be found here: https://mitpress.mit.edu/books/econometric-analysis-cross-section-and-panel-data
Alternatively, you can load it directly into Stata using 
use http://www.stata.com/data/jwooldridge/eacsap/airfare, clear

**Tags:** econometrics, statistics, regression, stata, paneldata
> **Comments:**
> **username_1**: Have you tried using the version command to see if earlier versions of Stata give the desired result? They may have improved or broken things in the version changes since publication. I doubt this is the problem given that it replicates in R. Might be something to try.  
> **username_1**: I tried using the "version 9.0" and the regression you provided (xtreg lpassen lfare ldist ldistsq y98 y99 y00, i(id) fe vce(robust)). It actually makes it worse  and increases the standard error to 0.1254713 instead of the 0.1086574  it gives in version 13.  
> **username_2**: @BKay `xtreg, fe` used to adjust the VCE for the within transformation when the `cluster()` option was specified. The cluster-robust VCE no longer adjusts unless the `dfadj` is specified.  
> **username_2**: @jmbejara JW answers questions on Statalist pretty frequently. I am guessing that might get you an answer.  

---

## 3 answers

### Answer by username_3 on 2016-10-07. Score: 5

Use -areg- in Stata, and the standard errors will come out as in the textbook. Specifically, the command 
areg lpassen lfare ldist ldistsq y98 y99 y00, absorb(id) vce(robust)

will produce the desired result.
-xtreg- with fixed effects and the -vce(robust)- option will automatically give standard errors clustered at the id level, whereas -areg- with -vce(robust)- gives the non-clustered robust standard errors. The latter seems to be what Wooldridge estimated.
Moreover, -xtreg- assumes that the number of -xtset- groups (id in your example) grows when more data is added to the sample. -areg-, however, assumes that the number of groups is fixed. I.e., the two estimators have different asymptotic properties. The point estimates will be identical, but standard errors will be different, sometimes substantially so.
Old versions of Stata (e.g. Stata 9) did not make the appropriate degrees of freedom adjustment when -xtreg, vce(robust)- was called, which is why you get a bigger standard error when specifying -version 9-. In fact, those standard errors are identical to -areg, absorb(id) vce(cluster id)- in newer versions of Stata.
As a side note, it is puzzling that Wooldridge got non-clustered robust standard errors when calling -xtreg, vce(robust)- in version 9, but perhaps I have a flawed understanding of what the call -version 9- does.
For more information on -xtreg- vs -areg-, see the blogpost and comments here.
(I recognize that this is a year-old thread, and that the question might have been answered on the Statalist. Consider my answer as "for future reference".)

> **Comments:**
> **username_0**: Thanks for your reply. This is very helpful information!  

---

### Answer by username_0 on 2015-10-24. Score: 4

I'm still not sure if I'm doing something wrong. However, it is useful to note that I get the same results in R.
library(foreign)
library(plm)
library(lmtest)

df <- read.dta("airfare.dta")
fe.out <- plm(lpassen ~ lfare + ldist + ldistsq + y98 + y99 + y00,
         data=df, index = c("id", "year"), 
         method = "within", effect = "individual")
summary(fe.out)
#robust standard errors
coeftest(fe.out, vcov. = vcovHC)

gives the same results. In fact, none of these seem to match the answer given in the book:
coeftest(fe.out, vcov. = vcovBK)
coeftest(fe.out, vcov. = vcovHC)
coeftest(fe.out, vcov. = vcovSCC)

The robust standard errors on lfare, for example, that I get in both Stata and R (using vcovHC) is 0.108. The book gives 0.083. 
For reference, the output of coeftest(fe.out, vcov. = vcovHC) is
t test of coefficients:

        Estimate Std. Error  t value  Pr(>|t|)    
lfare -1.1550389  0.1085628 -10.6394 < 2.2e-16 ***
y98    0.0464889  0.0049076   9.4728 < 2.2e-16 ***
y99    0.1023612  0.0063086  16.2256 < 2.2e-16 ***
y00    0.1946548  0.0097015  20.0644 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

> **Comments:**
> **username_4**: I think what you did is correct. I think it's an error in the book. You could report it to Jeff Wooldridge if you haven't yet.  

---

### Answer by username_5 on 2017-06-29. Score: 3

To understand the issue let's review what is the so call robust variance-covariance matrix estimates (VCE) and the implied "robust" standard errors. The robustness is meant to allow for violations of homoscedasticity in the cross-sectional dimension or heteroscedasticity. There are various heteroscedastic robust VCE which are known as the Sandwich estimators or heteroscedasticity consistent (HC) standard errors due to their form: $\gamma(X'X)^{-1}\hat{\Omega}(X'X)^{-1}$. Stata by default uses HC1 which uses the residuals just as HC0, but has a degrees of freedom adjustment. However, one can request HC2 or HC3 through the vce option after a compatible command, e.g., `reg y x, vce(hc3)`.

However, in the case of unobserved effects models such as the one-way error component (`xtreg`) one should not use HC estimators and choose an appropriate VCE which allows for dependence of the error term. These are known as CRVE or cluster robust Variance-Covariance estimators. Stata `xtreg` and `xtivreg` and similar commands are for short-panels one-way error models (one can include the temporal intercept for two-way error models manually). Therefore, independence in the temporal dimension might be a valid assumption, but rarely we can get away with independence through the cross-sectional dimension and thus one should **always** cluster at least at the panel id level. Stata does not allow for two-way clustering, but the most important one for short-panels should be the `cl(pid)` option. Stata's CRVE implementation is known as Roger's standard errors and is one of the first estimators... in the future newer solution might be implemented.

In the case of fixed effects models, one should note that the coefficients can be estimated through the within estimator (`xtreg` or LSDV: `reg y x i.pid`). The asymptotic standard errors are correct for the LSDV and and for the within after correcting the degree of freedom (which all implementations should do). However, HC standard errors are inconsistent for the fixed effects model. Therefore, it is the norm and what everyone should do to use cluster standard errors as oppose to some sandwich estimator. Stata took the decision to change the `robust` option after `xtreg y x, fe` to automatically give you `xtreg y x, fe cl(pid)` in order to make it more fool-proof and people making a mistake. CRVE are heteroscedastic, autocorrelation, and cluster robust.

As an aside, due to the small size corrections one obtains different cluster robust standard errors with `reg y x i.pid, cl(pid)` and `xtreg y x, fe` or equivalent `xtreg y x, fe vce(pid)`. The correct ones are the latter ones.

PD:
For REIV and FEIV, most implementations including Stata when using 2SLS use a GLS Anova method which by default is the Swamy-Arora which uses the residuals from the between and within models rather than P2SLS.

References:

Cameron, Colin A., and Douglas L. Miller. 2015. "A Practitioner’s Guide to Cluster-Robust Inference." Journal of Human Resources 50 (2): 317–372. doi:10.3368/jhr.50.2.317.

Stock, J. H., and M. W. Watson. 2008. Heteroskedasticity-robust standard errors for fixed effects panel data regression. Econometrica 76: 155–174.


---

