You nee to use the @ symbols to signify a string substitution. Try

ols @explainedVars[i]  @explanatoryVars[j]

Logan 
Sent from my T-Mobile 4G LTE Device


-------- Original message --------
From: Daniel Bencik <eubie@centrum.cz>
Date:12/26/2014 10:37 AM (GMT-06:00)
To: gretl-users <gretl-users@lists.wfu.edu>
Cc:
Subject: [Gretl-users] Automating regressions on various variables

Hello, 

 

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. The pseudocode should look something like this

 

strings explainedVars = array(3)

explainedVars[1] = "v1"

explainedVars[2] = "v2"

explainedVars[3] = "v3"

 

strings explanatoryVars = array(9)

explanatoryVars[1] = "v1(-1)"

explanatoryVars[2] = "v1_5(-1)"

explanatoryVars[3] = "v1_22(-1)

...

explanatoryVars[9] = "v3_22(-1)

 

loop i = 1 to 3

 loop j = 1 to 9

    ols explainedVars[i]  explanatoryVars[j]

 endloop

endloop

 

The OLS line is the one that is not working for me, I do not know how to tell the estimation command that the string explainedVars[i] should be taken as a series name. The problem is naturally a simplified version of the real problem.

 

Any help is much appreciated, 

Daniel