hypvolgmm_hdlevel: Default HDR level defining the GMM hull

View source: R/hypvolgmm.R

hypvolgmm_hdlevelR Documentation

Default HDR level defining the GMM hull

Description

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].

Usage

hypvolgmm_hdlevel(dens, ...)

Arguments

dens

A vector of density estimates for the n observed data points.

...

Further arguments passed to or from other methods.

Value

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.

Author(s)

Luca Scrucca

Examples

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)


mclustAddons documentation built on Dec. 3, 2025, 5:08 p.m.