Skip to contents

Computes subspace similarity scores for each cluster, using the aligned mapping between estimated and true clusters. This provides a detailed assessment of how well each cluster's subspace is recovered.

Usage

compute_clusterwise_subspace_score(true_Lambda_list, est_Lambda_list, mapping)

Arguments

true_Lambda_list

List of K_true matrices, each (M x r) representing true cluster-specific basis matrices.

est_Lambda_list

List of K_hat matrices, each (M x r_hat) representing estimated cluster-specific basis matrices.

mapping

Named integer vector from align_clusters_to_truth, mapping estimated cluster labels to true cluster labels.

Value

A list with:

scores

Named numeric vector of subspace similarity scores for each true cluster (names are cluster indices as characters).

mean_score

Numeric scalar: mean of non-NA scores.

n_matched

Integer: number of true clusters with a valid estimated match.

Returns a list with NA values if inputs are invalid.

Details

For each true cluster k:

  1. Find the estimated cluster that maps to k (using the mapping)

  2. Compute subspace similarity between true_Lambda_list[[k]] and the corresponding estimated basis

  3. If no estimated cluster maps to k, the score is NA

This function is NA-safe: if estimation failed for some clusters (NULL or invalid matrices), those clusters receive NA scores and are excluded from the mean calculation.

Examples

if (FALSE) { # \dontrun{
# Generate data and fit model
data <- generate_synergy_data(N = 30, K = 3, r = 2, seed = 123)
fit <- mfa_em_fit(data$list_of_data, K = 3, r = 2)

# Align clusters
alignment <- align_clusters_to_truth(data$true_cluster, fit$z)

# Compute cluster-wise scores
scores <- compute_clusterwise_subspace_score(
  data$true_Lambda_list,
  fit$Lambda,
  alignment$mapping
)
} # }