dtweedie {tweedie} | R Documentation |
Density, distribution function, quantile function and random generation for the Tweedie distributions
dtweedie(y, power, mu, phi) dtweedie.series(y, power, mu, phi) dtweedie.inversion(y, power, mu, phi, exact=FALSE, rotate=TRUE) ptweedie(q, power, mu, phi) ptweedie.series(q, power, mu, phi) qtweedie(p, power, mu, phi) rtweedie(n, power, mu, phi)
y, q |
vector of quantiles |
p |
vector of probabilities |
n |
the number of observations |
power |
the value of power such that the variance is var(Y) = phi * mu^power |
mu |
the mean |
phi |
the dispersion |
exact |
logical flag;
if TRUE ,
the exact zero W-algorithm of Sidi (1982) is used.
If FALSE (the default),
the (approximate zero) modified W-algorithm of Sidi (1988) is used.
The modified algorithm requires less computation but is often less accurate;
the exact zero W-algorithm can be slower but generally improves accuracy.
|
rotate |
logical flag;
if TRUE (the default),
the algorithm rotates before inverting the solution,
which has the effect of increasing the relative accuracy. |
The Tweedie family of distributions belong to the class
of exponential dispersion models (EDMs),
famous for their role in generalized linear models.
The Tweedie distributions are the EDMs with a variance of the form
var(Y) = phi * mu^power
where power is greater than or equal to one, or less than or equal to zero.
This function only evaluates for power
greater than or equal to one.
Special cases include the
normal (power=0),
Poisson (power=1 with phi=1),
gamma (power=2)
and
inverse Gaussian (power=3)
distributions.
For other values of power
,
the distributions are still defined but cannot be written in closed form,
and hence evaluation is very difficult.
When 1 < power < 2, the distribution are continuous for Y greater than zero, with a positive mass at Y=0. For power > 2, the distributions are continuous for Y greater than zero.
This function evaluates the density or cumulative probability using one of two methods, depending on the combination of parameters. One method is the evaluation of an infinite series. The second interpolates some stored values computed from a Fourier inversion technique.
The function dtweedie.inversion
evaluates the density using a Fourier series technique;
ptweedie.inversion
does likewise for the cumulative
probabilities.
The actual code is contained in an external FORTRAN program.
Different code is used for power > 2
and for 1 < power < 2.
The function dtweedie.series
evaluates the density
using a series expansion;
a different series expansion
is used for power > 2 and for 1 < power < 2.
The function ptweedie.series
does likewise for the
cumulative probabilities but only for 1 < power < 2.
The function dtweedie
uses a two-dimensional interpolation procedure to
compute the density for some parts of the parameter space from
previously computed values found from the series or the
inversion. For other parts of the parameter space,
the series solution is found.
ptweedie
returns either the computed series
solution or inversion solution.
density (dtweedie
),
probability (ptweedie
),
quantile (qtweedie
)
or random sample (rtweedie
)
for the given Tweedie distribution with parameters
mu
,
phi
and
power
.
Peter Dunn (dunn@usq.edu.au)
Dunn, Peter K and Smyth, Gordon K (To appear). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing.
Dunn, Peter K and Smyth, Gordon K (2001). Tweedie family densities: methods of evaluation. Proceedings of the 16th International Workshop on Statistical Modelling, Odense, Denmark, 2–6 July
Jorgensen, B. (1987). Exponential dispersion models. Journal of the Royal Statistical Society, B, 49, 127–162.
Jorgensen, B. (1997). Theory of Dispersion Models. Chapman and Hall, London.
Sidi, Avram (1982). The numerical evaluation of very oscillatory infinite integrals by extrapolation. Mathematics of Computation 38(158), 517–529.
Sidi, Avram (1988). A user-friendly extrapolation method for oscillatory infinite integrals. Mathematics of Computation 51(183), 249–266.
Tweedie, M. C. K. (1984). An index which distinguishes between some important exponential families. Statistics: Applications and New Directions. Proceedings of the Indian Statistical Institute Golden Jubilee International Conference (Eds. J. K. Ghosh and J. Roy), pp. 579-604. Calcutta: Indian Statistical Institute.
### Plot a Tweedie density power <- 2.5 mu <- 1 phi <- 1 y <- seq(0, 10, length=100) fy <- dtweedie( y=y, power=power, mu=mu, phi=phi) plot(y, fy, type="l") # Compare to the saddlepoint density f.saddle <- dtweedie.saddle( y=y, power=power, mu=mu, phi=phi) lines( y, f.saddle, col=2 ) ### A histogram of Tweedie random numbers hist( rtweedie( 1000, power=1.2, mu=1, phi=1) ) ### An example of the multimodal feature of the Tweedie ### family with power near 1 (from the first reference ### listed above). y <- seq(0.001,2,len=1000) mu <- 1 phi <- 0.1 p <- 1.02 f1 <- dtweedie(y,mu=mu,phi=phi,power=p) plot(y, f1, type="l", xlab="y", ylab="Density") p <- 1.05 f2<- dtweedie(y,mu=mu,phi=phi,power=p) lines(y,f2, col=2)