On Sat, 14 Jan 2012, AGUSTÍN ALONSO RODRÍGUEZ wrote:
I am teaching a course in econometrics using Gretl, and I
would like to receive an example on how to calculate the
regressogram in Gretl.
Regarding nonparametric methods, current gretl offers loess
regression and the Nadaraya-Watson estimator -- see the
functions loess() and nadarwat(). The regressogram is not a
built-in method but it can be scripted in gretl. An example
follows. The data, attached, are from the example at
http://fedc.wiwi.hu-berlin.de/xplore/ebooks/html/anr/anrhtmlnode20.html
<hansl>
function matrix regressogram (series y, series x, matrix cuts)
scalar nbins = cols(cuts) - 1
matrix R = zeros(2*nbins, 2)
scalar k = 1
loop i=1..nbins -q
smpl (x >= cuts[i]) && (x < cuts[i+1]) --restrict
R[k,1] = mean(y)
R[k+1,1] = R[k,1]
R[k,2] = cuts[i]
R[k+1,2] = cuts[i+1] - 0.001
k += 2
smpl --full
endloop
colnames(R, "y x")
outfile "(a)dotdir/regresso.plt" --write
print "plot '-' using 2:1 w l notitle, \
'-' using 3:2 w p notitle"
printf "%10.5g\n", R
print "e"
print y x --byobs
print "e"
outfile --close
gnuplot --input="(a)dotdir/regresso.plt" --output=display
return R
end function
open mcycle.gdt
matrix cuts = seq(0,19) * 3
matrix R = regressogram(y, x, cuts)
print R
</hansl>
Allin Cottrell