Learn R Programming

tweedie (version 3.2.2)

dtweedie_series: Series Evaluation for the Tweedie Probability Function

Description

Evaluates the probability density function (pdf) for Tweedie distributions using an infinite series, for given values of the dependent variable y, the mean mu, dispersion phi, and power parameter power. Not usually called by general users, but can be used in the case of evaluation problems.

Usage

dtweedie_series(y, power, mu, phi, details = FALSE)

dtweedie.series(y, power, mu, phi)

Value

A numeric vector of probabilities.

Arguments

y

vector of quantiles.

power

scalar; the value of \(p\) such that the variance is \(\mbox{var}[Y]=\phi\mu^{p}\).

mu

vector of mean \(\mu\).

phi

vector of dispersion parameters \(\phi\).

details

logical; if TRUE, returns a list: the density (density), its logarithm (logf, computed without underflow), an estimate of its relative error from rounding (relerr; for \(p > 2\), where the series alternates in sign; zero otherwise), and the range of terms summed (lo, hi).

Accuracy

For \(1 < p < 2\), the terms of the series are all positive, and the density keeps full relative accuracy. For \(p > 2\), the terms alternate in sign, and rounding error can cancel many digits. An estimate of the resulting relative error is returned (as relerr) when details = TRUE; no warning is given for a large estimated error. Where the series cannot be summed at all, NaN is returned with a warning. dtweedie() uses the series for \(p > 2\) only where this estimated relative error is below \(10^{-12}\).

References

Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267--280. tools:::Rd_expr_doi("10.1007/s11222-005-4070-y")

Examples

Run this code
# Plot a Tweedie density
y <- seq(0.01, 4, length = 50)
fy <- dtweedie_series(y, power = 1.1, mu = 1, phi = 1)
plot(y, fy, type = "l", lwd = 2, ylab = "Density")

Run the code above in your browser using DataLab