Skip to contents

This function uses the v2 dynamic synergy simulator (simulate_dynamic_synergy_data), which provides three orthogonal control axes: spatial structure, temporal coordination, and stability-adaptability. This allows for systematic evaluation of how different motor control strategies affect muscle synergy structures.

Usage

compare_static_vs_dynamic(
  model_types = c("Dynamic_v2"),
  N = 30,
  K = 3,
  r = 3,
  M = 8,
  T_each = 200,
  cluster_sep_spatial = 1,
  cluster_sep_temporal = 1,
  cluster_sep_stability = 1,
  seed = 123,
  output_dir = "results/compare_dynamic_v2",
  n_init = 1,
  use_kmeans_init = FALSE,
  mc_cores = 1
)

Arguments

model_types

Character vector specifying which model types to use. Default is c("Dynamic_v2"). Only "Dynamic_v2" is supported.

N

Number of subjects (time series). Default is 30.

K

True number of clusters. Default is 3.

r

True factor dimension (number of synergies). Default is 3.

M

Number of observed channels (muscles). Default is 8.

T_each

Time-series length per subject. Default is 200.

cluster_sep_spatial

Numeric scalar (0-2) controlling spatial structure differentiation between clusters. Higher values create more distinct spatial modules. Default is 1.0.

cluster_sep_temporal

Numeric scalar (0-2) controlling temporal coordination differentiation between clusters. Higher values create more distinct temporal patterns. Default is 1.0.

cluster_sep_stability

Numeric scalar (0-2) controlling stability-adaptability differentiation between clusters. Higher values create more distinct noise profiles. Default is 1.0.

seed

Random seed for data generation. Default is 123.

output_dir

Directory path where results will be saved. Default is "results/compare_dynamic_v2". The directory will be created if it doesn't exist.

n_init

Number of random initializations for mixture methods. Default is 1.

use_kmeans_init

Logical; if TRUE, also try k-means initialization. Default is FALSE.

mc_cores

Number of cores for parallel computation. Default is 1.

Value

A data frame with the following columns:

model_type

Character string: "Dynamic_v2"

Method

Analysis method name (e.g., "MixtureFA", "SinglePCA")

BIC

Bayesian Information Criterion

ARI

Adjusted Rand Index (clustering accuracy)

SSE

Sum of Squared Errors (reconstruction error)

VAF

Variance Accounted For (1 - SSE/totalSST)

seed

Random seed used for data generation

cluster_sep_spatial

Spatial separation parameter

cluster_sep_temporal

Temporal separation parameter

cluster_sep_stability

Stability separation parameter

N

Number of subjects

K

Number of clusters

r

Number of synergies

M

Number of muscles

T_each

Time series length

Details

The function generates data using the Dynamic_v2 model and applies six analysis methods (SingleFA, SinglePCA, TwoStep_FA, TwoStep_PCA, MixtureFA, MixturePCA) to evaluate their performance.

The function saves results to an RDS file in the specified output directory with filename format results_YYYY-MM-DD.rds.

Data is generated using simulate_dynamic_synergy_data, which creates time-varying synergy activation patterns with three orthogonal control axes: (1) Spatial structure, (2) Temporal coordination, and (3) Stability-Adaptability.

The generated data is analyzed using six methods, allowing comparison of method performance on realistic dynamic synergy data.

Examples

if (FALSE) { # \dontrun{
# Basic comparison with v2 simulator
results <- compare_static_vs_dynamic(
  N = 30, K = 3, r = 3, M = 8, T_each = 200,
  cluster_sep_spatial = 1.0,
  cluster_sep_temporal = 1.0,
  cluster_sep_stability = 1.0,
  seed = 123
)
print(results)

# Compare with high spatial separation
results_spatial <- compare_static_vs_dynamic(
  N = 30, K = 3, r = 3, M = 8, T_each = 200,
  cluster_sep_spatial = 2.0,
  cluster_sep_temporal = 0.5,
  cluster_sep_stability = 1.0,
  seed = 456
)

# Visualize results
library(ggplot2)
ggplot(results, aes(x = Method, y = ARI)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  labs(title = "Method Performance on Dynamic v2 Data")
} # }