Package: medsim 0.6.0.9000

medsim: Simulation Infrastructure for Mediation Analysis

Provides standardized infrastructure for conducting Monte Carlo simulation studies in mediation analysis. Features include environment-aware execution (local vs HPC cluster), parallel processing with progress reporting, ground truth caching, automated result analysis, and publication-ready visualization. Designed to work seamlessly with the mediationverse ecosystem: 'medfit', 'probmed', 'RMediation', and 'medrobust'.

Authors:Davood Tofighi [aut, cre]

medsim_0.6.0.9000.tar.gz
medsim_0.6.0.9000.zip(r-4.7-any)medsim_0.6.0.9000.zip(r-4.6-any)medsim_0.6.0.9000.zip(r-4.5-any)
medsim_0.6.0.9000.tgz(r-4.6-any)medsim_0.6.0.9000.tgz(r-4.5-any)
medsim_0.6.0.9000.tar.gz(r-4.7-any)medsim_0.6.0.9000.tar.gz(r-4.6-any)
medsim_0.6.0.9000.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
medsim/json (API)

# Install 'medsim' in R:
install.packages('medsim', repos = c('https://data-wise.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/data-wise/medsim/issues

Pkgdown/docs site:https://data-wise.github.io

On CRAN:

Conda:

quarto

4.92 score 20 scripts 63 exports 26 dependencies

Last updated from:a2659822b9 (on dev). Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK164
source / vignettesOK329
linux-releaseOK171
macos-releaseOK179
macos-oldrelOK157
windows-develOK200
windows-releaseOK209
windows-oldrelOK190
wasm-releaseOK115

Exports:medsim_amputatemedsim_analyzemedsim_analyze_coveragemedsim_analyze_performancemedsim_analyze_powermedsim_audit_resultsmedsim_cache_clearmedsim_cache_existsmedsim_cache_infomedsim_cache_initmedsim_cache_listmedsim_cache_loadmedsim_cache_savemedsim_check_resultsmedsim_combine_chunksmedsim_compare_configsmedsim_compare_methodsmedsim_configmedsim_detect_coresmedsim_detect_environmentmedsim_estimandmedsim_estimate_speedupmedsim_figuresmedsim_get_optimal_coresmedsim_method_boundsmedsim_method_gaugemedsim_method_ipwmedsim_method_mbco_mimedsim_method_mc_cimedsim_method_pmed_mbcomedsim_method_sobolmedsim_nsim_for_mcsemedsim_plot_combined_panelmedsim_plot_coveragemedsim_plot_error_boxplotmedsim_plot_se_vs_estimatemedsim_plot_timingmedsim_rnonnormalmedsim_runmedsim_run_chunkmedsim_run_parallelmedsim_scenariomedsim_scenario_dmmedsim_scenario_gaugemedsim_scenario_missingmedsim_scenario_missing_gridmedsim_scenario_numericmedsim_scenario_pmedmedsim_scenario_sobolmedsim_scenarios_mediationmedsim_summarize_branch_switchmedsim_table_accuracymedsim_table_comparisonmedsim_table_coveragemedsim_table_performancemedsim_table_powermedsim_table_timingmedsim_tablesmedsim_tables_workflowmedsim_validate_scenariomedsim_workflowmedsim_write_submit_scriptmedsim_write_table

Dependencies:clicpp11dplyrfarvergenericsggplot2gluegtableisobandlabelinglifecyclemagrittrpbapplypillarpkgconfigR6RColorBrewerrlangS7scalestibbletidyselectutf8vctrsviridisLitewithr

Missing-Data Mediation: MBCO-MI vs. Monte-Carlo CI
Introduction | Installation | Step 1: Generate Nonnormal Data | Step 2: Insert Missingness | Step 3: Define a Missing-Data Scenario | Step 4: Run Both Estimators | Fixed-branch correction and the reference degrees of freedom | Step 5: Branch-Switch Diagnostics | Optional: Inverse-Probability Weighting | Next Steps

Last update: 2026-10-17
Started: 2026-07-11

Cookbook: Recipes for Common Tasks
Design | Build a factorial grid of scenarios | Vary the sample size | Nonnormal variables | Missing data | Running | Smoke-test before a long run | Choose the number of replications | Keep a scratch run out of your project | Use several cores | Methods that sometimes fail | Run on a SLURM cluster | Saving and reporting | Save and reload results | Bias with Monte Carlo SEs | Write a table as CSV or Markdown | Restyle a figure

Last update: 2026-10-15
Started: 2026-10-14

Tutorial: Your First Coverage Study
What you will build | Step 1: Describe the data-generating model | Checkpoint | Scenario names are seeds | Step 2: Write the estimator | Step 3: State the truth | Step 4: Smoke test, then the real run | Where files go | Step 5: Read the results | Coverage | Type I error and power | Bias and standard errors | What you learned | Exercises | Next

Last update: 2026-10-15
Started: 2026-10-14

Analyzing and Reporting Simulation Results
Overview | The results object | Accuracy: medsim_analyze() | Performance with Monte Carlo SEs | Coverage and rejection rates | How many replications? | Comparing methods fairly | Keep scenario names fixed | Tables | Figures | Everything at once | Reference

Last update: 2026-10-15
Started: 2026-10-14

Getting Started with medsim
Introduction | Installation | Quick Start | Step 1: Define Your Method | Step 2: Configure the Simulation | Step 3: Select Scenarios | Step 4: Run the Simulation | Step 5: Analyze Results | Execution Modes | Custom Scenarios | HPC Cluster Support | Next Steps

Last update: 2026-10-14
Started: 2025-12-04

Cluster Testing: the two-tier model (Tier A on CRAN, Tier B on Hopper)
Why two tiers | The structural reason FORK-RNG can only be Tier B | The self-contained synthetic study | Running Tier B | B2 — end-to-end coverage (the real number) | Combining runs under an integrity audit | B3 — the can-fail dogfood (planted defect) | B4 — many-core FORK RNG realism (the sole FORK guard) | B5 — production-grid seed-collision check | Pilot before scale | Summary

Last update: 2026-08-23
Started: 2026-07-11

Estimand Kinds: Sobol Variance Share and Gauge Residual
Introduction | Sobol Variance-Share Proportion Mediated | Gauge-Residual Estimand | Comparing the Two | Next Steps

Last update: 2026-07-11
Started: 2026-07-11

Readme and manuals

Help Manual

Help pageTopics
Insert missing values under MCAR / MAR / MNARmedsim_amputate
Analyze Simulation Resultsmedsim_analyze
Analyze Coverage Ratesmedsim_analyze_coverage
ADEMP performance summary (bias, SEs, RMSE) with Monte Carlo SEsmedsim_analyze_performance
Analyze Statistical Powermedsim_analyze_power
Audit a combined results object for chunked-run integrity violationsmedsim_audit_results
Clear Cachemedsim_cache_clear
Check if Cache Existsmedsim_cache_exists
Get Cache Infomedsim_cache_info
Initialize Cache Directorymedsim_cache_init
List Cache Filesmedsim_cache_list
Load Object from Cachemedsim_cache_load
Save Object to Cachemedsim_cache_save
Check Results for Errorsmedsim_check_results
Combine chunk RDS files produced by medsim_run_chunk()medsim_combine_chunks
Compare Multiple Configurationsmedsim_compare_configs
Compare Multiple Methodsmedsim_compare_methods
Create Simulation Configurationmedsim_config
Detect Number of Available Coresmedsim_detect_cores
Detect Computing Environmentmedsim_detect_environment
Declare the estimand kind for a simulation scenariomedsim_estimand
Estimate Parallel Speedupmedsim_estimate_speedup
Generate all standard figures from simulation resultsmedsim_figures
Get Optimal Number of Coresmedsim_get_optimal_cores
Bounds estimator adapter for differential-misclassification (DM) studiesmedsim_method_bounds
Gauge-residual (P_med + W) estimator wrappermedsim_method_gauge
Thin IPW estimator adapter (robustness appendix)medsim_method_ipw
MBCO-MI estimator adaptermedsim_method_mbco_mi
Monte-Carlo CI estimator adaptermedsim_method_mc_ci
MBCO confidence interval for P_med (two-branch method)medsim_method_pmed_mbco
Sobol / functional-ANOVA variance-share estimator wrappermedsim_method_sobol
Replications needed for a target coverage Monte Carlo SEmedsim_nsim_for_mcse
Create Combined Multi-Panel Figuremedsim_plot_combined_panel
Plot Coverage Ratesmedsim_plot_coverage
Plot Error Distribution Boxplotsmedsim_plot_error_boxplot
Diagnostic scatter of model SE against the point estimatemedsim_plot_se_vs_estimate
Plot Timing Comparisonmedsim_plot_timing
Draw nonnormal values with a target marginal skew/kurtosismedsim_rnonnormal
Run Simulation Studymedsim_run
Run one chunk of a chunked SLURM array simulationmedsim_run_chunk
Run Tasks in Parallelmedsim_run_parallel
Create Custom Simulation Scenariomedsim_scenario
Construct a differential-misclassification (DM) mediation scenariomedsim_scenario_dm
Create a gauge-residual (P_med + W) simulation scenariomedsim_scenario_gauge
Construct a missing-data mediation scenariomedsim_scenario_missing
Build the full factorial of missing-data scenariosmedsim_scenario_missing_grid
Create a numeric accuracy simulation scenariomedsim_scenario_numeric
Create a P_med simulation scenariomedsim_scenario_pmed
Create a Sobol / functional-ANOVA variance-share simulation scenariomedsim_scenario_sobol
Create Standard Mediation Scenariosmedsim_scenarios_mediation
Summarize the MBCO majority-branch rate per scenariomedsim_summarize_branch_switch
Generate Accuracy Tablemedsim_table_accuracy
Generate Method Comparison Tablemedsim_table_comparison
Generate Coverage Tablemedsim_table_coverage
Render a performance summary as a LaTeX tablemedsim_table_performance
Generate Power Tablemedsim_table_power
Generate Timing Comparison Tablemedsim_table_timing
Generate all standard LaTeX tables from simulation resultsmedsim_tables
Generate All Tablesmedsim_tables_workflow
Validate Scenariomedsim_validate_scenario
Generate analysis, figures, and tables from simulation resultsmedsim_workflow
Write a SLURM array submit script for chunked simulation jobsmedsim_write_submit_script
Write Table to Filemedsim_write_table
Print Analysis Resultsprint.medsim_analysis
Print Method Comparisonprint.medsim_comparison
Print Configuration Summaryprint.medsim_config
Print Coverage Resultsprint.medsim_coverage
Print Power Resultsprint.medsim_power
Print Simulation Resultsprint.medsim_results
Print Scenario Summaryprint.medsim_scenario
Print medsim_tableprint.medsim_table
Summarize Simulation Resultssummary.medsim_results