On Sat, 31 Mar 2012, Bulent Erdemir wrote:
I'm trying to run multiple OLS's over many data sets and try
to figure out the best R square. Therefore, in a loop, I
want to issue ols command multiple times and store the
r-square for each command result in a dataset. Later I'll
sort this dataset and see the max R-square and the
associated dataset .
Following a similar pattern in Lee C. Adkins' book, "Using
gretl for Principles of Econometrics, 3rd Edition", I tried
to use the store command like in the example in the book, on
page 30 (pdf page 44), below:
#Monte Carlo
open "c:\Program Files\gretl\data\poe\food.gdt"
set seed 3213789
loop 100 -- progressive
genr u = 88*normal()
genr y1 = 80 + 10*x + u
ols y1 const x
genr b1 = $coeff(const)
genr b2 = $coeff(x)
print b1 b2
store coeff.gdt b1 b2
endloop
I applied this method to my script however the store command
wouldn't work resulting in an error like "is not the name of
a series". I checked the source to see what I'm missing but
it seems store command on accept series data, not scalars
[...]
That's true in general ("store" only accepts series) but
there's a special provision for the use of "store" in the
context of a "progressive" loop: as in Lee Adkins' example
above you can give the names of scalars, which are then
expanded to series (of a length equal to the number of
iterations of the loop). This is explained in the chapter on
"Loop constructs" in the User's Guide.
Some recommendations on previous posts don't work for me either.
Like
outfile.
http://lists.wfu.edu/pipermail/gretl-users/2009-June/003339.html
I think you'll have to post your script to get help on this.
Both of the constructs you mention are exercised in the
following trivial example, which works correctly with current
gretl:
<hansl>
open data4-1
series x = sqft
set seed 3213789
loop 100 --progressive
genr u = 88*normal()
genr y1 = 80 + 10*x + u
ols y1 const x
genr b1 = $coeff(const)
genr b2 = $coeff(x)
print b1 b2
store coeff.gdt b1 b2
endloop
ols 1 0 2
scalar R2 = $rsq
outfile --write R2.txt
printf "%.8g\n", R2
outfile --close
</hansl>
Allin Cottrell