Say I have a DataFrame called mydata where names(mydata) is Symbol[5001] consisting of :y, :x1, :x2, :x3, :x4, … (the other 4995 symbols) … , :x5000.

I want to fit models with the formula ModelFrame(y ~ x1, mydata), ModelFrame(y ~ x2, mydata), etc. until ModelFrame(y ~ x5000, mydata). ModelFrame can be switched to glm or lmm as I believe they use the same formula.jl code.

How do I create a model such that I can do something like ModelFrame(y ~ names(mydata)[x], mydata) where x is any number? This would allow looping over variables. However, I’m not really sure what type of variable is being given after the tilde because ModelFrame(y ~ names(mydata)[2], mydata), ModelFrame(y ~ Symbol(:x1), mydata), or ModelFrame(y ~“x1”, mydata) don’t work.