Evaluates the distribution function (df) for Tweedie distributions
with \(1 < p < 2\)
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 in the case of evaluation problems.
ptweedie_series(q, power, mu, phi, lower.tail = TRUE, log.p = FALSE,
verbose = FALSE, details = FALSE, max.terms = 1e6)ptweedie.series(q, power, mu, phi, verbose = FALSE, details = FALSE)
A numeric vector of probabilities (or log-probabilities, if log.p = TRUE).
vector of quantiles.
the power parameter \(p\).
the mean parameter \(\mu\).
the dispersion parameter \(\phi\).
logical; if TRUE (the default), computes \(F(y)=\Pr(Y\le y)\);
if FALSE, computes the upper tail \(S(y)=\Pr(Y>y)\) directly, rather than as
1 - ptweedie_series(...).
logical; if TRUE, the logarithm of the probability is returned,
computed directly via log-sum-exp accumulation over the series terms rather than as
log(ptweedie_series(...)). This retains accuracy even when the probability
itself would underflow to zero.
logical; if TRUE, displays some internal computation details.
The default is FALSE.
logical; if TRUE, returns the value of the distribution function
and some details.
integer; the maximum number of terms summed for each value before the
summing is truncated, and a warning produced. The default is 1e6, enough for
\(\lambda\) up to about \(4\times 10^9\); each extra million terms takes
about half a second per value.
The terms of the series are all positive, and are summed on the log scale, so
both tails keep full relative accuracy, far into the tails.
The only limitation is the number of terms: if more than max.terms are
needed (when \(\lambda\) is very large), the series is truncated and a
warning is given.
Dunn, Peter K and Smyth, Gordon K (Submitted). Evaluation of the Tweedie exponential dispersion model distribution function. Submitted.
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")
# Plot a Tweedie distribution function
y <- seq(0.01, 4, length = 50)
Fy <- ptweedie_series(y, power = 1.1, mu = 1, phi = 1)
plot(y, Fy, type = "l", lwd = 2, ylab = "Distribution function")
Run the code above in your browser using DataLab