On Sun, 28 Dec 2014, Sven Schreiber wrote:

> Am 28.12.2014 um 20:37 schrieb Allin Cottrell:
>
>>> Arrays of strings are not the right tool for the job here; you should use
>>> lists. Suppose your "explainedVars" are all put in a list named Y and your
>>> "explanatoryVars" in a list named X. Then this would do the analysis:
>>>
>>> <hansl>
>>> loop foreach i Y -q
>>>   loop foreach j X -q
>>>     list reglist = Y[i] 0 X[j]
>>>     ols reglist
>>>  endloop
>>> endloop
>>> </hansl>
>
> (Minor point: I have to say, putting both the LHS _and_ the RHS into one
> single list for the ols command feels a little like an abuse of the
> syntax and I'm surprised gretl's not complaining about wrong number of
> arguments or something similar.)

Internally, all of gretl's basic estimation commands accept a single 
list argument for the regression specification. For the user doc we 
split this into "dependent variable" plus "independent variables" 
but supplying a single named list is OK.

>> The use of the variable "reglist" in the inner loop above ought to
>> be unnecessary, but up till now it has been required due to a little
>> bug in the interpreter. That's now fixed in CVS and snapshots, so
>> one can simply do
>>
>> ols Y[i] 0 X[j]
>
> This is interesting, I didn't know that indexing into a list like this
> is possible. It doesn't seem to be documented, or is it?

It hasn't been available for very long. I'll have to check whether 
it's actually documented.

> According to what I've learned about the 'loop foreach' construction, I
> would have done the following instead, which feels more natural to me:
>
> ols $i 0 $j

That will work, though it uses string substitution, which is 
basically evil. (Note to self: I need to write an explanation of why 
I really don't like string substitution and would like to get rid of 
it if at all possible).

Allin

Reply via email to