Learn R Programming

hdrcde (version 3.5.0)

hdr.cde: Calculate highest density regions continuously over some conditioned variable.

Description

Calculates and plots highest density regions for a conditional density estimate. Uses output from cde().

Usage

hdr.cde(den, prob = c(0.5, 0.95, 0.99), plot = TRUE, nn = 1000, ...)

Value

hdr

array (a,b,c) where where a specifies conditioning value, b gives the HDR endpoints and c gives the probability coverage.

modes

estimated mode of each conditional density

The result is returned invisibly if plot=TRUE.

Arguments

den

Conditional density in the same format as the output from cde().

prob

Probability coverage level for HDRs

plot

Should HDRs be plotted? If FALSE, results are returned.

nn

Number of points to be sampled from each density when estimating the HDRs.

...

Other arguments passed to plot.hdrcde().

Author

Rob J Hyndman

References

Hyndman, R.J., Bashtannyk, D.M. and Grunwald, G.K. (1996) "Estimating and visualizing conditional densities". Journal of Computational and Graphical Statistics, 5, 315-336.

See Also

plot.hdrcde(), cde(),

Examples

Run this code
faithful.cde <- cde(faithful$waiting, faithful$eruptions)
faithful.hdr <- hdr.cde(faithful.cde, prob = c(0.50, 0.95))
faithful.hdr
plot(faithful.hdr, xlab = "Waiting time", ylab = "Duration time")

Run the code above in your browser using DataLab