Skip to contents

Selects the optimal number of factors (r) for a given number of clusters (K) by maximizing the VSS (Very Simple Structure) criterion, subject to constraints on VAF or BIC.

Usage

select_r_by_vss_mpca(
  list_of_data,
  K,
  rvec = 1:6,
  vss_threshold = 0.5,
  vaf_threshold = 0.9,
  max_iter = 50,
  nIterPCA = 5,
  tol = 0.001,
  method = "EM",
  n_init = 1,
  use_kmeans_init = TRUE,
  subject_rdim_for_kmeans = 2,
  mc_cores = 1,
  n_threads = 1
)

Arguments

list_of_data

A list of N matrices, each (T_i x M).

K

Number of clusters (fixed).

rvec

Vector of candidate r values to evaluate.

vss_threshold

Threshold for determining strong vs weak loadings. Default is 0.5.

vaf_threshold

Minimum VAF threshold. Models with VAF below this are excluded. Default is 0.9.

max_iter

Maximum EM iterations.

nIterPCA

Sub-iterations for PCA update.

tol

Convergence tolerance.

method

"EM" or "closed_form".

n_init

Number of random initializations.

use_kmeans_init

Whether to use k-means initialization.

subject_rdim_for_kmeans

Dimension for k-means features.

mc_cores

Number of cores for parallelization.

n_threads

Number of OpenMP threads.

Value

A list with:

best_r

The selected r value.

summary

A data.frame with columns r, BIC, VAF, VSS.

best_model

The fitted model for the selected r.

Details

This function fits MPCA models for each r in rvec with fixed K, and evaluates the VSS criterion. The optimal r is selected by maximizing VSS among models satisfying VAF >= vaf_threshold.

Higher VSS values indicate better simple structure, where each muscle loads strongly on exactly one synergy.

Examples

if (FALSE) { # \dontrun{
result <- select_r_by_vss_mpca(
  list_of_data, K = 3, rvec = 1:5,
  vss_threshold = 0.5, vaf_threshold = 0.9
)
print(result$summary)
best_model <- result$best_model
} # }