Skip to contents

Method to execute an NLME Bootstrap

Usage

bootstrap(
  model,
  hostPlatform = NULL,
  params,
  bootParams,
  runInBackground = FALSE,
  saveResult = TRUE,
  overwriteFitDir = FALSE,
  ...
)

Arguments

model

PK/PD model class object.

hostPlatform

Host definition for model execution. See hostParams. If missing, multicore local host with 4 threads is used.

params

Engine parameters. See engineParams. If missing, default parameters generated by engineParams(model) are used.

bootParams

Bootstrap parameters. See BootstrapParams. If missing, default parameters generated by BootstrapParams() are used.

runInBackground

Logical. When TRUE, the wrapper starts the engine asynchronously and returns a job object immediately; pass that object to collectJob() when the run has finished to obtain the typed result. When FALSE (the default), the wrapper blocks until the engine completes and returns the result directly.

Background execution is supported only on Linux hosts, whether local or remote: a local host whose hostType is "linux" (the default on Linux workstations), or a remote host with hostType "linux", "RHEL", or "UBUNTU". It is not supported on Windows (hostType = "windows", including the default local host when R runs on Windows): leave the argument at FALSE. Passing TRUE on a Windows host stops with an error. Remote Windows hosts are not supported at all.

saveResult

Logical; if TRUE (default), the returned rsnlme_boot is written to <workingDir>/bootstrap_<sanitizedModelName>_<YYYYMMDD_HHMMSS>.rds so the run becomes self-describing on disk. workingDir is the model's working directory (model@modelInfo@workingDir), not necessarily R's process getwd(). sanitizedModelName is derived from model@modelInfo@modelName by replacing every character outside [A-Za-z0-9._-] with _; if the result is empty or contains no alphanumerics, the literal string model is used instead. The timestamp is the wall-clock start of the engine call, formatted as YYYYMMDD_HHMMSS in the local time zone. For runInBackground = TRUE, the save happens at collectJob() time rather than when bootstrap() returns. A failing write produces a warning, never an error.

overwriteFitDir

Logical (default FALSE). bootstrap() writes its aggregate artifacts (dmp.txt, residuals.csv, Boot*.csv) into model@modelInfo@workingDir - NOT into hostPlatform@sharedDirectory, which does not redirect aggregate output. Passing a model whose workingDir already holds a fit's own dmp.txt/residuals.csv (e.g. a fitted model's workingDir taken as-is) would silently overwrite that fit's outputs with a single bootstrap replicate's estimates, corrupting any downstream GOF/VPC that re-reads the directory. By default bootstrap() detects this and reroots the run into an isolated <workingDir>/bootstrap/<run-id>/ subdirectory instead (via copyModel), leaving the original fit untouched. Set overwriteFitDir = TRUE to force running in-place and overwrite those files anyway (not recommended); this always emits a warning.

...

Additional class initializer arguments for BootstrapParams or hostParams, or arguments available inside engineParams functions. If engineParams arguments are supplied through both params argument and additional argument (i.e., ellipsis), then the arguments in params will be ignored and only the additional arguments will be used with warning. If hostParams arguments are supplied through both hostPlatform argument and additional argument, then its values will be overridden by additional arguments. In addition, if BootstrapParams arguments are supplied through both bootParams argument and additional argument, then its slots will be overridden by additional arguments.

Value

When runInBackground = FALSE, an rsnlme_boot object: a named list of bootstrap result tables with class c("rsnlme_boot", "list") and metadata attributes. The list carries the existing aggregates (BootOverall, BootTheta, BootOmega, BootOmegaCorrelation, BootOmegaStderr, BootVarCoVar, BootSecondary) plus the per-replicate stacks and per-parameter CI tables emitted by recent NLME8 builds (BootThetaStacked, BootOmegaStacked, BootSigmaStacked, BootOmegaCI, BootSigmaCI, BootEtaShrinkage, BootEpsShrinkage). When bootParams@initialEstimates is TRUE, a compact fitSummary table built from dmp.txt + nlme7engine.log is also embedded. See ?rsnlme_boot for the full field and attribute contract and ?print.rsnlme_boot for the rendered output.

When saveResult = TRUE (the default), the rsnlme_boot is also written to disk; see the saveResult parameter for the exact path.

When runInBackground = TRUE, the bare BootNlmeJob is returned; pass it to collectJob() to obtain the rsnlme_boot (the RDS write, if requested, happens at that point).

Examples

if (FALSE) { # \dontrun{
input_data <- pkData

model <-
  pkmodel(
    numCompartments = 2,
    data = input_data,
    ID = "Subject",
    Time = "Act_Time",
    A1 = "Amount",
    CObs = "Conc",
    workingDir = tempdir()
  )

# multicore
multicoreHost <- hostParams(
  sharedDirectory = tempdir(),
  parallelMethod = "Multicore",
  hostName = "local_multicore",
  numCores = 4
)

bootstrapdf <- bootstrap(model,
  hostPlatform = multicoreHost,
  params = engineParams(model),
  numReplicates = 5,
  randomNumSeed = 1234,
  runInBackground = FALSE
)
} # }