View source: R/tweedie_profile.R
| tweedie_profile | R Documentation |
This function profiles the (log-)likelihood over a vector of
Tweedie power-index parameter (denoted p or \xi) to find the maximum
likelihood estimate (MLE) of the index parameter p (or equivalently \xi).
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
)
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 |
For each value in p.vec, the function computes an estimate of \phi
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 p to be found.
Once p is found, the distribution within the class of Tweedie distributions is identified.
The estimates of p and \phi 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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-1-4419-0118-7")}
data(Loblolly)
out <- tweedie_profile(height~age, data = Loblolly,
do.plot = FALSE, p.vec = seq(3.5, 4.5, length = 7) )
# The estimate for the variance power index (p, or xi) is:
out$p.max
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.