# Using all independent variables with @formula in a multiple linear model

**URL:** <https://discourse.julialang.org/t/using-all-independent-variables-with-formula-in-a-multiple-linear-model/43691>\
**Category:** New to Julia\
**Tags:** glm\
**Created:** [July 26, 2020, 1:22am UTC](https://discourse.julialang.org/t/using-all-independent-variables-with-formula-in-a-multiple-linear-model/43691 "2020-07-26T01:22:04Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![pauloat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauloat/32/16517_2.png) [@pauloat](https://discourse.julialang.org/u/pauloat)\
**Post date:** [July 26, 2020, 9:19pm UTC](https://discourse.julialang.org/t/using-all-independent-variables-with-formula-in-a-multiple-linear-model/43691/3 "2020-07-26T21:19:17Z")

</div>

Edit2: Ok, is working now but I need to use your solution in the in the lm() directly, instead of being able to create a @formula variable. would be nice to be able to do a @formula variable, specially for cross validation and other that need to work with that. But for the time being, thank you again.

Thanks, it was give me an error:

> LoadError: ArgumentError: non-call expression encountered: Term.(Symbol.(names(df[:, Not(:Y])))

~~but I solve it creating a variable with the sum of the independent variables like this~~

> ~~IndependVars = sum(Term.(Symbol.(names(df[:, Not(:Y)]))))~~

~~and using it as~~

> ~~fm = @formula(Y ~ IndependVars)~~

edit: my solution is not working, the lm thinks that IndependVars is a column in my df…

---

_[View the full topic](https://discourse.julialang.org/t/using-all-independent-variables-with-formula-in-a-multiple-linear-model/43691)._
