Conversation
This distribution is tricky to implement as there is no closed form for most functions. PDF is computed based on `wrightbessel`. CDF and quantile are computed numerically. Performance is similar to reference R package tweedie. When `1 < p < 2` it is continuous but with a point mass at zero so it is not completely correct to consider it a `ContinuousUnivariateDistribution`. When `p = 1` it is even discrete.
|
Tests fail currently. |
| Tweedie(μ::Integer, σ::Integer, p::Integer; check_args::Bool=true) = | ||
| Tweedie(float(μ), float(σ), float(p); check_args=check_args) |
There was a problem hiding this comment.
Not needed?
| Tweedie(μ::Integer, σ::Integer, p::Integer; check_args::Bool=true) = | |
| Tweedie(float(μ), float(σ), float(p); check_args=check_args) |
There was a problem hiding this comment.
I copied this from Normal. Not sure why it does that.
| Tweedie(float(μ), float(σ), float(p); check_args=check_args) | ||
|
|
||
| #### Conversions | ||
| convert(::Type{Tweedie{T}}, μ::S, σ::S, p::S) where {T <: Real, S <: Real} = Tweedie(T(μ), T(σ), T(p)) |
There was a problem hiding this comment.
IMO no such method should be defined - users should use the constructor:
| convert(::Type{Tweedie{T}}, μ::S, σ::S, p::S) where {T <: Real, S <: Real} = Tweedie(T(μ), T(σ), T(p)) |
There was a problem hiding this comment.
This also comes from Normal (also exists for other distributions). It makes sense IMO at least in theory, e.g. if you want to store such an object in a field with a different T. Though in practice it's probably not super common.
|
Thanks for the review! I will address your comments. Note that CI will fail until JuliaMath/SpecialFunctions.jl#512 is merged and released (which isn't a small task...). |
| #### Statistics | ||
|
|
||
| mean(d::Tweedie) = d.μ | ||
| mean(d::Tweedie) = float(d.μ) |
There was a problem hiding this comment.
float seems to make more sense to me here for as e.g. rand(Tweedie{Int}(1, 2, 2)) generates float values and not integers.
This distribution is tricky to implement as there is no closed form for most functions. PDF is computed based on
wrightbessel(JuliaMath/SpecialFunctions.jl#512). CDF and quantile are computed numerically from PDF. Performance is similar to reference R package tweedie.When
1 < p < 2it is continuous but with a point mass at zero so it is not completely correct to consider it aContinuousUnivariateDistribution. Whenp = 1it is even discrete. However I wasn't sure that justifies adding a new type likeSemiContinuousUnivariateDistribution.This distribution is useful to allow estimating Tweedie models in GLM.