Open ForceBru opened 1 year ago
Hi @ForceBru
When using Lasso.jl, I noticed that to exclude the intercept, it needs to be specified as an argument in fit()
as in fit(LassoModel,...; intercept=false)
-- rather than in @formula(...)
like with GLM.jl. I haven't stepped through the source code to understand why.
I hope this helps.
Regards Patrick
Code that doesn't work
Why can I not manually specify an intercept like
@formula(x ~ 1 + y)
? The documentation?@formula
says:So
1
is a valid intercept specification, like in R. This@formula
also works inGLM.lm
.Code that works
If I write
@formula(x ~ y)
, Lasso.jl will automatically fit a model with an intercept:I assume the first coefficient is the intercept and the second one is multiplied by
y
, so the model is:So, intercepts are supported, but I can't manually specify that I want an intercept.
More code that doesn't work
Let's fit a model without an intercept. I specify this with the
0
in@formula(x ~ 0 + y)
.It seems like the package ignored the zero in the formula, fitted an intercept
-0.132743
anyway and produced the same model as above, even though the@formula
is different. R'sglmnet
supports fitting without an intercept since 2013.It would be nice if it were possible to specify the intercept in the formula.
Versions