Fits a hyperbolic distribution to data. Displays the histogram, log-histogram (both with fitted densities), Q-Q plot and P-P plot for the fit which has the maximum likelihood.
hyperbFit(x, freq = NULL, paramStart = NULL,
startMethod = c("Nelder-Mead","BFGS"),
startValues = c("BN","US","FN","SL","MoM"),
criterion = "MLE",
method = c("Nelder-Mead","BFGS","nlm",
"L-BFGS-B","nlminb","constrOptim"),
plots = FALSE, printOut = FALSE,
controlBFGS = list(maxit = 200),
controlNM = list(maxit = 1000), maxitNLM = 1500,
controlLBFGSB = list(maxit = 200),
controlNLMINB = list(),
controlCO = list(), ...) # S3 method for hyperbFit
print(x,
digits = max(3, getOption("digits") - 3), ...)
# S3 method for hyperbFit
plot(x, which = 1:4,
plotTitles = paste(c("Histogram of ","Log-Histogram of ",
"Q-Q Plot of ","P-P Plot of "), x$obsName,
sep = ""),
ask = prod(par("mfcol")) < length(which) & dev.interactive(), ...)
# S3 method for hyperbFit
coef(object, ...)
# S3 method for hyperbFit
vcov(object, ...)
hyperbFit
returns a list with components:
A vector giving the maximum likelihood estimate of
param, as c(mu, delta, alpha, beta)
.
The value of the maximised log-likelihood.
Optimisation method used.
Convergence code. See the relevant documentation (either
optim
or nlm
) for details on
convergence.
Number of iterations of optimisation routine.
The data used to fit the hyperbolic distribution.
A character string with the actual x
argument
name.
Starting value of param returned by call to
hyperbFitStart
.
Descriptive name for the method finding start values.
Acronym for the method of finding start values.
The cell boundaries found by a call to
hist
.
The cell midpoints found by a call to
hist
.
The estimated density found by a call to
hist
.
Data vector for hyperbFit
. Object of class
"hyperbFit"
for print.hyperbFit
and plot.hyperbFit
.
A vector of weights with length equal to length(x)
.
A user specified starting parameter vector
param
taking the form c(mu, delta, alpha, beta)
.
Method used by hyperbFitStart
in calls to
optim
.
Code giving the method of determining starting
values for finding the maximum likelihood estimate of param
.
Currently only "MLE"
is implemented.
Different optimisation methods to consider. See Details.
Logical. If FALSE
suppresses printing of the
histogram, log-histogram, Q-Q plot and P-P plot.
Logical. If FALSE
suppresses printing of
results of fitting.
A list of control parameters for optim
when using
the "BFGS"
optimisation.
A list of control parameters for optim
when using the "Nelder-Mead"
optimisation.
A positive integer specifying the maximum number of
iterations when using the "nlm"
optimisation.
A list of control parameters for optim
when using
the "L-BFGS-B"
optimisation.
A list of control parameters for nlminb
when using the "nlminb"
optimisation.
A list of control parameters for constrOptim
when using the "constrOptim"
optimisation.
Desired number of digits when the object is printed.
If a subset of the plots is required, specify a subset of
the numbers 1:4
.
Titles to appear above the plots.
Logical. If TRUE
, the user is asked before
each plot, see par(ask = .)
.
Passes arguments to par
, hist
,
logHist
, qqhyperb
and pphyperb
.
Object of class "hyperbFit"
for coef.hyperbFit
and for vcov.hyperbFit
.
David Scott d.scott@auckland.ac.nz, Ai-Wei Lee, Jennifer Tso, Richard Trendall, Thomas Tran, Christine Yang Dong
startMethod
can be either "BFGS"
or
"Nelder-Mead"
.
startValues
can be one of the following:
"US"
User-supplied.
"BN"
Based on Barndorff-Nielsen (1977).
"FN"
A fitted normal distribution.
"SL"
Based on a fitted skew-Laplace distribution.
"MoM"
Method of moments.
For the details concerning the use of paramStart
,
startMethod
, and startValues
, see
hyperbFitStart
.
The six optimisation methods currently available are:
"BFGS"
Uses the quasi-Newton method "BFGS"
as
documented in optim
.
"Nelder-Mead"
Uses an implementation of the Nelder and
Mead method as documented in optim
.
"nlm"
Uses the nlm
function in R.
"L-BFGS-B"
Uses the quasi-Newton method with box
constraints "L-BFGS-B"
as documented in optim
.
"nlminb"
Uses the nlminb
function in R.
"constrOptim"
Uses the constrOptim
function in R.
For details of how to pass control information for optimisation using
optim
, nlm
, nlminb
and constrOptim
, see
optim
, nlm
, nlminb
and
constrOptim
.
When method = "nlm"
is used, warnings may be produced. These do
not appear to be a problem.
Barndorff-Nielsen, O. (1977) Exponentially decreasing distributions for the logarithm of particle size, Proc. Roy. Soc. Lond. A353, 401--419.
Fieller, N. J., Flenley, E. C. and Olbricht, W. (1992) Statistics of particle size data. Appl. Statist. 41, 127--146.
optim
, nlm
, nlminb
,
constrOptim
, par
,
hist
, logHist
(pkg DistributionUtils),
qqhyperb
, pphyperb
, dskewlap
and hyperbFitStart
.
param <- c(2, 2, 2, 1)
dataVector <- rhyperb(500, param = param)
## See how well hyperbFit works
hyperbFit(dataVector)
hyperbFit(dataVector, plots = TRUE)
fit <- hyperbFit(dataVector)
par(mfrow = c(1, 2))
plot(fit, which = c(1, 3))
## Use nlm instead of default
hyperbFit(dataVector, method = "nlm")
Run the code above in your browser using DataLab