| Title: | Evaluation of Tweedie Exponential Family Models |
|---|---|
| Description: | Maximum likelihood computations for Tweedie families, including the series expansion (Dunn and Smyth, 2005; <doi:10.1007/s11222-005-4070-y>) and the Fourier inversion (Dunn and Smyth, 2008; <doi:10.1007/s11222-007-9039-6>), and related methods. |
| Authors: | Peter K. Dunn [cre, aut] |
| Maintainer: | Peter K. Dunn <[email protected]> |
| License: | GPL (>=2) |
| Version: | 3.1.0 |
| Built: | 2026-05-24 23:08:58 UTC |
| Source: | https://github.com/peterkdunn/tweedie |
This package provides maximum likelihood computations for Tweedie families, including the series expansion (Dunn and Smyth, 2005) and the Fourier inversion (Dunn and Smyth, 2008), and related methods.
Maintainer: Peter K. Dunn [email protected]
Evaluates the probability density function (pdf) for Tweedie distributions using Fourier inversion,
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.
dtweedie_inversion(y, mu, phi, power, method = 3, verbose = FALSE, details = FALSE, IGexact = TRUE) dtweedie.inversion(y, power, mu, phi, method = 3, verbose, details)dtweedie_inversion(y, mu, phi, power, method = 3, verbose = FALSE, details = FALSE, IGexact = TRUE) dtweedie.inversion(y, power, mu, phi, method = 3, verbose, details)
y |
vector of quantiles. |
mu |
the mean parameter |
phi |
the dispersion parameter |
power |
scalar; the power parameter |
method |
the method to use; one of |
verbose |
logical; if |
details |
logical; if |
IGexact |
logical; if |
A numeric vector of densities if details=FALSE; if details = TRUE, a list containing denisty (a vector of the values of the density), regions (a vector of the number of integration regions used),method (a vector giving the evaluation method used; see the Note below on the three methods), and exitstatus (a vector, where a 1 for any value means a computational problem or target relative accuracy not reached, for the corresponding observation).
The 'exact' values for the inverse Gaussian distribution are not really exact, but evaluated using inverse normal distributions,
for which very good numerical approximation are available in R.
For special cases of (i.e., ), where no inversion is needed, regions and method are set to NA for all values of y.
For special cases of y for other values of (i.e., ), regions and method are set to NA.
The three methods are described in Dunn & Smyth (2008).
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
# Plot a Tweedie density y <- seq(0.02, 4, length = 50) fy <- dtweedie_inversion(y, mu = 1, phi = 1, power = 1.1) plot(y, fy, type = "l", lwd = 2, ylab = "Density")# Plot a Tweedie density y <- seq(0.02, 4, length = 50) fy <- dtweedie_inversion(y, mu = 1, phi = 1, power = 1.1) plot(y, fy, type = "l", lwd = 2, ylab = "Density")
Density function for the Tweedie EMDs using a saddlepoint approximation.
dtweedie_saddle(y, xi = NULL, mu, phi, eps = 1/6, power = NULL) dtweedie.saddle(y, xi = NULL, mu, phi, eps = 1/6, power = NULL)dtweedie_saddle(y, xi = NULL, mu, phi, eps = 1/6, power = NULL) dtweedie.saddle(y, xi = NULL, mu, phi, eps = 1/6, power = NULL)
y |
vector of quantiles. |
xi |
scalar; the value of |
mu |
vector of mean |
phi |
vector of dispersion parameters |
eps |
the offset in computing the variance function; the default is |
power |
scalar; a synonym for |
A numeric vector of densities.
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. doi:10.1007/s11222-005-4070-y
Nelder, J. A. and Pregibon, D. (1987). An extended quasi-likelihood function Biometrika, 74(2), 221–232. doi:10.1093/biomet/74.2.221
# Plot a Tweedie density y <- seq(0.01, 4, length = 50) fy <- dtweedie_saddle(y, power = 1.1, mu = 1, phi = 1) plot(y, fy, type = "l", lwd = 2, ylab = "Density")# Plot a Tweedie density y <- seq(0.01, 4, length = 50) fy <- dtweedie_saddle(y, power = 1.1, mu = 1, phi = 1) plot(y, fy, type = "l", lwd = 2, ylab = "Density")
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.
dtweedie_series(y, power, mu, phi, details = FALSE) dtweedie.series(y, power, mu, phi)dtweedie_series(y, power, mu, phi, details = FALSE) dtweedie.series(y, power, mu, phi)
y |
vector of quantiles. |
power |
scalar; the value of |
mu |
vector of mean |
phi |
vector of dispersion parameters |
details |
logical; if |
A numeric vector of densities.
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. doi:10.1007/s11222-005-4070-y
# 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")# 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")
Evaluates the log-likelihood for a fitted Tweedie glm.
logLiktweedie(glm.obj, dispersion = NULL)logLiktweedie(glm.obj, dispersion = NULL)
glm.obj |
a fitted |
dispersion |
the dispersion parameter, usually extracted from |
The log-Likelihood is computed by evaluating the density function.
The value of the computed log-likelihood.
Evaluating the likelihood can be time consuming, so the function may take some time for large data sets.
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. doi:10.1007/s11222-005-4070-y
Jorgensen, B. (1997). Theory of Dispersion Models. Chapman and Hall, London.
Sakamoto, Y., Ishiguro, M., and Kitagawa G. (1986). Akaike Information Criterion Statistics. D. Reidel Publishing Company.
# Fit a Tweedie density using tweedie family function from statmod pretend <- data.frame( y = stats::rgamma(20, shape = 1, rate = 1) ) fit <- glm(y ~ 1, data = pretend, family = statmod::tweedie(link.power = 0, var.power = 2.1)) # Compute the AIC logLiktweedie(fit)# Fit a Tweedie density using tweedie family function from statmod pretend <- data.frame( y = stats::rgamma(20, shape = 1, rate = 1) ) fit <- glm(y ~ 1, data = pretend, family = statmod::tweedie(link.power = 0, var.power = 2.1)) # Compute the AIC logLiktweedie(fit)
Evaluates the distribution function (df) for Tweedie distributions using Fourier inversion,
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_inversion(q, mu, phi, power, verbose = FALSE, details = FALSE, IGexact = TRUE) ptweedie.inversion(q, power, mu, phi, verbose, details)ptweedie_inversion(q, mu, phi, power, verbose = FALSE, details = FALSE, IGexact = TRUE) ptweedie.inversion(q, power, mu, phi, verbose, details)
q |
vector of quantiles. |
mu |
the mean parameter. |
phi |
the dispersion parameter. |
power |
the power parameter |
verbose |
logical; if |
details |
logical; if |
IGexact |
logical; if |
If details = FALSE, a numeric vector of the distribution function values; if details = TRUE, a list containing CDF (a vector of the values of the distribution function), regions (a vector of the number of integration regions used), and exitstatus (a vector, where a 1 for any value means a computational problem or target relative accuracy not reached, for the corresponding observation).
For special cases of (i.e., ), where no inversion is needed, regions is set to NA for all values of q.
For special cases of q for other values of (i.e., ), regions is set to NA.
The 'exact' values for the inverse Gaussian distribution are not really exact, but evaluated using inverse normal distributions, for which very good numerical approximation are available in R.
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
# Plot a Tweedie distribution function y <- seq(0.01, 4, length = 50) Fy <- ptweedie_inversion(y, mu = 1, phi = 1, power = 1.1) plot(y, Fy, type = "l", lwd = 2, ylab = "Distribution function")# Plot a Tweedie distribution function y <- seq(0.01, 4, length = 50) Fy <- ptweedie_inversion(y, mu = 1, phi = 1, power = 1.1) plot(y, Fy, type = "l", lwd = 2, ylab = "Distribution function")
Evaluates the distribution function (df) for Tweedie distributions
with
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, verbose = FALSE, details = FALSE) ptweedie.series(q, power, mu, phi, verbose = FALSE, details = FALSE)ptweedie_series(q, power, mu, phi, verbose = FALSE, details = FALSE) ptweedie.series(q, power, mu, phi, verbose = FALSE, details = FALSE)
q |
vector of quantiles. |
power |
the power parameter |
mu |
the mean parameter |
phi |
the dispersion parameter |
verbose |
logical; if |
details |
logical; if |
A numeric vector of densities.
The 'exact' values for the inverse Gaussian distribution are not really exact, but evaluated using inverse normal distributions, for which very good numerical approximation are available in R.
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. 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")# 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")
Density, distribution function, quantile function and random generation for the the Tweedie family of distributions, with mean mu, dispersion parameter phi and variance power power (or xi, a synonym for power).
dtweedie(y, xi = NULL, mu, phi, power = NULL, verbose = FALSE) ptweedie(q, xi = NULL, mu, phi, power = NULL, verbose = FALSE) qtweedie(p, xi = NULL, mu, phi, power = NULL) rtweedie(n, xi = NULL, mu, phi, power = NULL) ptweedie(q, xi = NULL, mu, phi, power = NULL, verbose = FALSE) qtweedie(p, xi = NULL, mu, phi, power = NULL) rtweedie(n, xi = NULL, mu, phi, power = NULL)dtweedie(y, xi = NULL, mu, phi, power = NULL, verbose = FALSE) ptweedie(q, xi = NULL, mu, phi, power = NULL, verbose = FALSE) qtweedie(p, xi = NULL, mu, phi, power = NULL) rtweedie(n, xi = NULL, mu, phi, power = NULL) ptweedie(q, xi = NULL, mu, phi, power = NULL, verbose = FALSE) qtweedie(p, xi = NULL, mu, phi, power = NULL) rtweedie(n, xi = NULL, mu, phi, power = NULL)
y |
vector of quantiles. |
xi |
scalar; the value of |
mu |
vector of mean |
phi |
vector of dispersion parameters |
power |
scalar; a synonym for |
verbose |
logical; if |
q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. |
The Tweedie edms belong to the class of exponential dispersion models (edms), known for their role in generalized linear models (glms).
The Tweedie distributions are the edms with a variance of the form where .
This function only evaluates for .
Special cases are the Poisson ( with ), gamma (), and inverse Gaussian () distributions.
Evaluation is difficult for outside of .
This function uses one of two primary methods, depending on the combination of parameters:
Evaluation of an infinite series (dtweedie_series).
Interpolation from stored values computed via a Fourier inversion technique (dtweedie_inversion).
This function employs a two-dimensional interpolation procedure to compute the density for some parts of the parameter space from previously computed values (interpolation) and uses the series solution for others.
When , the density function include a positive probably for .
dtweedie gives the density, ptweedie gives the distribution function, qtweedie gives the quantile function,
and rtweedie generates random deviates.
The length of the result is determined by n for rtweedie, and by the length of mu for other functions.
dtweedie and ptweedie are the only functions generally to be called by users.
Consequently, all checks on the function inputs are performed in these functions.
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. doi:10.1007/s11222-005-4070-y
Jorgensen, B. (1997). Theory of Dispersion Models. Chapman and Hall, London.
dtweedie_series, dtweedie_inversion, ptweedie_series, ptweedie_inversion, dtweedie_saddle, tweedie_lambda
# Compute a Tweedie density power <- 1.1 mu <- 1 phi <- 1 y <- seq(0, 5, by = 0.5) dtweedie(y, power = power, mu = mu, phi = phi) # Compare to the saddlepoint density dtweedie_saddle(y = y, power = power, mu = mu, phi = phi) # The DF: ptweedie(y, power = power, mu = mu, phi = phi)# Compute a Tweedie density power <- 1.1 mu <- 1 phi <- 1 y <- seq(0, 5, by = 0.5) dtweedie(y, power = power, mu = mu, phi = phi) # Compare to the saddlepoint density dtweedie_saddle(y = y, power = power, mu = mu, phi = phi) # The DF: ptweedie(y, power = power, mu = mu, phi = phi)
Evaluates the aic for a fitted Tweedie glm.
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
where .
This function only evaluates for .
tweedie_AIC(glm.obj, dispersion = NULL, k = 2, verbose = TRUE) AICtweedie(glm.obj, dispersion = NULL, k = 2, verbose = TRUE)tweedie_AIC(glm.obj, dispersion = NULL, k = 2, verbose = TRUE) AICtweedie(glm.obj, dispersion = NULL, k = 2, verbose = TRUE)
glm.obj |
a fitted |
dispersion |
the dispersion parameter, usually extracted from |
k |
the aic penalty; |
verbose |
logical; if |
The aic is computed by evaluating the density function.
The value of the computed aic.
Evaluating the likelihood can be time consuming, so the function may take some time for large data sets.
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. doi:10.1007/s11222-005-4070-y
Jorgensen, B. (1997). Theory of Dispersion Models. Chapman and Hall, London.
Sakamoto, Y., Ishiguro, M., and Kitagawa G. (1986). Akaike Information Criterion Statistics. D. Reidel Publishing Company.
# Fit a Tweedie density using tweedie family function from statmod pretend <- data.frame( y = stats::rgamma(20, shape = 1, rate = 1) ) fit <- glm(y ~ 1, data = pretend, family = statmod::tweedie(link.power = 0, var.power = 2.1)) # Compute the AIC tweedie_AIC(fit)# Fit a Tweedie density using tweedie family function from statmod pretend <- data.frame( y = stats::rgamma(20, shape = 1, rate = 1) ) fit <- glm(y ~ 1, data = pretend, family = statmod::tweedie(link.power = 0, var.power = 2.1)) # Compute the AIC tweedie_AIC(fit)
Converts from the fitted glm parameters , and
and the corresponding underlying Poisson and gamma parameters (when ).
tweedie_convert(xi = NULL, mu, phi, power = NULL) tweedie.convert(xi = NULL, mu, phi, power = NULL)tweedie_convert(xi = NULL, mu, phi, power = NULL) tweedie.convert(xi = NULL, mu, phi, power = NULL)
xi |
a synonym for |
mu |
the mean parameter |
phi |
the dispersion parameter |
power |
the power parameter |
a list of the parameters of the parameters of the corresponding underlying
Poisson and gamma densities:
poisson.lambda ( from the underlying Poisson distribution),
gamma.shape, gamma.scale (the shape and scale parameters
from the underlying gamma distribution),
p0 (the probability that ),
gamma.mean and gamma.phi (the gamma mean and dispersion parameter values)
### Fit a Tweedie density pretend <- data.frame( y = rgamma(20, shape = 1, rate = 1) ) fit <- glm(y ~ 1, data = pretend, family = statmod::tweedie(link.power = 0, var.power = 1.4)) # Convert parameters tweedie_convert(mu = fitted(fit, type="response"), phi = 1, power = 1.4)### Fit a Tweedie density pretend <- data.frame( y = rgamma(20, shape = 1, rate = 1) ) fit <- glm(y ~ 1, data = pretend, family = statmod::tweedie(link.power = 0, var.power = 1.4)) # Convert parameters tweedie_convert(mu = fitted(fit, type="response"), phi = 1, power = 1.4)
Computes the unit deviance for Tweedie distributions.
tweedie_dev(y, mu, power) tweedie.dev(y, mu, power)tweedie_dev(y, mu, power) tweedie.dev(y, mu, power)
y |
vector of quantiles. |
mu |
the mean parameter |
power |
the power parameter |
A numeric vector containing the unit deviance.
Jorgensen, B. (1997). Theory of Dispersion Models. Chapman and Hall, London.
# Unit deviance is not symmetric in general: round( tweedie_dev(0:6, mu = 3, power = 1.1), 3)# Unit deviance is not symmetric in general: round( tweedie_dev(0:6, mu = 3, power = 1.1), 3)
Plots the integrand for Fourier inversion and the real and imaginary parts separately.
tweedie_integrand(y, power, mu, phi, t = seq(0, 5, length = 200), type = "PDF", whichPlots = 1:4, plot_args = list())tweedie_integrand(y, power, mu, phi, t = seq(0, 5, length = 200), type = "PDF", whichPlots = 1:4, plot_args = list())
y |
vector of quantiles. |
power |
a synonym for |
mu |
the mean parameter |
phi |
the dispersion parameter |
t |
the values of the variable over which to integrate; the default is |
type |
either |
whichPlots |
which combination of the four plots (described below) are produced; by default, all four are produced (i.e., |
plot_args |
A named list of arguments controlling the main plot.
These are passed to |
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 where is greater than or equal to one, or less than or equal to zero.
This function only evaluates for greater than or equal to one.
Special cases include the normal (), Poisson ( with ), gamma () and inverse Gaussian () 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 , the distribution are continuous for greater than zero, with a positive mass at . For , the distributions are continuous for greater than zero.
This function displays the integrand that is evaluated for computing the Fourier inversion, for the PDF or CDF.
A list containing the real and imaginary parts of , Real and Imag respectively, plus the values of the integrand as IG.
The main purpose of the function is the side-effect of producing a grid of plots.
The first is the imaginary parts of .
The second is (for type=="PDF") or (for type=="CDF").
The third is the real part of
The fourth is the integrand, with the envelope shown as a dashed line.
Peter Dunn ([email protected])
Dunn, P. K. and Smyth, G. K. (2008). Evaluation of Tweedie exponential dispersion model densities by Fourier inversion. Statistics and Computing, 18, 73–86. doi:10.1007/s11222-007-9039-6
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. doi:10.1007/s11222-005-4070-y
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.
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.
tweedie_integrand(2, power = 3, mu = 1, phi = 1, plot_args = list(lwd = 2))tweedie_integrand(2, power = 3, mu = 1, phi = 1, plot_args = list(lwd = 2))
The probability that the variable takes the value of zero.
tweedie_lambda(mu, phi, power)tweedie_lambda(mu, phi, power)
mu |
the mean parameter |
phi |
the dispersion parameter |
power |
the power parameter |
The value of when such that . When , a vector of zeros is returned.
Dunn, Peter K and Smyth, Gordon K (2005). Series evaluation of Tweedie exponential dispersion model densities Statistics and Computing, 15(4). 267–280. doi:10.1007/s11222-005-4070-y
lambda <- tweedie_lambda(mu = 1:3, phi = 1, power = 1.1) exp( -lambda) # When p > 2, there is zero probability that Y = 0: lambda <- tweedie_lambda(mu = 1, phi = 1, power = 3.1)lambda <- tweedie_lambda(mu = 1:3, phi = 1, power = 1.1) exp( -lambda) # When p > 2, there is zero probability that Y = 0: lambda <- tweedie_lambda(mu = 1, phi = 1, power = 3.1)
This function produced a plot of the specified Tweedie distribution.
tweedie_plot(y, xi = NULL, mu, phi, type = "pdf", power = NULL, add = FALSE, plot_args = list(), point_args = list(), line_args = list()) tweedie.plot( y, xi = NULL, mu, phi, type = "pdf", power = NULL, add = FALSE, ... )tweedie_plot(y, xi = NULL, mu, phi, type = "pdf", power = NULL, add = FALSE, plot_args = list(), point_args = list(), line_args = list()) tweedie.plot( y, xi = NULL, mu, phi, type = "pdf", power = NULL, add = FALSE, ... )
y |
the values for |
xi |
a synonym for |
mu |
the mean of the distribution |
phi |
the dispersion parameter |
type |
the type of plot, either |
power |
the variance power |
add |
logical; if |
plot_args |
A named list of arguments controlling the main plot.
These are passed to |
point_args |
A named list of graphical parameters for plotted points.
These are passed to |
line_args |
A named list of graphical parameters for plotted lines.
These are passed to |
... |
Additional graphical arguments, passed to |
If , the mass at is automatically added.
y <- seq(0, 4, length = 50) tweedie_plot(y, power = 1.1, mu = 1, phi = 1, line_args = list(lwd = 2))y <- seq(0, 4, length = 50) tweedie_plot(y, power = 1.1, mu = 1, phi = 1, line_args = list(lwd = 2))
This function profiles the (log-)likelihood over a vector of
Tweedie power-index parameter (denoted or ) to find the maximum
likelihood estimate (MLE) of the index parameter (or equivalently ).
tweedie_profile(formula, p.vec = NULL, xi.vec = NULL, link.power = 0, data, weights = 1, offset = 0, fit.glm = FALSE, do.smooth = TRUE, do.plot = FALSE, do.ci = do.smooth, eps = 1/6, control = list( epsilon = 1e-09, maxit = stats::glm.control()$maxit, trace = glm.control()$trace ), do.points = do.plot, method = "inversion", conf.level = 0.95, phi.method = ifelse(method == "saddlepoint", "saddlepoint", "mle"), verbose = FALSE, add0 = FALSE, plot_args = list(), point_args = list(), line_args = list()) tweedie.profile( formula, p.vec = NULL, xi.vec = NULL, link.power = 0, data, weights = 1, offset = 0, fit.glm = FALSE, do.smooth = TRUE, do.plot = FALSE, do.ci = do.smooth, eps = 1/6, control = list(epsilon = 1e-09, maxit = stats::glm.control()$maxit, trace = glm.control()$trace), do.points = do.plot, method = "inversion", conf.level = 0.95, phi.method = ifelse(method == "saddlepoint", "saddlepoint", "mle"), verbose = FALSE, add0 = FALSE )tweedie_profile(formula, p.vec = NULL, xi.vec = NULL, link.power = 0, data, weights = 1, offset = 0, fit.glm = FALSE, do.smooth = TRUE, do.plot = FALSE, do.ci = do.smooth, eps = 1/6, control = list( epsilon = 1e-09, maxit = stats::glm.control()$maxit, trace = glm.control()$trace ), do.points = do.plot, method = "inversion", conf.level = 0.95, phi.method = ifelse(method == "saddlepoint", "saddlepoint", "mle"), verbose = FALSE, add0 = FALSE, plot_args = list(), point_args = list(), line_args = list()) tweedie.profile( formula, p.vec = NULL, xi.vec = NULL, link.power = 0, data, weights = 1, offset = 0, fit.glm = FALSE, do.smooth = TRUE, do.plot = FALSE, do.ci = do.smooth, eps = 1/6, control = list(epsilon = 1e-09, maxit = stats::glm.control()$maxit, trace = glm.control()$trace), do.points = do.plot, method = "inversion", conf.level = 0.95, phi.method = ifelse(method == "saddlepoint", "saddlepoint", "mle"), verbose = FALSE, add0 = FALSE )
formula |
a formula expression as for other regression models and
generalized linear models, of the form |
p.vec |
a vector of |
xi.vec |
a synonym for |
link.power |
the power link function to use in the |
data |
an optional data frame, list or environment containing the variables. |
weights |
an optional vector of weights to be used in the fitting process. |
offset |
an a priori known component included in the linear predictor.
See |
fit.glm |
logical; if |
do.smooth |
logical; if |
do.plot |
logical; if |
do.ci |
logical; if |
eps |
the offset in computing the variance function. Default is |
control |
a list of parameters for controlling the fitting process; |
do.points |
logical; if |
method |
the method of evaluation; one of |
conf.level |
the level of confidence for the confidence intervals; the default is |
phi.method |
the method used to estimate |
verbose |
logical; if |
add0 |
logical; if |
plot_args |
A named list of arguments controlling the main plot.
These are passed to |
point_args |
A named list of graphical parameters for plotted points.
These are passed to |
line_args |
A named list of graphical parameters for plotted lines.
These are passed to |
For each value in p.vec, the function computes an estimate of
and then computes the value of the log-likelihood for these parameters.
The plot of the log-likelihood against p.vec allows the maximum
likelihood value of to be found.
Once is found, the distribution within the class of Tweedie distributions is identified.
The estimates of and are printed invisibly.
If the response variable has any exact zeros, the values in p.vec must all be
between one and two.
The function can be temperamental (for theoretical reasons involved in numerically computing
the density; see Dunn and Smyth (2005)) and may be very slow or fail.
One solution is to change the method.
The default is method = "inversion"; then try "series", "interpolation",
and "saddlepoint" in that order.
Note that method = "saddlepoint" is an approximate method only.
It is recommended that for the first use with a data set, use p.vec
with only a small number of values and set do.smooth = FALSE,
do.ci = FALSE. If this is successful, a larger vector p.vec
and smoothing can be used.
Dunn, P. K. and Smyth, G. K. (2018). Generalized linear models with examples in R. Springer. doi:10.1007/978-1-4419-0118-7
data(rock) out <- tweedie_profile(perm~1, data=rock, do.plot=FALSE, xi.vec=seq(1.5, 2.75, length=11), line_arg = list(lwd = 2)) # The estimate for the variance power index (p, or xi) is: out$p.maxdata(rock) out <- tweedie_profile(perm~1, data=rock, do.plot=FALSE, xi.vec=seq(1.5, 2.75, length=11), line_arg = list(lwd = 2)) # The estimate for the variance power index (p, or xi) is: out$p.max