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
)
a formula expression as for other regression models and
generalized linear models, of the form response ~ predictors.
a vector of \(p\) values for consideration.
The values must all be larger than one.
If the response has zeros, values must be \(1 < p < 2\).
If NULL (default), p.vec is set automatically.
a synonym for p.vec, as some authors use the \(\xi\) notation.
the power link function to use in the tweedie glm family.
These link functions \(g(\cdot)\) are of the form \(g(\eta)=\eta^{link.power}\), where link.power = 0 (default) refers to the logarithm link function.
an optional data frame, list or environment containing the variables.
an optional vector of weights to be used in the fitting process.
an a priori known component included in the linear predictor.
See model.offset.
logical; if TRUE, the Tweedie glm is fitted using the
value of \(p\) found by the profiling function. The default is FALSE.
logical; if TRUE (default), a spline is fitted to the
data to smooth the profile likelihood plot. Note that p.vec
must contain at least five points for smoothing.
logical; if TRUE, a plot of the profile likelihood is produced.
The default is FALSE.
logical; if TRUE, the nominal 100*conf.level is computed.
Defaults to the value of do.smooth.
Confidence intervals are only computed if do.smooth = TRUE.
the offset in computing the variance function. Default is 1/6 (as recommended by Nelder and Pregibon, 1987).
eps is ignored unless method = "saddlepoint".
a list of parameters for controlling the fitting process;
logical; if TRUE, the points used to compute the likelihood as given by p.vec (or equivalently, xi.vec) are explicitly shown by points.
The defaults is the value of do.plot.
the method of evaluation; one of saddlepoint, interpolation, series or inversion (the default).
the level of confidence for the confidence intervals; the default is 0.95 (for \(95\%\) confidence intervals).
the method used to estimate \(\phi\); one of saddlepoint, mle (the default).
logical; if TRUE, some details of the calculations are shown. The default is FALSE.
logical; if TRUE, adds \(P(Y = 0)\) to the plot. The default is FALSE.
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.
Dunn, P. K. and Smyth, G. K. (2018). Generalized linear models with examples in R. Springer. tools:::Rd_expr_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))
# The estimate for the variance power index (p, or xi) is:
out$p.max
Run the code above in your browser using DataLab