Learn R Programming

stat.extend (version 0.2.1)

HDR: Highest density region (HDR)

Description

HDR.xxxx returns the highest density region (HDR) for a chosen distribution.

Usage

HDR.norm(
  cover.prob,
  mean = 0,
  sd = 1,
  gradtol = 1e-10,
  steptol = 1e-10,
  iterlim = 100
)

HDR.lnorm( cover.prob, meanlog = 0, sdlog = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.t(cover.prob, df, ncp = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100)

HDR.cauchy( cover.prob, location = 0, scale = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.f( cover.prob, df1, df2, ncp = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.beta( cover.prob, shape1, shape2, ncp = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.chisq( cover.prob, df, ncp = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.gamma( cover.prob, shape, rate = 1, scale = 1/rate, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.weibull( cover.prob, shape, scale = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.exp(cover.prob, rate, gradtol = 1e-10, steptol = 1e-10, iterlim = 100)

HDR.unif( cover.prob, min = 0, max = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.hyper(cover.prob, m, n, k, gradtol = 1e-10, steptol = 1e-10, iterlim = 100)

HDR.geom(cover.prob, prob, gradtol = 1e-10, steptol = 1e-10, iterlim = 100)

HDR.binom( cover.prob, size, prob, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.pois(cover.prob, lambda, gradtol = 1e-10, steptol = 1e-10, iterlim = 100)

HDR.nbinom( cover.prob, size, prob, mu, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.arcsine( cover.prob, min = 0, max = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.matching(cover.prob, size, trials = 1, prob = 0, approx = (trials > 100))

HDR.betapr( cover.prob, shape1, shape2, scale = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.fatigue( cover.prob, alpha, beta = 1, mu = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.gompertz( cover.prob, shape = 1, scale = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.gpd( cover.prob, mu = 0, sigma = 1, xi = 0, location = mu, scale = sigma, shape = xi, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.huber( cover.prob, mu, sigma, epsilon, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.kumar( cover.prob, a = 1, b = 1, shape1 = a, shape2 = b, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.tnorm( cover.prob, mean = 0, sd = 1, a = -Inf, b = Inf, min = a, max = b, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.invchisq( cover.prob, df, ncp = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.invexp( cover.prob, rate = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.invgamma( cover.prob, shape, rate = 1, scale = 1/rate, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.benini( cover.prob, shape, y0, scale = y0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.frechet( cover.prob, shape, scale = 1, location = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.gengamma( cover.prob, d, k, shape1 = d, shape2 = k, rate = 1, scale = 1/rate, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.gumbelII( cover.prob, shape, scale = 1, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

HDR.lgamma( cover.prob, shape = 1, scale = 1, location = 0, gradtol = 1e-10, steptol = 1e-10, iterlim = 100 )

Arguments

cover.prob

The probability coverage for the HDR (scalar between zero and one). The significance level for the HDR i is 1-cover.prob.

gradtol

Parameter for the nlm optimisation - a positive scalar giving the tolerance at which the scaled gradient is considered close enough to zero to terminate the algorithm (see [nlm doccumentation](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/nlm.html)).

steptol

Parameter for the nlm optimisation - a positive scalar providing the minimum allowable relative step length (see [nlm doccumentation](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/nlm.html)).

iterlim

Parameter for the nlm optimisation - a positive integer specifying the maximum number of iterations to be performed before the program is terminated (see [nlm doccumentation](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/nlm.html)).

shape1, shape2, ncp, location, scale, df, rate, df1, df2, meanlog, sdlog, mean, sd, min, max, shape, size, prob, m, n, k, mu, lambda, alpha, beta, sigma, xi, epsilon, a, b, y0, d, trials, approx

Distribution parameters.

Value

An interval object with classes hdr and interval containing the highest density region and related information.

Details

This function computes the highest density region (HDR) for a univariate distribution in the stats package. The functions for the HDR for different distributions are named in the form HDR.xxxx where the xxxx refers to the distribution (e.g., HDR.chisq, HDR.gamma, HDR.norm, etc.). The user can use any univariate distribution in the stats package, and the function accepts parameters from the specified distribution (see table below). The output of the function is an interval of classes hdr and interval giving the highest density region and some related information pertaining to the distribution and the computation of the HDR (for information on intervals, see the sets package). If the input distribution is continuous then the HDR is a real interval, and if the input distribution discrete then the HDR is a discrete interval. For non-trivial cases the computation is done by optimisation using the nlm function.

Using stats Continuous
HDR.arcsine min max
HDR.beta shape1 shape2 ncp
HDR.cauchy location scale
HDR.chisq df ncp
HDR.exp rate
HDR.f df1 df2 ncp
HDR.gamma shape rate scale
HDR.lnorm meanlog sdlog
HDR.norm mean sd
HDR.t df ncp
HDR.unif min max
HDR.weibull shape scale
Using stats Discrete
HDR.binom size prob
HDR.geom prob
HDR.hyper m n k
HDR.nbinom size prob mu
HDR.pois lambda
Using extraDistr
HDR.betapr shape1 shape2 scale
HDR.fatigue alpha beta mu
HDR.gompertz shape scale
HDR.gpd mu,location sigma, scale shape, xi
HDR.huber mu sigma epsilon
HDR.kumar a,shape1 b,shape2
HDR.tnorm mean sd a, b, min, max
Using invgamma
HDR.invchisq df ncp
HDR.invexp rate
HDR.invgamma shape rate scale
Using VGAM
HDR.benini shape y0 scale
HDR.frechet shape scale location
HDR.gengamma d, shape1 k, shape2 rate, scale
HDR.gumbelII shape scale
HDR.lgamma shape scale location
HDR.matching size prob trials & approx

The table above shows the parameters in each of the distributions. Some have default values, but most need to be specified. (For the gamma distribution you should specify either the rate or scale but not both.)

Examples

Run this code
# NOT RUN {
HDR.norm(.95)
# }

Run the code above in your browser using DataLab