Highest Density Regions and Conditional Density Estimation
Computation of highest density regions in one and two dimensions, kernel estimation of univariate density functions conditional on one covariate,and multimodal regression.
The R package hdrcde provides tools for computing highest density regions in one and two dimensions, kernel estimates of univariate density functions conditional on one covariate, and multimodal regression.
Author: Rob J Hyndman with contributions from Jochen Einbeck and Matt Wand
This package implements the methods described in the following papers.
- Rob J Hyndman (1996) "Computing and graphing highest density regions". American Statistician, 50, 120-126.
- Rob J Hyndman and David Bashtannyk (1996) "Estimating and visualizing conditional densities". Journal of Computational and Graphical Statistics, 5, 315-336.
- David Bashtannyk, Rob J Hyndman (2001) "Bandwidth selection for kernel conditional density estimation". Computational Statistics and Data Analysis 36(3), 279-298.
- Rob J Hyndman and Qiwei Yao (2002) "Nonparametric estimation and symmetry tests for conditional density functions". Journal of Nonparametric Statistics, 14(3), 259-278.
- Einbeck, J., and Tutz, G. (2006). "Modelling beyond regression functions: an application of multimodal regression to speed-flow data". Journal of the Royal Statistical Society, Series C, 55, 461-475.
- Richard J Samworth and Matthew P Wand (2010) "Asymptotics and optimal bandwidth selection for highest density region estimation". The Annals of Statistics, 38, 1767-1792.
You can install the stable version on
install.packages('hdrcde', dependencies = TRUE)
You can install the development version from
This package is free and open source software, licensed under GPL 3.
- Updated hdr.den() to demonstrate the calculation of hdr more clearly (thanks to Dennis Freuer for the suggestion)
- Added hdrscatterplot() function
- Roxygenized the package
- Added pkgdown site
- Added dependency on mvtnorm to avoid problems with ks.
- Reduced dependency on KernSmooth and changed ::: calls to ::
- New functions hdr.2d() and plot.hdr2d() to return and plot bivariate HDR information.
- Rewritten hdr.boxplot.2d() function.
- Replaced .Internal() calls with new .filled.contour() function.
- Added option to control limits of density estimate in hdr.boxplot.2d()
- Updated references for hdrbw().
* Added color options to hdr.boxplot.2d().
* Modified hdr(), hdr.boxplot() and hdr.den() to allow a Box-Cox transformation to be used when computing the density. This allows the density estimate to be non-zero only on the positive real line.
- Added hdrbw() from Matt Wand to compute better bandwidths for hdr(), hdr.den() and hdr.boxplot().
- Fixed a few bugs in the help files.
- Bug fix in hdr.boxplot.2d(). The show.points option was not working.
- Bug fix: the a bandwidth in cde() when fw=TRUE and use.locfit=TRUE was twice as large as it should have been.
* Bug fix in hdr.boxplot.2d(). It would sometimes plot outliers on a separate plot.
* New argument to hdr.boxplot.2d() to allow the density to be estimated using the kde() function from the ks package.