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

Wooldridge, Panel Book Table 11.1, 2nd Edition, p.357

  • $\begingroup$ 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. $\endgroup$
    – BKay
    Oct 29, 2015 at 15:22
  • $\begingroup$ 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. $\endgroup$
    – BKay
    Oct 29, 2015 at 15:30
  • 1
    $\begingroup$ @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. $\endgroup$
    – dimitriy
    Oct 30, 2015 at 1:38
  • $\begingroup$ @jmbejara JW answers questions on Statalist pretty frequently. I am guessing that might get you an answer. $\endgroup$
    – dimitriy
    Oct 30, 2015 at 1:45

3 Answers 3


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

  • $\begingroup$ Thanks for your reply. This is very helpful information! $\endgroup$
    – jmbejara
    Nov 16, 2017 at 18:28

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.


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")
#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
  • $\begingroup$ 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. $\endgroup$
    – chan1142
    Oct 27, 2016 at 6:15

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.


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.