generate_data: Generate data from each 'DGP' in the 'Experiment'.

View source: R/experiment-helpers.R

generate_dataR Documentation

Generate data from each DGP in the Experiment.

Description

Generate sample data from all DGP objects that were added to the Experiment, including their varied params. Primarily useful for debugging. Note that results are not generated in parallel.

Usage

generate_data(experiment, n_reps = 1, ...)

Arguments

experiment

An Experiment object.

n_reps

The number of datasets to generate per DGP.

...

Not used.

Value

A list of length equal to the number of DGPs in the Experiment. If the Experiment does not have a vary_across component, then each element in the list is a list of n_reps datasets generated by the given DGP. If the Experiment does have a vary_across component, then each element in the outermost list is a list of lists. The second layer of lists corresponds to a specific parameter setting within the vary_across scheme, and the innermost layer of lists is of length n_reps with the dataset replicates, generated by the DGP.

Examples

# create DGP to generate data from normal distribution with n samples
normal_dgp <- create_dgp(
  .dgp_fun = function(n) rnorm(n), .name = "Normal DGP", n = 10
)
# create DGP to generate data from binomial distribution with n samples
bernoulli_dgp <- create_dgp(
  .dgp_fun = function(n) rbinom(n, 1, 0.5), .name = "Bernoulli DGP", n = 10
)

# initialize experiment with toy DGPs only
experiment <- create_experiment(name = "Experiment Name") %>%
  add_dgp(normal_dgp) %>%
  add_dgp(bernoulli_dgp)

# generate data from all DGPs (and vary across components if applicable)
# in experiment
generate_data(experiment, n_reps = 2)

Yu-Group/simChef documentation built on March 25, 2024, 3:22 a.m.