make_boot_datasets | R Documentation |
Creates bootstrap datasets and returns corresponding nm
objects. Requires
the necessary rsample
splitting objects to be present. See examples.
make_boot_datasets(
m,
samples = 10,
data_folder = file.path(nm_dir("derived_data"), "bootstrap_datasets"),
overwrite = FALSE,
id_var = "ID",
...
)
m |
An nm object. |
samples |
Number of samples. |
data_folder |
Folder (relative path) to store datasets. |
overwrite |
Logical (default = |
id_var |
Character (default = |
... |
Arguments passed to |
A tibble
with samples
rows and an nm object object column m
for
execution of the bootstrap.
## The following only works inside an NMproject directory structure and
## and requires NONMEM installed
## Not run:
# create example object m1 from package demo files
exdir <- system.file("extdata", "examples", "theopp", package = "NMproject")
m1 <- new_nm(run_id = "m1",
based_on = file.path(exdir, "Models", "ADVAN2.mod"),
data_path = file.path(exdir, "SourceData", "THEOPP.csv"))
d <- input_data(m1)
## in your dataset production script
d <- d %>%
mutate(
WT_C = cut(WT, breaks = 2, labels = FALSE),
STRATA = paste(SEX, WT_C, sep = "_")
)
d_id <- d %>% distinct(ID, STRATA)
set.seed(123)
## create large set of resamples (to enable simulation to grow
## without ruining seed)
bootsplits <- rsample::bootstraps(d_id, 100, strata = "STRATA")
dir.create("DerivedData", showWarnings = FALSE)
bootsplits %>% saveRDS("DerivedData/bootsplit_data.csv.RData")
## In a model development script, the following, performs a
## 100 sample bootstrap of model m1
m1_boot <- m1 %>% make_boot_datasets(samples = 100, overwrite = TRUE)
m1_boot$m %>% run_nm()
## the following bootstrap template will wait for results to complete
m1_boot$m %>% nm_list_render("Scripts/basic_boot.Rmd")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.