Generate v2 Dynamic Synergy Data for Model Selection Experiments
Source:R/simulate_synergy_export.R
generate_synergy_data.RdThis function provides a standardized interface for generating v2 dynamic
synergy data suitable for model selection experiments. It wraps
simulate_dynamic_synergy_data and returns data in a format
optimized for parameter sweep experiments with model selection.
Arguments
- N
Number of subjects (time series). Default is 30.
- K
Number of clusters (subgroups). Default is 3.
- r
Number of synergies per cluster. 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. Default is 1.0.
- cluster_sep_temporal
Numeric scalar (0-2) controlling temporal coordination differentiation between clusters. Default is 1.0.
- cluster_sep_stability
Numeric scalar (0-2) controlling stability-adaptability differentiation between clusters. Default is 1.0.
- freq_range
Numeric vector of length 2 specifying the range of base frequencies (in Hz) for the periodic activation signals. Default is c(0.5, 3.0).
- amp_range
Numeric vector of length 2 specifying the range of amplitudes for the periodic activation signals. Default is c(0.5, 1.5).
- base_level
Numeric scalar specifying the baseline activation level. Default is 0.05.
- rectify_output
Logical; if TRUE, apply half-wave rectification. Default is TRUE.
- seed
Random seed for reproducibility. Required for deterministic results.
Value
A list with the following components:
list_of_dataList of length N; each element is a (T_each x M) matrix of generated EMG signals. This is the standard input format for MFA/MPCA fitting.
true_clusterInteger vector of length N indicating true cluster assignments (1 to K). Named as
true_clusterfor consistency.true_Lambda_listList of length K; each element is a (M x r) matrix of true cluster-specific synergy loadings. Essential for subspace recovery evaluation. This is the canonical name for ground truth basis matrices.
paramsList containing all generation parameters for reproducibility. Includes both canonical short names (T, sep_spatial, sep_temporal, sep_stability) and full names (T_each, cluster_sep_spatial, etc.) for compatibility. Also includes r_mode = "global" for future extension.
Lambda_listList of length K; each element is a (M x r) matrix of cluster-specific synergy loadings. Kept for backward compatibility; identical to
true_Lambda_list.C_listList of length N; each element is a (T_each x r) matrix of synergy activation signals (for visualization/validation).
spatial_paramsList containing spatial structure parameters for each cluster.
temporal_paramsList containing temporal coordination parameters for each cluster.
stability_paramsList containing stability-adaptability parameters for each cluster.
Details
This function is designed for use in parameter sweep experiments where model
selection (K, r) is performed on generated data. The key differences from
simulate_dynamic_synergy_data are:
Returns
list_of_data(renamed fromX_list) for consistency with fitting functionsReturns
true_cluster(renamed fromz_true) for consistency with evaluation functionsIncludes a
paramslist for tracking generation parametersSeed is required (not optional) to ensure reproducibility
See also
simulate_dynamic_synergy_data for the underlying
simulation function, run_param_sweep_modelsel for parameter
sweep experiments.
Examples
if (FALSE) { # \dontrun{
# Generate data for model selection experiment
data <- generate_synergy_data(
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
)
# Access the data for fitting
list_of_data <- data$list_of_data
true_cluster <- data$true_cluster
# Fit MFA model
fit <- mfa_em_fit(list_of_data, K = 3, r = 3)
# Evaluate clustering accuracy
ari <- mclust::adjustedRandIndex(true_cluster, fit$z)
} # }