You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> model = glm(@formula(y~x), data)
ERROR: MethodError: no method matching fit(::Type{GeneralizedLinearModel}, ::Matrix{Float64}, ::Vector{Float64})
Closest candidates are:
fit(::Type{M}, ::AbstractMatrix{<:AbstractFloat}, ::AbstractVector{<:Real}, ::Distributions.UnivariateDistribution) where M<:GLM.AbstractGLM at ~/.julia/packages/GLM/DgddX/src/glmfit.jl:471
fit(::Type{M}, ::AbstractMatrix{<:AbstractFloat}, ::AbstractVector{<:Real}, ::Distributions.UnivariateDistribution, ::Link; dofit, wts, offset, fitargs...) where M<:GLM.AbstractGLM at ~/.julia/packages/GLM/DgddX/src/glmfit.jl:471
fit(::Type{M}, ::AbstractMatrix, ::AbstractVector, ::Distributions.UnivariateDistribution) where M<:GLM.AbstractGLM at ~/.julia/packages/GLM/DgddX/src/glmfit.jl:495
The error here was caused by forgetting to add a distribution. However, it might not be immediately clear to a user that the problem is a missing argument for glm (not fit). We could improve this by throwing an error saying glm requires a distribution.
model = glm(@formula(y~x), data, Normal)
ERROR: MethodError: no method matching fit(::Type{GeneralizedLinearModel}, ::Matrix{Float64}, ::Vector{Float64}, ::Type{Normal})
Closest candidates are:
fit(::Type{StatsBase.Histogram}, ::Any...; kwargs...) at ~/.julia/packages/StatsBase/pJqvO/src/hist.jl:383
fit(::Type{T}, ::FormulaTerm, ::Any, ::Any...; contrasts, kwargs...) where T<:RegressionModel at ~/.julia/packages/StatsModels/57Kc9/src/statsmodel.jl:78
fit(::Type{T}, ::FormulaTerm, ::Any, ::Any...; contrasts, kwargs...) where T<:StatisticalModel at ~/.julia/packages/StatsModels/57Kc9/src/statsmodel.jl:78
Passing a type rather than a distribution caused the error here, but this is also not clear for a new user.
The text was updated successfully, but these errors were encountered:
Yeah the signature of glm should be made stricter, to match that of fit. Would you make a PR?
Having a method that throws an error if a type is passed rather than an instance for the distribution could make sense. We could almost allow passing either...
The error here was caused by forgetting to add a distribution. However, it might not be immediately clear to a user that the problem is a missing argument for
glm
(notfit
). We could improve this by throwing an error sayingglm
requires a distribution.Passing a type rather than a distribution caused the error here, but this is also not clear for a new user.
The text was updated successfully, but these errors were encountered: