simChef culinary school 🍳

Cooking up reliable and realistic simulations

November 20, 2026

Overview of simChef

simChef is a versatile R package to create high-quality simulations with MERITS, with PCS as the guiding framework.

The simChef Vision

  • Allow data scientists to focus on substantive questions with fewer technical distractions
  • Lower the activation barrier to running high-quality simulation studies
  • Provide comprehensive simulation documentation and archive of simulation artifacts for transparency and reproducibility

simChef Highlights

  • A tidy grammar for simulation studies
# create experiment recipe
experiment <- create_experiment(name = "My Experiment") |>
  add_dgp(my_dgp) |>
  add_method(my_method) |>
  add_evaluator(my_evaluator) |>
  add_visualizer(my_visualizer) |>
  add_vary_across(.dgp = my_dgp, n = c(10, 100, 1000))

# run experiment
my_results <- run_experiment(experiment, n_reps = 25, save = TRUE)

# document and visualize experiment results
init_docs(experiment)
render_docs(experiment)

simChef Highlights

  • A tidy grammar for simulation studies

  • Automated documentation and visualization of results

    render_docs(experiment)

simChef Highlights

  • A tidy grammar for simulation studies
  • Automated documentation and visualization of results
  • Caching of results
  • Ease of parallelization
  • Debugging tools
  • Built in library of evaluation and plotting functions

Creating your own simChef simulation

# create experiment recipe
experiment <- create_experiment(name = "My Experiment") |>
  add_dgp(my_dgp) |>
  add_method(my_method) |>
  add_evaluator(my_evaluator) |>
  add_visualizer(my_visualizer) |>
  add_vary_across(.dgp = my_dgp, n = c(10, 100, 1000))

# run experiment
my_results <- run_experiment(experiment, n_reps = 25, save = TRUE)

# document and visualize experiment results
init_docs(experiment)
render_docs(experiment)
DGP

the data-generating process from which to generate data

Method

the methods (or models) to fit in the simulation experiment

Evaluator

the evaluation metrics used to evaluate the methods’ performance

Visualizer

the visualization functions used to visualize the results (e.g., tables, plots, written text)

my_dgp <- create_dgp(
  .dgp_fun = dgp_fun, 
  .name = "DGP Name",
  # named arguments to pass to .dgp_fun
  ...
)
my_method <- create_method(
  .method_fun = method_fun, 
  .name = "Method Name",
  # named arguments to pass to .method_fun
  ...
)
my_evaluator <- create_evaluator(
  .eval_fun = eval_fun, 
  .name = "Evaluator Name",
  # named arguments to pass to .eval_fun
  ...
)
my_visualizer <- create_visualizer(
  .viz_fun = viz_fun, 
  .name = "Visualizer Name",
  # named arguments to pass to .viz_fun
  ...
)
  • Can have multiple DGPs, methods, evaluators, and visualizers
  • Can also add multiple DGP/methods parameters to vary across (e.g., sample size, signal-to-noise ratio, method hyperparameters, etc.)

Case Study: The simChef Recipe

1
DGP
generate_xy_data()
  • Ideally, should generate data that is representative of the intended real-world scenario
Returns: train/test (\(X, y\)) + true interactions
2
Method
fit_irf()
  • Fit iRF to the simulated data
  • (+ other comparison methods)
Returns: iRF fit (predictions + interactions)
3
Evaluators
eval_predictions(), eval_interactions(), eval_stability()
  • Evaluate prediction performance
  • Evaluate interaction recovery (TPs vs. FPs)
  • Evaluate stability of the learned interactions
Returns: table of evaluation metrics
4
Visualizers
plot_predictions(), plot_interactions(), plot_stability()
Prediction Interaction recovery Stability
Returns: visualizations of results
Vary: \(n \in \{400,1200,2000\}\)
Vary: num. of iterations \(K=1,\ldots,5\)
How to construct a realistic and meaningful DGP?
\(y = f(X) + \varepsilon\)
Choice of \(X\)
  • Use (bootstrapped or subsampled) real data for \(X\) to preserve realistic feature distributions and correlation structures
Choice of \(f\)
  • Use domain knowledge or existing models to inform choice of \(f\)
  • Fit model using real data to estimate parameters and then simulate using these estimated parameters
Choice of \(\varepsilon\)
  • Fit model using real data and bootstrap the residuals to create realistic noise
E.g., Drosophila enhancer data
E.g., Boolean interactions (LSS model) to mimic on/off thresholding behavior of genes
E.g., RF noise

Case Study: Creating the DGP

