On Sun, 28 Dec 2014, Allin Cottrell wrote:
On Fri, 26 Dec 2014, Daniel Bencik wrote:
> I have several measures of volatility v1, v2, v3 and their 5-day and
> 22-day averages (v1_5, v1_22, etc.) loaded into the session. What I would
> like is to write a loop over the explained and explanatory variables so
> that I have one code for OLS estimation into which I just feed different
> data. [...]
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>
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]
in a construction such as the one shown above.
Allin Cottrell