Description Usage Arguments Details Value Author(s) References See Also Examples

Calculates and plots highest density regions in one dimension including the HDR boxplot.

1 2 3 4 5 6 7 8 9 10 11 12 | ```
hdr(x = NULL, prob = c(50, 95, 99), den = NULL, h = hdrbw(BoxCox(x,
lambda), mean(prob)), lambda = 1, nn = 5000, all.modes = FALSE)
hdr.den(x, prob = c(50, 95, 99), den, h = hdrbw(BoxCox(x, lambda),
mean(prob)), lambda = 1, xlab = NULL, ylab = "Density",
ylim = NULL, plot.lines = TRUE, col = 2:8, bgcol = "gray",
legend = FALSE, ...)
hdr.boxplot(x, prob = c(99, 50), h = hdrbw(BoxCox(x, lambda),
mean(prob)), lambda = 1, boxlabels = "", col = gray((9:1)/10),
main = "", xlab = "", ylab = "", pch = 1, border = 1,
outline = TRUE, space = 0.25, ...)
``` |

`x` |
Numeric vector containing data. In |

`prob` |
Probability coverage required for HDRs |

`den` |
Density of data as list with components |

`h` |
Optional bandwidth for calculation of density. |

`lambda` |
Box-Cox transformation parameter where |

`nn` |
Number of random numbers used in computing f-alpha quantiles. |

`all.modes` |
Return all local modes or just the global mode? |

`xlab` |
Label for x-axis. |

`ylab` |
Label for y-axis. |

`ylim` |
Limits for y-axis. |

`plot.lines` |
If |

`col` |
Colours for regions of each box. |

`bgcol` |
Colours for the background behind the boxes. Default |

`legend` |
If |

`...` |
Other arguments passed to plot. |

`boxlabels` |
Label for each box plotted. |

`main` |
Overall title for the plot. |

`pch` |
Plotting character. |

`border` |
Width of border of box. |

`outline` |
If not <code>TRUE</code>, the outliers are not drawn. |

`space` |
The space between each box, between 0 and 0.5. |

Either `x`

or `den`

must be provided. When `x`

is provided,
the density is estimated using kernel density estimation. A Box-Cox
transformation is used if `lambda!=1`

, as described in Wand, Marron and
Ruppert (1991). This allows the density estimate to be non-zero only on the
positive real line. The default kernel bandwidth `h`

is selected using
the algorithm of Samworth and Wand (2010).

Hyndman's (1996) density quantile algorithm is used for calculation.
`hdr.den`

plots the density with the HDRs superimposed.
`hdr.boxplot`

displays a boxplot based on HDRs.

`hdr.boxplot`

retuns nothing. `hdr`

and `hdr.den`

return a list of three components:

`hdr` |
The endpoints of each interval in each HDR |

`mode` |
The estimated mode of the density. |

`falpha` |
The value of the density at the boundaries of each HDR. |

Rob J Hyndman

Hyndman, R.J. (1996) Computing and graphing highest density
regions. *American Statistician*, **50**, 120-126.

Samworth, R.J. and Wand, M.P. (2010). Asymptotics and optimal bandwidth
selection for highest density region estimation. *The Annals of
Statistics*, **38**, 1767-1792.

Wand, M.P., Marron, J S., Ruppert, D. (1991) Transformations in density
estimation. *Journal of the American Statistical Association*,
**86**, 343-353.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
# Old faithful eruption duration times
hdr(faithful$eruptions)
hdr.boxplot(faithful$eruptions)
hdr.den(faithful$eruptions)
# Simple bimodal example
x <- c(rnorm(100,0,1), rnorm(100,5,1))
par(mfrow=c(1,2))
boxplot(x)
hdr.boxplot(x)
par(mfrow=c(1,1))
hdr.den(x)
# Highly skewed example
x <- exp(rnorm(100,0,1))
par(mfrow=c(1,2))
boxplot(x)
hdr.boxplot(x,lambda=0)
``` |

hdrcde documentation built on May 1, 2019, 9:21 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.