get_cluster_assignment: Extract the hard cluster assignment from a fitted LUCID model

View source: R/model_extractors.R

get_cluster_assignmentR Documentation

Extract the hard cluster assignment from a fitted LUCID model

Description

Computes the maximum-a-posteriori cluster label for every observation directly from model$inclusion.p, with no need to re-run prediction or supply G/Z/Y again. Shaped exactly like predict_lucid()'s own pred.x: a numeric vector for early, a list by layer for parallel, and a list by stage (recursively shaped) for serial. Labels run 1, ..., K, matching Eq 21 and the row names used by summary().

Usage

get_cluster_assignment(model)

Arguments

model

A fitted early_lucid, lucid_parallel, or lucid_serial object.

Value

A numeric vector (early), a named list by layer (parallel), or a named list by stage (serial, each element shaped like the above depending on that stage's own type).

Examples

idx <- 1:200
G <- sim_data$G[idx, ]
Z <- sim_data$Z[idx, ]
Y_normal <- sim_data$Y_normal[idx, ]
fit <- estimate_lucid(G = G, Z = Z, Y = Y_normal, lucid_model = "early",
                      family = "normal", K = 2,
                      max_itr = 10, max_tot.itr = 30)
table(get_cluster_assignment(fit))

LUCIDus documentation built on Sept. 3, 2026, 1:06 a.m.