The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Package {tweedieDistr}


Title: Tweedie Distribution
Version: 0.1.0
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.
License: LGPL (≥ 3)
URL: https://github.com/StefanoDamato/tweedieDistr
BugReports: https://github.com/StefanoDamato/tweedieDistr/issues
Encoding: UTF-8
RoxygenNote: 7.3.3
Depends: R (≥ 4.1.0)
Imports: distributional, Rcpp, rlang, stats
LinkingTo: Rcpp, RcppArmadillo
Suggests: ggdist, ggplot2, testthat (≥ 3.0.0), tibble, tweedie
Config/testthat/edition: 3
NeedsCompilation: yes
Packaged: 2026-07-06 14:10:52 UTC; stefano.damato
Author: Stefano Damato [aut, cre]
Maintainer: Stefano Damato <stefanodamato128@gmail.com>
Repository: CRAN
Date/Publication: 2026-07-15 17:50:02 UTC

tweedieDistr: Tweedie Distribution

Description

logo

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.

Author(s)

Maintainer: Stefano Damato stefanodamato128@gmail.com

See Also

Useful links:


Tweedie Distribution

Description

Construct a Tweedie distribution object using the compound Poisson–Gamma parameterisation with power parameter in (1, 2). 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.

Usage

dist_tweedie(mean = 1, dispersion = 1, power = 1.5)

Arguments

mean

Mean parameter \mu > 0.

dispersion

Dispersion parameter \phi > 0.

power

Power parameter p \in (1, 2).

Details

The density is evaluated using the series expansion of Dunn & Smyth (2005), implemented in C++ for performance.

Value

A distributional distribution object of class dist_tweedie.

References

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.

Examples

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)

Tweedie Distribution Functions

Description

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.

Usage

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
)

Arguments

n

number of observations. If length(n) > 1, the length is taken to be the number required.

mean

vector of means.

dispersion

vector of dispersion parameters.

power

vector of power parameters.

x, q

vector of quantiles.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P[X \le x]; otherwise, P[X > x].

p

vector of probabilities.

Details

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 (1, 2). It has \mathbb{E}[X] = \mu and \mathrm{Var}(X) = \phi\mu^p, where \mu is mean, \phi is dispersion, and p is power.

Value

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.

References

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.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.