On Mon, 22 Feb 2010, [ISO-8859-1] S�bastien Rodrigue-Priv� wrote:
Hi everyones, I'm a new Gretl user and I have a huge
"mission"
to do with the program.
Huge mission is no problem (a short script) for gretl.
First of all, I have 883 times series variable to deflate. The
name of series are I001EX through I999EX, and I001IM through
I999IM and finally I001IMT through I999IMT. Each of this times
series matrix have to be "deflated", divided by an other time
serie namely def_us (the deflator). I want to program a kind of
loop to "genr" all of this times series data "deflated", an
other 883 series.
After this, for all of this new times series variable (883) I
have to regressed in OLS with some explicative variable. Again I
want to create a loop, not to do so 883 times, one by one.
Finally, I want, all my results being exportable in block to an
Excel or the OpenOffice table, once. This part, I honestly have
no clue how to do this things at all, or if it's at least
possible.
<script>
# create big list of all dependent series
list ylist = I*EX I*IM I*IT
# and the list of regressors
list xlist = # <- put your regressors here
# full results matrix, starts out empty
matrix Res = {}
loop foreach i ylist --quiet
# deflate the series
series $i_def = $i / def_us
# run the regression
ols $i_def 0 xlist --quiet
# grab the coefficients and standard errors
matrix res = $coeff' | $stderr'
# and add them to the big results matrix
Res = Res | res
endloop
# open a file, and write out the results
outfile "results.txt" --write
printf "%#12.6g", Res
outfile --close
</script>
Now open results.txt in your spreadsheet program. It will
have 2 * 883 rows, each pair of rows containing the coefficients
and standard errors from one of the regressions.
If you want additional information in results.txt (e.g. the
R-squared values from the regressions), or you want t-ratios
instead of standard errors, that is "left as an exercise".
Note that the operator "|" appends the right operand (matrix)
below the left operand (matrix). The operator "~" works in a
similar way but appends the second matrix to the right of the
first, "growing" it column-wise.
Allin Cottrell