Skip to content
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

lm(X,y) supports y as integer, but not X #84

Closed
setzler opened this issue Aug 26, 2014 · 3 comments
Closed

lm(X,y) supports y as integer, but not X #84

setzler opened this issue Aug 26, 2014 · 3 comments

Comments

@setzler
Copy link
Contributor

setzler commented Aug 26, 2014

Currently, lm(X,y) has asymmetric type support - y can be integer, X cannot. Please permit X as integer type. Example of the issue:

julia> y
3-element Array{Int64,1}:
2
4
6

julia> X
3x1 Array{Int64,2}:
1
2
3

julia> lm(X,y)
ERROR: DensePredQR{T<:Union(Float64,Float32)} has no method matching DensePredQR{T<:Union(Float64,Float32)}(::Array{Int64,2})

julia> X
3x1 Array{Float64,2}:
1.0
2.0
3.0

julia> lm(X,y)
LinearModel{DensePredQR{Float64}}:

Coefficients: Estimate Std.Error t value Pr(>|t|)
x1 2.0 3.84593e-16 5.20031e15 <1e-31

@pkofod
Copy link
Contributor

pkofod commented Feb 29, 2016

This issue is now different.

 lm(rand(Int64, 4,2), rand(Int64, 4))
 lm(rand(4,2), rand(Int64, 4))
 lm(rand(Int64, 4,2), rand(4))

Neither work, but this works

 lm(rand(4,2), rand(4))

So either this issue is solved by requiring all floats, or it has expanded and now y can't be Integer either. This is in contrast to the fact that all these work

 glm(rand(Int64, 4,2), rand(Int64, 4), Normal(), IdentityLink())
 glm(rand(4,2), rand(Int64, 4), Normal(), IdentityLink())
 glm(rand(Int64, 4,2), rand(4), Normal(), IdentityLink())
 glm(rand(4,2), rand(4), Normal(), IdentityLink())

@nalimilan
Copy link
Member

This works because fit for AbstractGLM has a generic method which calls float on the two vectors. Should be easy to add for linear models too.

@pkofod
Copy link
Contributor

pkofod commented Feb 29, 2016

I see it. I'll make a PR harmonizing glm and lm fit methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants