JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.
Other
1.08k stars 410 forks source link

add loglogistic distribution #1780

Open yunzli opened 9 months ago

yunzli commented 9 months ago

This PR adds log-logistic distribution to the package.

The log-logistic distribution has two parameters: scale and shape. It has been widely used in survival analysis.

The model implementation is in src/univariate/continuous/loglogistic.jl The test is in test/univariate/continuous/loglogistic.jl

codecov-commenter commented 9 months ago

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Files Coverage Δ
src/Distributions.jl 100.00% <ø> (ø)
src/univariates.jl 75.90% <ø> (ø)
src/univariate/continuous/loglogistic.jl 43.90% <43.90%> (ø)

... and 10 files with indirect coverage changes

:loudspeaker: Thoughts on this report? Let us know!.

ParadaCarleton commented 9 months ago

This looks like a pretty solid implementation, but I do wonder if we should be adding Log* distributions piecemeal like this, rather than providing a more general interface for transformed variables.

yunzli commented 9 months ago

This looks like a pretty solid implementation, but I do wonder if we should be adding Log* distributions piecemeal like this, rather than providing a more general interface for transformed variables.

It sounds like a very interesting idea to provide a general interface for transformed variables. But I feel there might be some difficulties. 1) commonly used parameterization might not be consistent for distribution on R and its log transformation on R+. 2) it might not be straightforward to "translate" moments. For example, Logistic(a, b) always has a mean value of a, but LogLogistic(c,d) doesn't always have a finite mean. 3) It might be redundant for users to recreate a transformation, especially for popular ones as LogNormal, LogLogistic, LogUniform, etc.