Skip to contents

Creates a heatmap showing Sum of Squared Errors (SSE) for each subject across different methods. This helps identify which methods perform poorly for specific subjects and reveals the instability of the Two-step approach.

Usage

plot_sse_heatmap(
  results_list,
  list_of_data,
  log_scale = TRUE,
  theme_base_size = 12
)

Arguments

results_list

A named list of method results. Each element should be a fitted model object containing SSE information. Names should be method names (e.g., "TwoStep_PCA", "MixtureFA", "SinglePCA").

list_of_data

List of data matrices, one per subject (T_i x M). Required to compute per-subject SSE if not already in results.

log_scale

Logical. If TRUE, displays log10(SSE) instead of raw SSE. Recommended for better visualization when SSE values span multiple orders of magnitude. Default is TRUE.

theme_base_size

Base font size for the plot theme. Default is 12.

Value

A ggplot object showing a heatmap of SSE values (subjects x methods).

Details

This function computes per-subject reconstruction errors for multiple methods and displays them as a heatmap. Darker colors indicate higher errors (worse reconstruction). This visualization is useful for:

  • Comparing reconstruction quality across methods

  • Identifying subjects that are poorly reconstructed by Two-step methods

  • Revealing instability in Two-step assignments (high SSE for misclassified subjects)

  • Showing that mixture models provide more consistent reconstruction

The function expects results from fit_all_methods_on_data() or similar comparison functions. It computes per-subject SSE by reconstructing each subject's data using the assigned cluster model.

Examples

if (FALSE) { # \dontrun{
# Simulate data
sim <- simulate_dynamic_synergy_data(N=30, K=3, r=3, M=8, T_each=200)

# Fit all methods
results <- fit_all_methods_on_data(
  sim$list_of_data, z_true=sim$z_true,
  N=30, K=3, r=3, M=8, seed=123
)

# Create SSE heatmap
plot_sse_heatmap(results, sim$list_of_data)

# Use linear scale instead of log scale
plot_sse_heatmap(results, sim$list_of_data, log_scale=FALSE)
} # }