estimateBetaDist: Select the beta distribution that fit specified quantiles

estimateBetaDistR Documentation

Select the beta distribution that fit specified quantiles

Description

This function perform a nonlinear estimation of the shape parameters of beta distribution

Usage

estimateBetaDist(
  q,
  init.pars = NULL,
  via.optim = TRUE,
  loss.fun = c("linear", "huber", "smooth", "cauchy", "arctg"),
  maxiter = 1024,
  maxfev = 1e+05,
  ftol = 1e-12,
  ptol = 1e-12
)

Arguments

q

prior probabilities

init.pars

initial parameter values. Defaults is NULL and an initial guess is estimated using the method of moments, which probably is the best approach to estimate the initial parameter values of beta distribution.

via.optim

Logical. Whether to estimate beta distribution parameters via optim or nls.lm. If any of this approaches fail then parameters used init.pars will be returned.

loss.fun

Loss function(s) used in the regression (see (Loss function)). This fitting uses the approach followed in in the R package usefr. After z = 1/2 * sum((f(x) - y)^2) we have:

  1. "linear": linear function which gives a standard least squares: loss(z) = z.

  2. "huber": Huber loss, loss(z) = ifelse(z \leq 1, z, sqrt(z) -1).

  3. "smooth": Smooth approximation to the sum of residues absolute values: loss(z) = 2*(sqrt(z + 1) - 1).

  4. "cauchy": Cauchy loss: loss(z) = log(z + 1).

  5. "arctg": arc-tangent loss function: loss(x) = atan(z).

maxiter, ftol, ptol, maxfev

Optional parameters for nlsLM and nls.lm functions.

Details

To obtain the estimates for shape parameters from the best fitted beta distribution model, a nonlinear regression Levenberg-Marquardt algorithm implemented in function nls.lm is applied. Several (loss functions)) are available to accomplish the model fitting to the data. If nls.lm function fails, then a new try will be accomplish with nlsLM function. If the previous algorithms fail, then the parameters will be estimated using BFGS" algorithm implemented in optim function.

Value

the estimated values of the shape parameters of the selected beta distribution.

Examples

## ------ A simple example -----
set.seed(4)
br <- rbeta(1e3, shape1 = 1, shape2 = 2)
pars <- estimateBetaDist(br)
pars


genomaths/MethylIT documentation built on Feb. 3, 2024, 1:24 a.m.