I was trying to understand how GRETL calculates R^2 for fixed-effects
panel-data models as the value it produces is different from Stata and R's
plm library.
As far as I have been able to understand, the calculation happens in the
function fix_within_stats in the file lib/src/gretl_panel.c as follows
(line 1758-9 in the current CVS head, comment in the original):
/* should we modify R^2 in this way? */
fmod->rsq = 1.0 - (fmod->ess / fmod->tss);
Here fmod->ess is the error-sum-of-squared from the regression on the
demeaned data but fmod->tss has been overwritten earlier in the function
(line 1750) by the TSS from the pooled regression.
I am a newcomer to this list, so apologies if this has already been
discussed, but it is not clear to me whether the above is a useful measure
of goodness of fit, since a high R^2 would be reported even in situations
where the unit dummies explain a lot of the variation in y while the
explicit regressors do not add much.
I would be grateful if someone can point me to some justification in the
literature for this measure. I also think that the way R^2 is calculated
should be discussed in the User's Guide.
Stata's xtreg reports three different measures of "R^2" (see page 10 of
http://www.stata-press.com/manuals/stata12/xt_xtreg.pdf ) none of which
match the one above. R's plm function from the plm library reports an R^2
which equals the "within" R^2 reported by Stata.
Gretl could report the same value simply by not modifying the values in
fmod->rsq.
Regards,
Jyotirmoy Bhattacharya