Let \(f(x, y)\) be the pdf of a random vector \(\left( X, Y \right) \in \mathbb{R}^2\). Then for \(\alpha \in (0,1)\) the \(100(1 - \alpha)\%\) highest density region (HDR) is the subset \(R(f_{\alpha}) \subset \mathbb{R}^2\) such that \(R(f_{\alpha}) = \{(x, y): f (x, y) \geq f_{\alpha}\}\) where \(f_{\alpha}\) is the largest constant such that \(\mathrm{P}\left[(X, Y) \in R(f_{\alpha})\right] \geq 1 - \alpha\).
geom_hdr()
geom_hdr_fun()
df <- data.frame(x = rexp(100, 1), y = rexp(100, 1))
# pdf for parametric density estimate
f <- \(x, y, lambda) dexp(x, lambda[1]) * dexp(y, lambda[2])
# estimate parameters governing joint pdf
lambda_hat <- apply(df, 2, mean)
# make plot
ggplot(df, aes(x, y)) +
geom_hdr_fun(
fun = f, args = list(lambda = lambda_hat),
xlim = c(0, 7), ylim = c(0, 7)
) +
geom_point(fill = "lightgreen", shape = 21) +
coord_fixed()
geom
’sJames Otto (Baylor University)