You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently formulas are constructed using @~, which as far as I know is Julia's only infix macro. This allows us to mirror R's formulas, which take advantage of R's nonstandard evaluation, and avoid prefixing variable names with :.
However, this is a special case that Julia makes in parsing that it—at least in my opinion—shouldn't have to do to allow Julia to look like R in one scenario. It would be nice if Julia could avoid having to parse anything as an infix macro. Plus, there surely is a more Julian approach!
A solution
A while back, @dmbates suggested on the mailing list that we replace our current formula syntax with Pairs. Based on my understanding, this would look like :y => :(1 + x1 + x2). @StefanKarpinski alternatively suggested the use of a @model macro, which would take an expression and construct a formula or model object, which could then be passed to fit or what have you. I imagine this looking something like
fit(LinearRegressionModel, @model y ~1+ x1 + x2, ...)
This approach allows any separator for the dependent and independent variables, not just ~, since it simply becomes the head in the resulting Expr. We could even use = for a more SAS-like aesthetic, or => as in Pairs.
A call to action
As we're transitioning the modeling functionality out of DataFrames.jl and into its own package (this one!), we have the opportunity to revisit some design decisions such as this. What do you all think? Should we leave things as-is or blaze a new trail?
The text was updated successfully, but these errors were encountered:
I like the @model macro: it makes it very clear what the intent of the formula is (to represent a model), thus potentially heading off some of the "punning" on ~ in R as a generic quotation operator.
Unless I'm misunderstanding something, we'd still need some kind of macro to use pairs. Or require that people make sure that both sides are quoted, like :y => :(1+x), which feels clunky to me, and more importantly potentially confusing to users ("why do I need a :y on the left but x on the right??")
What we have
Currently formulas are constructed using
@~
, which as far as I know is Julia's only infix macro. This allows us to mirror R's formulas, which take advantage of R's nonstandard evaluation, and avoid prefixing variable names with:
.However, this is a special case that Julia makes in parsing that it—at least in my opinion—shouldn't have to do to allow Julia to look like R in one scenario. It would be nice if Julia could avoid having to parse anything as an infix macro. Plus, there surely is a more Julian approach!
A solution
A while back, @dmbates suggested on the mailing list that we replace our current formula syntax with
Pair
s. Based on my understanding, this would look like:y => :(1 + x1 + x2)
. @StefanKarpinski alternatively suggested the use of a@model
macro, which would take an expression and construct a formula or model object, which could then be passed tofit
or what have you. I imagine this looking something likeThis approach allows any separator for the dependent and independent variables, not just
~
, since it simply becomes thehead
in the resultingExpr
. We could even use=
for a more SAS-like aesthetic, or=>
as inPair
s.A call to action
As we're transitioning the modeling functionality out of DataFrames.jl and into its own package (this one!), we have the opportunity to revisit some design decisions such as this. What do you all think? Should we leave things as-is or blaze a new trail?
The text was updated successfully, but these errors were encountered: