Skip to contents

This function implements a traditional EMG synergy approach: select the minimum r (number of factors) that achieves a target VAF (Variance Accounted For) threshold. This is commonly used in motor control research where VAF >= 90-95 percent is desired.

Usage

select_r_by_vaf_mfa(
  list_of_data,
  K,
  rvec = 1:5,
  vaf_threshold = 0.9,
  max_iter = 50,
  nIterFA = 5,
  tol = 0.001,
  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 data matrices, each (T_i x M).

K

Number of clusters (must be pre-specified).

rvec

Vector of candidate r values to test.

vaf_threshold

Target VAF threshold (default: 0.90 for 90 percent).

max_iter

Maximum EM iterations.

nIterFA

Sub-iterations within the factor-analyzer update.

tol

Convergence tolerance.

n_init

Number of random initializations.

use_kmeans_init

Whether to use k-means initialization.

subject_rdim_for_kmeans

Dimension for PCA-based features.

mc_cores

Number of CPU cores for parallelization.

n_threads

Number of OpenMP threads.

Value

A list containing: summary (data frame with r, VAF, BIC for each r), best_r_vaf (minimum r achieving VAF threshold), best_r_bic (optimal r by BIC), best_model_vaf (model with minimum r achieving threshold), and best_model_bic (model with optimal BIC).

Details

This function fits MFA models for each r in rvec with fixed K, computes both VAF and BIC, and returns: 1. The minimum r that achieves the VAF threshold (traditional approach) 2. The optimal r by BIC (statistical approach)

Users can compare both criteria to make informed model selection decisions.