HDR: Highest density region (HDR)

Description Usage Arguments Details Value Examples

Description

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

Usage

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
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.

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.)

Value

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

Examples

1
HDR.norm(.95)

stat.extend documentation built on Nov. 23, 2021, 5:06 p.m.

Related to HDR in stat.extend...