tweedieDistr provides density, distribution function, quantile
function, and random generation for the Tweedie distribution under
the compound Poisson-Gamma parameterisation with power parameter
We provide four stats-like functions:
dtweedie(): probability density function via the series expansion of Dunn & Smyth (2005).ptweedie(): cumulative distribution function using a truncated compound Poisson-Gamma summation.qtweedie(): quantile function via Newton-Raphson algorithm, with a fallback to bisection.rtweedie(): random generation via the exact compound Poisson–Gamma representation.
You can install the stable version from CRAN:
install.packages("tweedieDistr")You can install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("StefanoDamato/tweedieDistr")The four dtweedie / ptweedie / qtweedie / rtweedie functions
mirror the conventions of base R distribution functions and support
vectorised arguments.
library(tweedieDistr)
# density at a few points
dtweedie(c(0, 1, 2, 3), mean = 1, dispersion = 2, power = 1.2)
#> [1] 0.53526143 0.18138057 0.14514878 0.07404391
# cumulative probabilities
ptweedie(c(0, 1, 2, 3), mean = 1, dispersion = 2, power = 1.2)
#> [1] 0.5352614 0.6168058 0.7952006 0.9014508
# quantiles
qtweedie(c(0.25, 0.5, 0.75, 0.9), mean = 1, dispersion = 2, power = 1.2)
#> [1] 0.000000 0.000000 1.713588 2.980538
# random samples
rtweedie(4, mean = 1, dispersion = 2, power = 1.2)
#> [1] 0.6454074 0.0000000 1.0381130 0.0000000The Tweedie distribution
with
The distribution has mean
![]() Stefano Damato (Maintainer) |
If you encounter a bug, please file a minimal reproducible example on GitHub.
Dunn, P. K., & Smyth, G. K. (2005). Series evaluation of Tweedie exponential dispersion model densities. Statistics and Computing, 15(4), 267–280. https://doi.org/10.1007/s11222-005-4070-y.

