“Fit a statistical model.
“””
fit(model::StatisticalModel, args…) = error(“fit is not defined for $(typeof(model)).”)"
I can’t find the use or programming of the fit function anywhere else in this documentation nor in the StatsModels documentation. This function came along with Julia or am I missing something?
julia> @which fit(Histogram, rand(100))
fit(::Type{Histogram}, args...; kwargs...) in StatsBase at C:\Users\woclass\.julia\packages\StatsBase\Q76Ni\src\hist.jl:383
julia> @which fit(ZScoreTransform, rand(100))
fit(::Type{ZScoreTransform}, X::AbstractVector{var"#s258"} where var"#s258"<:Real; dims, center, scale) in StatsBase at C:\Users\woclass\.julia\packages\StatsBase\Q76Ni\src\transformations.jl:130
julia> @which fit(UnitRangeTransform, rand(100))
fit(::Type{UnitRangeTransform}, X::AbstractVector{var"#s130"} where var"#s130"<:Real; dims, unit) in StatsBase at C:\Users\woclass\.julia\packages\StatsBase\Q76Ni\src\transformations.jl:287
fit(model::StatisticalModel, args...) = error("fit is not defined for $(typeof(model)).")
The definition here is more like a fallback method.
If the input param type does not have a fit function defined on it will throw an error.