A "bug report" has been filed on sourceforge relating to what gretl
offers as residuals via its $uhat accessor for the fixed- and
random-effects panel-data models. You can find this at
http://sourceforge.net/p/gretl/bugs/199/
In my opinion this is not really a bug report, but it can be
interpreted as a request for clarification on how gretl's $uhat is
calculated for panel-data models (and implicitly, how one might
calculate alternative measures using gretl). In that regard it may
be of interest to others, and merits a reply.
Let's take the fixed-effects model first. It may be represented as
y_{it} = a_i + X_{it}\beta + e_{it}
Gretl takes the "fitted value" ($yhat) to be a_i + X_{it}\beta, and
the residual ($uhat) to be y_{it} minus this fitted value. This
makes sense, IMO, because the fixed effects (the a_i terms) are
taken as parameters to be estimated. However, it can be argued that
the fixed effects are not really "explanatory" and if one defines
the residual as the observed y value minus its "explained" component
one might prefer to see just y_{it} - X_{it}\beta. In gretl you can
get this after fixed-effects estimation as follows:
series ue_fe = $uhat + $ahat - $coeff[1]
where $ahat gives the unit-specific intercept (as it would be
calculated if one included all N unit dummies and omitted a common
y-intercept), and $coeff[1] gives the "global" y-intercept.
For anyone used to Stata, gretl's fixed-effects $uhat corresponds to
what you get from Stata's "predict, e" after xtreg, while the second
variant corresponds to Stata's "predict, ue".
Now let's consider the random-effects model. This can be represented
as
y_{it} = \mu + X_{it}\beta + u_i + e_{it}
In this case gretl considers the "error term" to be u_i + e_{it}
(since u_i is conceived as a random drawing) and the $uhat series is
the estimate of this, namely (taking "hats" as implicit, please)
y_{it} - \mu - X_{it}\beta
which corresponds to Stata's "predict, ue". What if you want an
estimate of just e_{it} (or just u_i) in this case? That's more
difficult, since random-effects estimation in itself does not
require estimation of the u_i in their own right. All that's needed
is an estimate of the variance of u, and even that is derived
indirectly (and may sometimes be negative, requiring adjustment to
zero). Stata offers "predict, e" and "predict, u" but it's not
clear
how they are calculating these. I'd be interested to know, but I'm
pretty sure the calculations are going to be debatable.
Allin Cottrell