2024 Stata Biostatistics and Epidemiology Virtual Symposium · 22 February
|R-squared: areg versus xtreg, fe
|William Gould, StataCorp
The coefficient estimates and standard errors are the same. The calculation of the R2 is different. In the areg procedure, you are estimating coefficients for each of your covariates plus each dummy variable for your groups. In the xtreg, fe procedure the R2 reported is obtained by only fitting a mean deviated model where the effects of the groups (all of the dummy variables) are assumed to be fixed quantities. So, all of the effects for the groups are simply subtracted out of the model, and no attempt is made to quantify their overall effect on the fit of the model.
Regardless of which approach you take, the SSE (sum-of-squares error) is the same. In the areg approach, the SST (sum-of-squares total) is given by
SST = sum(y2) − (1/n) * (sum(y))2
In the xtreg, fe approach, the R2 reported is not the R2 that is calculated from the regression for areg but the regression for the mean detrended dataset. As such, the SST for the xtreg, fe approach is less than the SST for the areg approach. The two calculations differ by
where the CF is the correction factor
Since the SSE is the same, the R2=1−SSE/SST is very different. The difference is real in that we are making different assumptions with the two approaches. In the xtreg, fe approach, the effects of the groups are fixed and unestimated quantities are subtracted out of the model before the fit is performed. In the areg approach, the group effects are estimated and affect the total sum of squares of the model under consideration.
Classroom and web training
Teaching with Stata
Statalist: The Stata Forum
Last updated: 16 November 2022
StataCorp LLC (StataCorp) strives to provide our users with exceptional products and services. To do so, we must collect personal information from you. This information is necessary to conduct business with our existing and potential customers. We collect and use this information only where we may legally do so. This policy explains what personal information we collect, how we use it, and what rights you have to that information.
These cookies are essential for our website to function and do not store any personally identifiable information. These cookies cannot be disabled.
Please note: Clearing your browser cookies at any time will undo preferences saved here. The option selected here will apply only to the device you are currently using.