sims is an R package to generate datasets from JAGS or R code for use in simulation studies.
nlists ObjectsBy default, sims_simulate() returns the simulated datasets in the form of an nlists object.
.rds FilesIf, however, save = TRUE then each nlist object is saved as an .rds file in path.
set.seed(10)
sims_simulate("a ~ dunif(0,1)", nsims = 2L, save = TRUE, path = tempdir(), exists = NA)
#> [1] TRUE
sims_data_files(tempdir())
#> [1] "data0000001.rds" "data0000002.rds".rds FilesThe datasets in the .rds files can be imported as an nlists object using sims_data().
.rds FilesThe values including the .Random.seed (not printed) that were used to generate the datasets are saved in .sims_args.rds which can be imported using sims_info().
sims_info(tempdir())[1:5]
#> $code
#> [1] "model{a ~ dunif(0,1)}\n"
#>
#> $constants
#> an nlist object with 0 numeric elements
#>
#> $parameters
#> an nlist object with 0 numeric elements
#>
#> $monitor
#> [1] "a"
#>
#> $nsims
#> [1] 2The fact that the arguments to sims_simulate() are saved to file allows additional .rds datasets to be generated using sims_add().
.rds FilesIf the user wishes to duplicate the datasets then they can either regenerate them by specifying a different path but the same seed (using set.seed()). Alternatively, they can copy the existing .sims.rds and datasets files to a new directory using sims_copy()
.rds FilesA user can check that all the datasets specified in .sims.rds are present using sims_check().
Parallelization is implemented using the future package.
To use all available cores on the local machine simply execute the following code before calling sims_simulate().
Progress is reported using the progressr package as follows.