Am 06.07.2015 um 13:23 schrieb JOSE FRANCISCO PERLES RIBES:
Dear list:
I'm playing with some panel data analysis to do a little course on this
topic and I want to use Gretl for estimations. Following Baltagi
recommendations I want to test the fixed effect restrictions using
Chamberlain (1982) test or Angrist and Newey (1991). Baltagi explains
that these tests are few used in practice. In fact, I have not seen it
implemented in R or other software like Eviews or Stata. So, the
question, somebody has implemented some code to perform these tests?
I'm not familiar with these tests, I just looked into a relevant Baltagi
et al paper, where they say:
"...the sum of T terms. Each term of this sum is simply
the degrees of freedom times the R2 from a regression of within
residuals for a particular period on all leads and lags of the
independent variables."
This sounds relatively simple, as in
(1) run a panel-FE regression ("panel Y const X --fixed-effects"),
(2) store the residuals ("series feresids = $uhat")
(3) for each time period create the leads and lags of the RHS
(4) regress the residuals on those, and record (and sum) the R2*dof.
Here's a working implementation:
<hansl>
# example panel data (balanced?)
open nc_crime.gdt
list lX = wfed
list lY = taxpc
# calculate the "within residuals" (?)
panel lY const lX --fixed-effects
series feresids = $uhat
# prelims
genr time
T = max(time)
test = 0
loop tix = 1..T
smpl time == tix --restrict --replace
maxlead = T - tix
maxlag = tix - 1 # non-negative
if maxlead == 0 || maxlag == 0
# workaround for strange gretl requirement:
list leadlagX = lX(xmin(maxlead,maxlag) to xmax(maxlead,maxlag))
else # both actual leads and lags
list leadlagX = lX(+maxlead to -maxlag)
endif
ols feresids const leadlagX --quiet
test += $rsq * $df
endloop
print test
</hansl>
But I have no idea whether this is really the right way to do it. (For
example the constant term in the second-stage ols...?) If during your
work with this you find anything to correct, it would be nice to let us
know.
hth,
sven