Home  /  Resources & support  /  FAQs  /  R-squared: areg versus xtreg, fe

Why isn’t the calculation of R2 the same for areg and xtreg, fe?

Title   R-squared: areg versus xtreg, fe
Author 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

n
Σ
i=1

 

1


 Ti
(

Ti
Σ
t=1
 yit ) 2   − CF

where the CF is the correction factor

(

n
Σ
i=1

 

Ti
Σ
t=1
 yit ) 2

 

n
Σ
i=1

  Ti  

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.