Learn R Programming

rriskDistributions (version 2.1.1)

fit.perc: Choosing distribution by given quantiles

Description

This function provides a GUI for choosing a most appropriate continuous distribution for known quantiles.

Usage

fit.perc(p = c(0.025, 0.5, 0.975), q = stats::qnorm(p), show.output = FALSE, tolPlot = 0.1, tolConv = 0.001, fit.weights = rep(1, length(p)))

Arguments

p
numerical vector of probabilities.
q
numerical vector of quantiles.
show.output
logical, if TRUE the output of the fitting functions get.distribution.par will be shown.
tolPlot
single positive numerical value giving a tolerance for plotting graphical diagnostics. If the sums of the differences between the distribution percentiles and the given percentiles are smaller than this value, the distribution will be plotted.
tolConv
positive numerical value, the absolute convergence tolerance for reaching zero.
fit.weights
numerical vector of the same length as a probabilities vector p containing positive values for weighting quantiles. By default all quantiles will be weighted by 1.

Value

Returns a named list containing a chosen distribution, its estimated parameters and the data on which the estimation is based.

Details

The argument tolPlot defines a tolerance for plotting graphical diagnostics. If the sums of the differences between the percentiles of the estimated distribution and the given percentiles are smaller than this value, the distribution will be plotted. The items of the probability vector p should lie between 0 and 1.

Examples

Run this code
## Not run: 
#     chosenDistr1 <- fit.perc()
#     chosenDistr1
#     
#     chosenDistr2 <- fit.perc(tolPlot = 5)
#     chosenDistr2
#     
#     chosenDistr3 <- fit.perc(p = c(0.3, 0.8, 0.9), q = c(10, 20, 40))
#     chosenDistr3
#     
#     chosenDistr4 <- fit.perc(p = c(0.3, 0.8, 0.9), q = c(10, 30, 40))
#     chosenDistr4
#     
#     chosenDistr5 <- fit.perc(p = c(0.3, 0.8, 0.9), q = c(10, 30, 40), tolPlot = 10)
#     chosenDistr5
# 
#     ## Fitting a PERT distribution
#     p <- c(0.025, 0.5, 0.6, 0.975)
#     q <- round(mc2d::qpert(p = p, min = 0, mode = 3, max = 10, shape = 5), digits = 2)
#     chosenDistr6 <- fit.perc(p = p, q = q, tolPlot = 10)
#     chosenDistr6
# ## End(Not run)

Run the code above in your browser using DataLab