Skip to contents

Runs mrgsolve::mrgsim() and writes simulation output to a parquet file in tempdir(), returning an mrgsimsds object. Files in tempdir() are auto-deleted on garbage collection by default. Use move_ds() or save_ds() to relocate files outside tempdir(), which automatically disables gc, or call gc_ds() to control gc directly. Note that full argument names must be used for all arguments.

Usage

mrgsim_ds(x, ..., tags = list(), verbose = FALSE, gc = TRUE)

Arguments

x

a model object loaded through mread_ds(), mcode_ds(), modlib_ds(), mread_cache_ds(), or house_ds().

...

passed to mrgsolve::mrgsim().

tags

a named list of atomic data to tag (or mutate) the simulated output.

verbose

if TRUE, print progress information to the console.

gc

initial gc setting; if TRUE, a finalizer function will attempt to remove files once the object is out of scope. This value is not locked: move_ds() and save_ds() will automatically adjust gc based on whether the files remain under tempdir(). To lock the gc setting and prevent automatic adjustment, call gc_ds() after creation.

Value

An object with class mrgsimsds.

Examples

mod <- house_ds()

data <- ev_expand(amt = 100, ID = 1:10)

out <- mrgsim_ds(mod, data, end = 72, delta = 0.1)

out <- mrgsim_ds(mod, data, tags = list(rep = 1))

head(out)
#> # A tibble: 6 × 8
#>      ID  time   GUT  CENT  RESP    DV    CP   rep
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1     1  0      0     0    50    0     0        1
#> 2     1  0    100     0    50    0     0        1
#> 3     1  0.25  74.1  25.7  48.7  1.29  1.29     1
#> 4     1  0.5   54.9  44.5  46.2  2.23  2.23     1
#> 5     1  0.75  40.7  58.1  43.6  2.90  2.90     1
#> 6     1  1     30.1  67.8  41.4  3.39  3.39     1