Learn R Programming

fitteR (version 0.2.0)

fitter: 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.

Value

A list serving as an unformatted report summarizing the fitting.

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.

See Also

printReport for post-processing of all fits

Examples

Run this code
# NOT RUN {
# 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))

# }

Run the code above in your browser using DataLab