| hypvolgmm_hdlevel | R Documentation |
Compute default HDR level used to define the GMM hull. This is obtained by
fitting a two-segment piecewise linear regression model (i.e., single change
point model) to a grid of (\alpha, h_\alpha) values with \alpha
in [0.9, 1].
hypvolgmm_hdlevel(dens, ...)
dens |
A vector of density estimates for the |
... |
Further arguments passed to or from other methods. |
Returns a list containing the following elements:
alpha A vector of alpha values specifying the HDR levels.
h_alpha A vector of HDR density values corresponding to alpha.
pcwsreg The two-segment piecewise linear regression model.
hdl The optimal HDR level selected as the change-point value.
h The HDR density values corresponding to the optimal HDR level.
Luca Scrucca
x = subset(faithful, eruptions > 3)
mod = densityMclust(x, plot = FALSE)
out = hypvolgmm_hdlevel(mod$density)
with(out,
{
plot(alpha, h_alpha, type = "b", pch = 20)
lines(alpha[1:pcwsreg$c],
pcwsreg$a1 * alpha[1:pcwsreg$c] + pcwsreg$b1,
lty = 2, lwd = 2, col = "red2")
lines(alpha[pcwsreg$c:length(alpha)],
pcwsreg$a2 * alpha[pcwsreg$c:length(alpha)] + pcwsreg$b2,
lty = 2, lwd = 2, col = "red2")
abline(v = hdl, lty = 3, col = "red2", lwd = 2)
abline(h = h, lty = 3, col = "red2", lwd = 2)
})
plot(x, xlim = c(2,6), ylim = c(60,100))
surfacePlot(data = mod$data, parameters = mod$parameters,
what = "density", type = "contour",
levels = c(out$h, min(mod$density)),
xlim = c(2,6), ylim = c(60,100), lty = c(1,2),
add = TRUE, drawlabels = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.