DGPMethodEvaluatorVisualizer
1 Define generate_xy_data()
generate_xy_data <- function(X, rf_probs, n) {
  fx <- (X[, "kr1"] > 1.25 | X[, "kr2"] > 1.25) &
    (X[, "twi1"] > 1.25 | X[, "twi2"] > 1.25) &
    (X[, "D1"] > 1.25) &
    (X[, "hb1"] > 1.25 | X[, "hb2"] > 1.25) &
    (X[, "wt_ZLD"] > 75)

  y <- as.integer(fx | (runif(nrow(X)) < rf_probs))
  split <- stratified_split(y, train_prop = n / nrow(X))

  list(
    X_train = X[split$train, , drop = FALSE],
    y_train = factor(y[split$train], levels = c(0, 1)),
    X_test = X[split$test, , drop = FALSE],
    y_test = factor(y[split$test], levels = c(0, 1)),
    true_interaction = c("D1", "hb", "kr", "twi", "wt.ZLD")
  )
}
2 Create the DGP
dgp <- simChef::create_dgp(
  .dgp_fun = generate_xy_data,
  .name = "Enhancer LSS with RF Noise",
  # named arguments to pass to generate_xy_data
  X = X,
  rf_probs = rf_probs,
  n = 400
)
The outputs of generate_xy_data() are named to match the inputs of fit_irf().

Case Study: Creating the Method

DGPMethodEvaluatorVisualizer
1 Define fit_irf()
fit_irf <- function(X_train, y_train, X_test, y_test,
                    true_interaction, niter, ...) {
  fit <- iRF::iRF(
    x = X_train, y = y_train,
    xtest = X_test, ytest = y_test,
    iter.return = niter, int.return = niter,
    signed = FALSE, verbose = FALSE, n.core = 1,
    ...
  )

  list(
    rf_fit = fit$rf.list,
    interactions = fit$interaction,
    y_test = y_test,
    true_interaction = true_interaction
  )
}
2 Create the Method
irf <- simChef::create_method(
  .method_fun = fit_irf,
  .name = "iRF",
  # named arguments to pass to fit_irf
  varnames.grp = var_groups,
  niter = 5,
  n.bootstrap = 20,
  rit.param = list(
    depth = 5, ntree = 100, nchild = 2,
    class.id = 1, min.nd = 1
  )
)
The outputs of fit_irf() should return everything needed by the evaluators and visualizers.

Case Study: Creating an Evaluator

DGPMethodEvaluatorVisualizer
1 Define the evaluator functions
eval_summary <- function(fit_results, vary_params = NULL,
                         eval_id, eval_fun) {
  group_ids <- c(".dgp_name", ".method_name", vary_params,
                 "interaction_order", "active")

  fit_results |>
    dplyr::rowwise() |>
    dplyr::mutate("{eval_id}" := eval_fun(
      rf_fit = rf_fit, interactions = interactions,
      y_test = y_test,
      true_interaction = true_interaction
    )) |>
    tidyr::unnest(cols = dplyr::all_of(eval_id)) |>
    dplyr::group_by(dplyr::across(dplyr::any_of(group_ids))) |>
    dplyr::summarise(dplyr::across(
      dplyr::all_of(eval_id),
      list(mean = mean, raw = list),
      .names = "{.fn}_{.col}"
    ), .groups = "drop")
}
eval_prediction <- function(rf_fit, y_test, ...) {
  yardstick::pr_auc_vec(
    y_test, rf_fit$test$votes[, "1"],
    event_level = "second"
  )
}
2 Create the Evaluator
prediction <- simChef::create_evaluator(
  .eval_fun = eval_summary,
  .name = "AUPRC",
  # named arguments to pass to eval_summary
  eval_id = "auprc",
  eval_fun = eval_prediction
)
fit_results and vary_params are automatically passed to the evaluator functions by simChef.

Case Study: Creating a Visualizer

DGPMethodEvaluatorVisualizer
1 Define plot_prediction()
plot_prediction <- function(
    fit_results = NULL, eval_results,
    vary_params = NULL, eval_name = "AUPRC") {
  plt_df <- eval_results[[eval_name]] |>
    tidyr::unnest(cols = raw_auprc)

  ggplot2::ggplot(
    plt_df,
    ggplot2::aes(
      x = !!rlang::sym(vary_params[[1]]),
      y = raw_auprc
    )
  ) +
    ggplot2::geom_boxplot() +
    ggplot2::theme_minimal()
}
2 Create the Visualizer
prediction_plot <- simChef::create_visualizer(
  .viz_fun = plot_prediction,
  .name = "AUPRC Plot"
)
fit_results, eval_results, and vary_params are automatically passed to the visualizer functions by simChef.

Case Study Results: Prediction Performance

How does predictive performance change with the training sample size?

Mean AUPRC
n = 4000.806
n = 1,2000.832
n = 2,0000.840
Takeaway
Prediction improves as the training sample grows but with diminishing returns.

Ready to cook up your own simulation?

Design with MERITS. Build with simChef. Share a simulation others can trust.

Thank you! Questions?
Email: ttang4@nd.edu