This function chooses the best fitted distribution, based on a specified criterion.

bestDist(
  X,
  w = rep(1, length(X))/length(X),
  candDist = c("Beta_ab", "Laplace", "Normal"),
  criterion = c("AICc", "logLik", "AIC", "BIC", "MDL")
)

Arguments

X

Sample observations.

w

An optional vector of sample weights.

candDist

A vector of candidate distributions.

criterion

The basis on which the best fitted distribution is chosen.

Value

An object of class character containing the name of the best distribution and its corresponding parameter estimates.

Details

When comparing models fitted by maximum likelihood to the same data, the smaller the AIC, BIC or MDL, the better the fit. When comparing models using the log-likelihood criterion, the larger the log-likelihood the better the fit.

Note

The MDL criterion only works for parameter estimation by numerical maximum likelihood.

Author

Haizhen Wu and A. Jonathan R. Godfrey.

Examples

X <- rBeta_ab(30, a = 0, b = 1, shape1 = 2, shape2 = 10)

# Determining the best distribution from the list of candidate distributions for the data X
Best.Dist <- bestDist(X, candDist = c("Laplace","Normal","Beta_ab"), criterion = "logLik")

# Printing the parameter estimates of the best distribution
attributes(Best.Dist)$best.dist.par
#> 
#> Parameters for the Beta_ab distribution. 
#> (found using the  numerical.MLE method.)
#> 
#>  Parameter     Type   Estimate
#>     shape1    shape 1.00006231
#>     shape2    shape 2.35288591
#>          a boundary 0.03528325
#>          b boundary 0.55530427
#> 
#>