Skip to contents

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)
#> $`Normal DGP`
#> $`Normal DGP`[[1]]
#> $`Normal DGP`[[1]][[1]]
#>  [1] -0.1955145  0.9566731  0.1811654  0.6868962 -0.3522124 -1.6073684
#>  [7]  0.4971132  0.8414329 -0.1565263  0.2352087
#> 
#> 
#> $`Normal DGP`[[2]]
#> $`Normal DGP`[[2]][[1]]
#>  [1] -0.06666797 -1.13211916 -0.24935832 -0.10377363  0.05421331 -1.85656591
#>  [7]  2.04234475  0.62420312 -0.27977636 -0.57399593
#> 
#> 
#> 
#> $`Bernoulli DGP`
#> $`Bernoulli DGP`[[1]]
#> $`Bernoulli DGP`[[1]][[1]]
#>  [1] 0 1 1 0 0 1 0 1 1 1
#> 
#> 
#> $`Bernoulli DGP`[[2]]
#> $`Bernoulli DGP`[[2]][[1]]
#>  [1] 1 0 0 1 1 1 0 0 0 1
#> 
#> 
#>