Learn R Programming

CoSMoS (version 2.2.0)

fitDist: Distribution fitting

Description

Fits a parametric distribution to data using the Nelder-Mead simplex algorithm to minimise one of four fitting norms.

Usage

fitDist(
  data,
  dist,
  n.points,
  norm,
  constrain,
  opts = list(algorithm = "NLOPT_LN_NELDERMEAD", xtol_rel = 1e-08, maxeval = 10000)
)

Value

An object of class "fitDist": a named list of fitted distribution parameters with attributes dist, edf (empirical CDF), and nfo (full nloptr output).

Arguments

data

numeric vector of values to fit

dist

character; distribution name (e.g. "norm", "ggamma")

n.points

integer; number of ECDF points used in norm computation

norm

character; norm identifier — one of "N1" (ratio RMSE on quantiles), "N2" (MSE on quantiles), "N3" (ratio RMSE on probabilities), "N4" (MSE on probabilities)

constrain

logical; if TRUE, constrains shape2 parameters to (0, 0.48) to enforce finite upper tails

opts

list of nloptr minimisation options

See Also

fitACS, plot.fitDist

Examples

Run this code

x <- fitDist(rnorm(1000), "norm", 30, "N1", FALSE)
x

Run the code above in your browser using DataLab