fitter: Fit distributions to empirical data

View source: R/fitter.R

fitterR Documentation

Fit distributions to empirical data

Description

Fits theoretical univariate distributions from the R universe to a given set of empirical observations

Usage

fitter(
  X,
  dom = "discrete",
  freq = NULL,
  R = 100,
  timeout = 5,
  posList = NULL,
  fast = TRUE
)

Arguments

X

A numeric vector

dom

A string specifying the domain of ‘X’

freq

The frequency of values in ‘X’. See details.

R

An integer specifying the number of bootstraps. See details.

timeout

An numeric value specifying the maximum time spend for a fit

posList

A list. See details.

fast

A logical. See details.

Details

This routine is the workhorse of the package. It takes empirical data and systematically tries to fit numerous distributions implemented in R packages to this data. Sometimes the empirical data is passed as a histogram. In this case ‘X’ takes the support and ‘freq’ takes the number of occurences of each value in ‘X’. Although not limited to, this makes most sense for discrete data. If there is prior knowledge (or guessing) about candidate theoretical distributions, these can be specified by ‘posList’. This parameter takes a list with names of items being the package name and items being a character vector containing names of the distribtions (with prefix 'd'). If all distributions of a package should be applied, this vector is set to NA. Fitting of some distributions can be very slow. They can be skipped if ‘fast’ is set to TRUE.

Value

A list serving as an unformatted report summarizing the fitting.

Note

To reduce the computational efforts, usage of the parameter ‘posList’ is recommended. If not specified, the function will try to perform fits to distributions from _ALL_ packages listed in supported.packages.

Author(s)

Markus Boenn

See Also

printReport for post-processing of all fits

Examples

# continous empirical data
x <- rnorm(1000, 50, 3)
if(requireNamespace("ExtDist")){
r <- fitter(x, dom="c", posList=list(stats=c("dexp"), ExtDist=c("dCauchy")))
}else{
r <- fitter(x, dom="c", posList=list(stats=c("dexp", "dt")))
}

# discrete empirical data
x <- rnbinom(100, 0.5, 0.2)
r <- fitter(x, dom="dis", posList=list(stats=NA))


fitteR documentation built on March 18, 2022, 7:20 p.m.

Related to fitter in fitteR...