Skip to contents

This function extracts cluster assignment labels from a fitted MFA or MPCA model object. It searches through common field names used by different model implementations.

Usage

extract_cluster_labels(fit)

Arguments

fit

A fitted model object (MFA or MPCA).

Value

An integer vector of cluster assignments (1 to K), or NA if cluster labels cannot be extracted.

Details

The function searches for cluster labels in the following fields (in order):

  • z: Standard field for MFA/MPCA models

  • cluster: Alternative naming

  • clusters: Plural form

  • class: Classification result

  • z_hat: Estimated assignments

  • cl: Short form

  • hard_cluster: Hard assignment from soft clustering

  • labels: Generic label field

If the model has a resp (responsibility) matrix but no hard assignments, the function computes hard assignments using MAP (maximum a posteriori).

Examples

if (FALSE) { # \dontrun{
fit <- mfa_em_fit(list_of_data, K = 3, r = 2)
pred_cluster <- extract_cluster_labels(fit)
} # }