fit_dist: Distribution Selection and Parameters Estimation

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/fit_dist.R

Description

If the distribution family is given, this function returns the corresponding parameters estimation. If not, a suggested distribution is choosen by the largest p-value of Kolmogorov-Smirnov tests.

Usage

1
fit_dist(x, dist_null = NA, ...)

Arguments

x

a numeric vector of data values.

dist_null

a character string specifies the distribution family. Default is NA. This means no specified distribution and the function will select a distribution from common continuous distributions. Distribution options are shown in details.

...

further arguments for distribution parameters.

Details

This function is built up for selecting underlying distribution in null hypothesis in this anomaly detection method. dist_null needs to be one of the strings in the list below:

"norm"

normal distribution

"unif"

uniform distribution

"gamma"

gamma distribution

"chisq"

chi-square distribution

"beta"

beta distribution

"cauchy"

cauchy distribution

"exp"

exponential distribution

"f"

f distribution

"logis"

logistic distribution

"lnorm"

log normal distribution

"t"

t distribution

"weibull"

Weibull distribution

"gpd"

generalized pareto distribution

If dist_null is missing, this function fits the data with all the distributions in the list and picks the one with the largest p-value of ks.test.

With hazard rate ratio adjustment, this test is robusted with distribution misspecification. As long as the underlying distribution is closed to distribution of sampled data, the test works well.

Value

This function returns a list with components:

dist

A string indicates the distribution family. It is same as dist_null when dist_null is given.

para

A vector with estimated parameter(s) come with the distribution.

Note

To use gpd, package POT https://cran.r-project.org/package=POT needs to be installed first.

Author(s)

Zhicong Zhao

Examples

1
2
3
4
5
x <- rnorm(10000)
fit_dist(x)

y <- rgamma(10000,2,3)
fit_dist(y)

zhicongz/AnomDetct documentation built on Dec. 12, 2019, 9:16 a.m.