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

negbin fails on X, y data #455

Open
awadell1 opened this issue Nov 11, 2021 · 2 comments
Open

negbin fails on X, y data #455

awadell1 opened this issue Nov 11, 2021 · 2 comments

Comments

@awadell1
Copy link

Per the doc string: negbin(X::AbstractMatrix, y::AbstractVector, [link::Link]; <keyword arguments>) is valid however:

julia> using GLM

julia> m = negbin(ones(100,1), Int.(rand(UInt32, 100)))
ERROR: type GeneralizedLinearModel has no field model
Stacktrace:
 [1] getproperty(x::GeneralizedLinearModel{GLM.GlmResp{Vector{Float64}, Poisson{Float64}, LogLink}, GLM.DensePredChol{Float64, LinearAlgebra.Cholesky{Float64, Matrix{Float64}}}}, f::Symbol)
   @ Base ./Base.jl:33
 [2] negbin(::Matrix{Float64}, ::Vector{Int64}; initialθ::Float64, maxiter::Int64, minstepfac::Float64, atol::Float64, rtol::Float64, verbose::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GLM ~/.julia/packages/GLM/5CcRd/src/negbinfit.jl:112
 [3] negbin(::Matrix{Float64}, ::Vector{Int64})
   @ GLM ~/.julia/packages/GLM/5CcRd/src/negbinfit.jl:78
 [4] top-level scope
   @ REPL[118]:1

Issue seems to stem from negbin assuming that regmodel (Defined at Ln 105/108 in negbinfit.jl ) is a TableRegressionModel and not a GLMResp

@nalimilan
Copy link
Member

Good catch. We should indeed check the type of regmodel via something like model = regmodel isa TableRegressionModel ? regmodel.model ? model and then use only model. PR welcome.

@andreasnoack
Copy link
Member

This currently fails with

julia> m = negbin(ones(100,1), Int.(rand(UInt32, 100)))
ERROR: TypeError: in keyword argument wts, expected AbstractVector{<:Real}, got a value of type Nothing
Stacktrace:
 [1] glm(X::Matrix{…}, y::Vector{…}, args::Poisson{…}; kwargs::@Kwargs{})
   @ GLM ~/.julia/dev/GLM/src/glmfit.jl:647
 [2] negbin(::Matrix{…}, ::Vector{…}; wts::Nothing, initialθ::Float64, dropcollinear::Bool, method::Symbol, maxiter::Int64, minstepfac::Float64, atol::Float64, rtol::Float64, verbose::Bool, kwargs::@Kwargs{})
   @ GLM ~/.julia/dev/GLM/src/negbinfit.jl:110
 [3] negbin(::Matrix{Float64}, ::Vector{Int64})
   @ GLM ~/.julia/dev/GLM/src/negbinfit.jl:70
 [4] top-level scope
   @ REPL[3]:1

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

No branches or pull requests

3 participants