[Gretl-users] how to run multiple regressions at one time

Allin Cottrell cottrell at wfu.edu
Thu Jan 29 16:30:20 EST 2009


On Thu, 29 Jan 2009, Sven Schreiber wrote:

> Am 29.01.2009 00:44, Riccardo (Jack) Lucchetti schrieb:
>
> >
> > How about this?
> >
> > <script>
> > list Y = y1 y2 y3
> > loop foreach i Y
> >   ols Y.$i const x1 x2
> > end loop
> > </script>
>
> I must say I find this $i business confusing; fortunately it's
> very well documented in the manual!
>
> At some point IMHO it may be worthwhile to think about a syntax
> reform; here it's not clear (to me) what the variable type of
> the loop index i actually is.

It's a scalar (usually an integer, and for sure an integer in a
"foreach" loop); really could not be anything else. The variable
'i' is always accessible within a loop, in scalar contexts, as in

 print i
 X[i] = foo

and so on.

In a "foreach" loop the '$i' construction works by lookup:  it
indexes into the relevant array of strings or variable names and
returns entry i at iteration i.

In other sorts of loops, '$i' just gives the string representation
of the current index value, as if you had done

  sprintf foo "%d", i

Allin.


More information about the Gretl-users mailing list