-
Notifications
You must be signed in to change notification settings - Fork 114
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
linear model with Float32 #260
Comments
The code probably needs some tweaks to be more generic. PR welcome. |
@kleinschmidt Is it on purpose that the model matrix promotes to It's worth noticing that |
I don't know actually...I suspect it was just a sensible default. I think it could be overridden by specifying I'm not super inclined to do the deep dive in the current StatsModels code to fix this though given that (inshallah) that's going to be replaced by Terms 2.0 (JuliaStats/StatsModels.jl#71). |
It's also hard to handle this in a sufficiently general way since you might have a categorical variable that gets expanded according to a contrasts matrix; that defaults to Float64, so you'd somehow have to figure out to un-promote that to Float32 in the case when the only continuous variables are Float32s. |
Also to clarify what @andreasnoack said: this is an issue with StatsModels (which handles the formula), not with GLM. |
I just encountered the same issue. This problem occurs when reading data from Stata's |
Glad the other lm function with no formula works with Float32. I would not put the function with formula on doc if it doesn' t work with such a basic data type. Is it a good time to fix this? |
I guess the question is, what should GLM do when it gets a I'd suggest something like a promotion (or at least an eltype check) in Line 129 in 468d0f8
|
Ahahaha yes here's exactly what I was talking about...statsmodels doctests picked up this (lack of Bool-to-Float64 conversion): https://github.com/JuliaStats/StatsModels.jl/actions/runs/5095234337/jobs/9159967200?pr=294#step:5:305 |
Hi GLM,
I am trying to use the lm function with the following command:
mydata = DataFrame(X=MyDataType.(1:3), Y=MyDataType.(11:13)); lm(@formula(Y ~ 1 + X), mydata)
This works fine with
MyDataType = Float64
orInt32
andInt64
but withFloat32
I get the following error:My environment is the following:
The text was updated successfully, but these errors were encountered: