Learn R Programming

BNPdensity (version 2025.7.29)

compute_optimal_clustering: Compute the optimal clustering from an MCMC sample

Description

Summarizes the posterior on all possible clusterings by an optimal clustering where optimality is defined as minimizing the posterior expectation of a specific loss function. Supports GreedyEPL and SALSO.

Usage

compute_optimal_clustering(fit, method = "GreedyEPL", loss_type = "VI")

Value

A vector of integers with the same size as the data, indicating the allocation of each data point.

Arguments

fit

The fitted object, obtained from one of the MixNRMIx functions

method

The method to use for optimal clustering. Can be "GreedyEPL" or "SALSO". Defaults to "GreedyEPL".

loss_type

Defines the loss function to be used in the expected posterior loss minimization. Only used if method is "GreedyEPL". Can be one of "VI", "B", "NVI", or "NID". Defaults to "VI".

Examples

Run this code
if (FALSE) {
data(acidity)
x <- acidity
# Fitting the model under default specifications
out <- MixNRMI1(x)
compute_optimal_clustering(out)
}

Run the code above in your browser using DataLab