Learn R Programming

rriskDistributions (version 2.1.1)

rriskFitdist.perc: Fitting an amount of distribution families by given quantiles

Description

This function fits the amount of distribution families to given quantiles and returns diagnostics that allow user to choose a most appropriate probability.

Usage

rriskFitdist.perc(p = c(0.025, 0.5, 0.975), q = c(9.68, 29.20, 50.98), show.output = TRUE, tolConv = 0.001, fit.weights = rep(1, length(p)))

Arguments

p
numerical vector giving probabilities.
q
numerical vector giving percentiles.
show.output
logical, if TRUE the optim result will be printed (default value is TRUE).
tolConv
positive numerical value, the absolute convergence tolerance for reaching zero by fitting distributions get.norm.par will be shown.
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 list containing the data frame with the input vectors p and q and the results matrix giving fitted distributions, estimated parameters and a vector of theoretical percentiles calculated based on the estimated parameters. If the consistency check of input parameters fails the function returns NA.

Details

Both inputs p and q should be of the same length. The items of the probability vector p should lie between 0 and 1.

Examples

Run this code
fit.results1 <- rriskFitdist.perc(show.output = FALSE)
fit.results1

fit.results2 <- rriskFitdist.perc(show.output = FALSE, tolConv = 0.6)
fit.results2

p <- c(0.2, 0.7)
q <- c(2.6, 19.1)
fit.results3 <- rriskFitdist.perc(p = p, q = q, show.output = FALSE)
fit.results3

p <- c(0.3, 0.8, 0.9)
q <- c(10, 20, 40)
fit.results4 <- rriskFitdist.perc(p = p, q = q, show.output = FALSE)
fit.results4

## Example with fitted pert distribution
p <- c(0.025, 0.5, 0.6, 0.975)
q <- mc2d::qpert(p = p, min = 0, mode = 3, max = 10, shape = 5)
fit.results5 <- rriskFitdist.perc(p = p, q = q, show.output = FALSE)
fit.results5

Run the code above in your browser using DataLab