[Gretl-users] Loop problems

Johannes Fichtinger johannes.fichtinger at wu-wien.ac.at
Thu Jul 19 13:30:12 EDT 2007


Hello everyone,

first of all, thank you a lot for that great piece of software! 

Now, I have some questions regarding the use of loops in gretl. I have some 
many datasets in one gretl file like x1 y1 x2 y2 x3 y3 ... x80 y80, where x-y 
stands for a pair of variables such that e.g. x1 is the independent, 
explanatory variable of y1, x2 explains y2 and so on.

1. First, I would like to run in a script a simple regression like:

loop i=1..80
ols $i+1 const $i
endloop

where $i+1 should be replaced in the loop with the variable y1 and $i with x1. 
Obviously, this is not working. I tried many different possibilities, but i 
did not found a solution. My problem: the variables are not really named like 
x1, y1 ..., so i can simply copy the example 9.5 in the user guide (May 2007) 
on page 55, but i need a way to access the variables by its id number and not 
the name. How can i do this?


2. Is it possible to run in a loop smth like
loop i=1..80
gnuplot $i
endloop

If I try this, he complains that the command gnuplot is not available in loop 
mode. This brings me to my last question:

Why are some commands not available in loop mode? This behaviour was somehow 
surprising for me.

Thanks,

Johannes.


More information about the Gretl-users mailing list