| Title: | Tweedie Distribution |
|---|---|
| Description: | Provides density, distribution function, quantile function, and random generation for the Tweedie distribution under the compound Poisson-Gamma parameterisation with power parameter in (1, 2). The density is evaluated using the series expansion of Dunn and Smyth (2005) <doi:10.1007/s11222-005-4070-y>, implemented in C++ via 'Rcpp' and 'RcppArmadillo' for performance. A constructor compatible with the distributional package is also provided for use in tidy modelling workflows. |
| Authors: | Stefano Damato [aut, cre] |
| Maintainer: | Stefano Damato <[email protected]> |
| License: | LGPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-07-15 20:47:15 UTC |
| Source: | https://github.com/cran/tweedieDistr |
Construct a Tweedie distribution object using the compound Poisson–Gamma
parameterisation with power parameter in . The Tweedie family
is a subclass of exponential dispersion models that naturally produces exact
zeros (via the Poisson count component) mixed with continuous positive
values (via the Gamma severity component), making it well suited to
intermittent demand data.
dist_tweedie(mean = 1, dispersion = 1, power = 1.5)dist_tweedie(mean = 1, dispersion = 1, power = 1.5)
mean |
Mean parameter |
dispersion |
Dispersion parameter |
power |
Power parameter |
The density is evaluated using the series expansion of Dunn & Smyth (2005), implemented in C++ for performance.
A distributional distribution object of class dist_tweedie.
Dunn, P. K., & Smyth, G. K. (2005). Series evaluation of Tweedie exponential dispersion model densities. Statistics and Computing, 15(4), 267–280. doi:10.1007/s11222-005-4070-y.
d <- dist_tweedie(mean = 2, dispersion = 0.8, power = 1.5) d |> mean() d |> quantile(c(0.5, 0.9)) d |> density(c(0, 1.5, 3)) d |> distributional::variance() d |> distributional::generate(10)d <- dist_tweedie(mean = 2, dispersion = 0.8, power = 1.5) d |> mean() d |> quantile(c(0.5, 0.9)) d |> density(c(0, 1.5, 3)) d |> distributional::variance() d |> distributional::generate(10)
Density, distribution function, quantile function and random generation for
the Tweedie distribution with mean equal to mean, dispersion equal to
dispersion, and power equal to power.
rtweedie(n, mean = 1, dispersion = 1, power = 1.5) dtweedie(x, mean = 1, dispersion = 1, power = 1.5, log = FALSE) ptweedie( q, mean = 1, dispersion = 1, power = 1.5, lower.tail = TRUE, log.p = FALSE ) qtweedie( p, mean = 1, dispersion = 1, power = 1.5, lower.tail = TRUE, log.p = FALSE )rtweedie(n, mean = 1, dispersion = 1, power = 1.5) dtweedie(x, mean = 1, dispersion = 1, power = 1.5, log = FALSE) ptweedie( q, mean = 1, dispersion = 1, power = 1.5, lower.tail = TRUE, log.p = FALSE ) qtweedie( p, mean = 1, dispersion = 1, power = 1.5, lower.tail = TRUE, log.p = FALSE )
n |
number of observations. If |
mean |
vector of means. |
dispersion |
vector of dispersion parameters. |
power |
vector of power parameters. |
x, q
|
vector of quantiles. |
log, log.p
|
logical; if |
lower.tail |
logical; if |
p |
vector of probabilities. |
If mean, dispersion, or power are not specified they assume the
default values of 1, 1, and 1.5, respectively.
The Tweedie distribution used here follows the compound Poisson-Gamma
parameterisation with power parameter in . It has
and
, where is mean,
is dispersion, and is power.
dtweedie gives the density, ptweedie gives the distribution
function, qtweedie gives the quantile function, and rtweedie
generates random samples.
The length of the result is determined by n for rtweedie, and is the
maximum of the lengths of the numerical arguments for the other functions.
The numerical arguments other than n are recycled to the length of the
result. Only the first elements of the logical arguments are used.
Dunn, P. K., & Smyth, G. K. (2005). Series evaluation of Tweedie exponential dispersion model densities. Statistics and Computing, 15(4), 267–280. doi:10.1007/s11222-005-4070-y.