Orchestrates a comprehensive parameter sweep experiment to evaluate the performance of MFA, MPCA, and baseline methods using the v2 dynamic synergy simulator with three orthogonal control axes.
Usage
run_param_sweep(
test = FALSE,
cores = 4,
output_dir = NULL,
param_grid = NULL,
verbose = TRUE
)Arguments
- test
Logical. If TRUE, uses a smaller test grid for quick validation. Default is FALSE (full parameter grid).
- cores
Integer. Number of CPU cores to use for parallel processing. Default is 4. Set to 1 for sequential processing.
- output_dir
Character. Directory to save results. Default is "inst/paper/results_sweep" if it exists (repo use), otherwise "results_sweep" in the current working directory.
- param_grid
Optional. Custom parameter grid data frame. If NULL, uses the built-in full or test grid based on the
testparameter.- verbose
Logical. If TRUE, prints progress information. Default is TRUE.
Value
Invisibly returns a list containing:
raw_results: Data frame with raw results from all runsaggregated_results: Data frame with results aggregated across seedssummary_file: Path to the summary CSV filewin_rates_file: Path to the win rates CSV fileoutput_dir: Directory where results were saved
Details
The parameter sweep evaluates:
6 methods: SingleFA, SinglePCA, TwoStep_FA, TwoStep_PCA, MixtureFA, MixturePCA
2 model types: Mixture (static) vs Dynamic_v2 (with 3 orthogonal axes)
Metrics: ARI (clustering accuracy), VAF (reconstruction quality), BIC, SSE
Variable parameters: N, K, r, cluster_sep_spatial, cluster_sep_temporal, cluster_sep_stability
For parallel processing (cores > 1), the function uses parLapplyLB for
load balancing. If the pbapply package is installed, a progress bar
will be displayed.
Examples
if (FALSE) { # \dontrun{
# Run test mode with 2 cores
results <- run_param_sweep(test = TRUE, cores = 2)
# Run full sweep with 8 cores
results <- run_param_sweep(test = FALSE, cores = 8)
# Run with custom output directory
results <- run_param_sweep(test = TRUE, cores = 2, output_dir = "my_results")
# Run with custom parameter grid
library(dplyr)
custom_grid <- expand.grid(
N = c(20, 50),
K = c(2, 3),
r = 2,
M = 8,
T_each = 200,
cluster_sep_spatial = c(0.3, 0.6),
cluster_sep_temporal = 0.6,
cluster_sep_stability = 1.0,
seed = 1:3,
stringsAsFactors = FALSE
)
custom_grid$run_id <- seq_len(nrow(custom_grid))
results <- run_param_sweep(
param_grid = custom_grid,
cores = 8,
output_dir = "inst/paper/results_custom"
)
# Access results directly
head(results$raw_results)
head(results$aggregated_results)
} # }