Skip to contents

Selects the optimal number of factors (r) for a given number of clusters (K) by combining multiple criteria: BIC, VAF, smoothness penalty, and VSS.

Usage

select_r_multicriteria_mpca(
  list_of_data,
  K,
  rvec = 1:6,
  vaf_threshold = 0.9,
  lambda_smooth = 0.001,
  vss_threshold = 0.5,
  weights = c(BIC = 1, VAF = 1, smoothness = 1, VSS = 1),
  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. Default is 1:6.

vaf_threshold

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

lambda_smooth

Smoothness penalty weight. Default is 1e-3.

vss_threshold

Threshold for VSS criterion. Default is 0.5.

weights

Named vector of weights for each criterion. Default is c(BIC = 1, VAF = 1, smoothness = 1, VSS = 1).

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, smoothness, VSS, composite_score.

best_model

The fitted model for the selected r.

Details

This function combines multiple criteria to select r:

  • BIC: Lower is better (penalizes complexity)

  • VAF: Higher is better (rewards fit quality)

  • Smoothness: Lower is better (penalizes wiggly factors)

  • VSS: Higher is better (rewards simple structure)

Each criterion is normalized to [0, 1] range, then combined using weights: $$ \text{score} = w_{\text{BIC}} \times \text{BIC}_{\text{norm}} + w_{\text{VAF}} \times (1 - \text{VAF}_{\text{norm}}) + w_{\text{smooth}} \times \text{smooth}_{\text{norm}} + w_{\text{VSS}} \times (1 - \text{VSS}_{\text{norm}}) $$

The r with the minimum composite score is selected among models satisfying VAF >= vaf_threshold.

Examples

if (FALSE) { # \dontrun{
result <- select_r_multicriteria_mpca(
  list_of_data, K = 3, rvec = 1:5,
  vaf_threshold = 0.9,
  lambda_smooth = 1e-3,
  weights = c(BIC = 1, VAF = 1, smoothness = 1, VSS = 1)
)
print(result$summary)
best_model <- result$best_model
} # }