I can think of two possible solutions to try.
1) pass the covariate names as symbols rather than strings,
e.g. probeName=:X10154
2) if you're going to pass the names as strings, try
mod=fit(lmm($(symbol(probeName)) ~ X + (1|PatientID),Data))
On Friday, September 11, 2015 at 6:18:39 AM UTC-7, Megan Smith wrote:
>
> For a statistical analysis in genomics, I need to evaluate a linear mixed
> effects model hundreds of thousands of times. I want to fit the model
>
> mod=fit(lmm(Y ~ X + (1|PatientID),Data))
>
> repeatedly in a loop with different outcome variables "Y" each time. I
> want to have the variable names for Y as arguments in the outside function,
> and this would require me to evaluate Y within the formula to fit the
> model. Does anyone know how I can do this?
>
> The problem I'm having is getting the Formula type to evaluate variables.
> For example, I want to fit
> mod=fit(lmm(X10154 ~ X + (1|PatientID),Data))
> inside a function that has the string variable probeName="X10154" as an
> argument of type UTF8String. How can I call X10154 within the formula?
>
> The line mod=fit(lmm(X10154 ~ X + (1|PatientID),Data)) works.
>
> However things like the following do not work and yield errors.
>
> mod=fit(lmm(probeName ~ X + (1|PatientID),Data))
>
> *ERROR: key not found: :probeName*
>
>
> mod=fit(lmm($probeName ~ X + (1|PatientID),Data))
>
> *ERROR: `convert` has no method matching
> convert(::Type{Union(Nothing,Expr,Symbol)}, ::UTF8String)*
>
> * in Formula at no file*
>
>
> Thanks
>
>
>