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

Regression should accept vectors #39

Closed
tbreloff opened this issue Oct 9, 2015 · 2 comments
Closed

Regression should accept vectors #39

tbreloff opened this issue Oct 9, 2015 · 2 comments

Comments

@tbreloff
Copy link
Collaborator

tbreloff commented Oct 9, 2015

I was surprised that this wasn't allowed:


julia> using OnlineStats

julia> LinReg(randn(100),randn(100))
ERROR: MethodError: `convert` has no method matching convert(::Type{OnlineStats.LinReg{W<:OnlineStats.Weighting}}, ::Array{Float64,1}, ::Array{Float64,1})
This may have arisen from a call to the constructor OnlineStats.LinReg{W<:OnlineStats.Weighting}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  OnlineStats.LinReg(::AbstractArray{Float64,2}, ::AbstractArray{Float64,1})
  OnlineStats.LinReg(::AbstractArray{Float64,2}, ::AbstractArray{Float64,1}, ::OnlineStats.Weighting)
  call{T}(::Type{T}, ::Any)
  ...
 in call at essentials.jl:57

julia> LinReg(randn(100,1),randn(100))
OnlineStat: OnlineStats.LinReg{OnlineStats.EqualWeighting}
 *        β:  [0.06140403868184703]
 *     nobs:  100

We should make sure both vectors and matrices are handled as expected.

@joshday
Copy link
Owner

joshday commented Oct 9, 2015

I'm not completely sure this is unexpected. A quick survey shows the following require x to be a Matrix:

GLM.lm(x,y)
Regression.linearreg(x,y)
GLMNet.glmnet(x,y) 
MultivariateStats.llsq(x,y)

This also only happens if you're fitting a line without an intercept, since LinReg doesn't add one for you, although maybe it should.

@joshday
Copy link
Owner

joshday commented Sep 14, 2016

I'd rather force users into doing x = view(randn(100), :, :) or similar. I think the issue is rare enough that I'd rather not add extra constructor/fit! methods for LinReg, QuantReg, and StatLearn.

@joshday joshday closed this as completed Sep 14, 2016
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

2 participants