Technically you *can* do the following:
@eval $(Symbol("logit_", outcomes[i], "_unadjusted")) = [... fix the RHS
too]
But IMHO programming like this is kind of discouraged. (for one thing,
undisciplined use can lead to big speed traps). An alternative is to hold a
string-addressable handle to results in a dictionary or a DataFrame.
On Fri, Jul 8, 2016 at 3:26 PM, Min-Woong Sohn <[email protected]> wrote:
> I am trying to run logistic regressions on a bunch of dependent variables
> like so:
>
> using GLM
>
> outcomes = [:mort30d, :readmit, :reoper, :sar]
>
> for i in 1:length(outcomes)
> logit_$(outcomes[i])_unadjusted = glm($(outcomes[i]) ~ race, puf,
> Binomial(),LogitLink())
> dump(coef(logit_$(outcomes[i])_unadjusted))
> end
>
> Here I want to run the logistic regression four times, once for each
> outcome, and save the return values into four different memory objects:
>
> logit_mort30d_unadjusted
> logit_readmit_unadjusted
> etc
>
> The glm... part works fine with the interpolation, $(outcomes[i]), but I
> cannot create the memory objects in this way. Is there any way I can use
> some method of string interpolation to this end?
>
>
>
>