getGammaFromCI {bootComb} R Documentation

Find the best-fit gamma distribution for a given confidence interval.

Description

Finds the best-fit gamma distribution for a given confidence interval; returns the corresponding density, distribution, quantile and sampling functions.

Usage

getGammaFromCI(qLow, qUpp, alpha = 0.05, initPars = c(1, 1), maxiter = 1000)

Arguments

 qLow The observed lower quantile. qUpp The observed upper quantile. alpha The confidence level; i.e. the desired coverage is 1-alpha. Defaults to 0.05. initPars A vector of length 2 giving the initial parameter values (shape & rate) to start the optimisation; defaults to c(1,1). maxiter Maximum number of iterations for optim. Defaults to 1e3. Set to higher values if convergence problems are reported.

Value

A list with 5 elements:

 r The sampling function. d The density function. p The distribution function. q The quantile function. pars A vector of length 2 giving the shape and rate for the best-fit gamma distribution (shape and rate as in rgamma, dgamma, pgamma, qgamma).

Examples

n<-getGammaFromCI(qLow=0.82,qUpp=5.14)
print(n\$pars) # the fitted parameter values (shape & rate)
n\$r(10) # 10 random values from the fitted gamma distribution
n\$d(6) # the probability density at x=6 for the gamma distribution
n\$p(2) # the cumulative density at x=2 for the fitted gamma distribution
n\$q(c(0.25,0.5,0.75)) # the 25th, 50th (median) and 75th percentiles of the fitted distribution
x<-seq(0,8,length=1e3)
y<-n\$d(x)
plot(x,y,type="l",xlab="",ylab="density") # density plot for the fitted gamma distribution

[Package bootComb version 1.1.1 Index]