-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrong type inference for square terms #244
Comments
Thanks for the report and the careful investigation! I think there's two things going on here.
Now that I think about it a bit more, I think what you're trying to do is pun on |
I'm considering only continuous data. So, I see your point that
... and the result is: NO so, maybe the "correct" way to specify a square term is to explicitly write it as |
Yup, if you want As a toy example, you might also be interested in looking at the example from the docs about how to create a "poly term" that generates [a, a^2, a^3, ..., a^n] from julia> fit(LinearModel, @formula(y ~ 1 + poly(a,2) + poly(b,2)), sim_dat)
StatsModels.TableRegressionModel{LinearModel{GLM.LmResp{Array{Float64,1}},GLM.DensePredChol{Float64,LinearAlgebra.Cholesky{Float64,Array{Float64,2}}}},Array{Float64,2}}
y ~ 1 + poly(a, 2) + poly(b, 2)
Coefficients:
──────────────────────────────────────────────────────────────────────────
Coef. Std. Error t Pr(>|t|) Lower 95% Upper 95%
──────────────────────────────────────────────────────────────────────────
(Intercept) 0.89288 0.181485 4.92 <1e-5 0.532586 1.25317
a^1 2.73324 0.349194 7.83 <1e-11 2.04001 3.42648
a^2 -1.0114 1.34262 -0.75 0.4531 -3.67684 1.65404
b^1 0.214424 0.136868 1.57 0.1205 -0.0572944 0.486142
b^2 3.15133 0.0811794 38.82 <1e-59 2.99016 3.31249
────────────────────────────────────────────────────────────────────────── or |
please read this.
Currently, formulas like
@formula(y ~ 1 + a * (a + b) + b * b)
would fail. We need to explicitly state the square terms like@formula(y ~ 1 + a + (a ^ 2) + (a & b) + b + (b ^ 2))
.It's because now term like
a & a
would has typeInteractionTerm{ContinuousTerm{Float64}}
rather thanInteractionTerm{Tuple{ContinuousTerm{Float64}, ContinuousTerm{Float64}}}
.Note that currently
InteractionTerm{ContinuousTerm{Float64}}
can not be properly handled.The text was updated successfully, but these errors were encountered: