GLM.jl
GLM.jl copied to clipboard
negbin fails on X, y data
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
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.