Skip to contents

Perform visual predictive check for NLME models

Usage

vpcmodel(
  model,
  vpcParams,
  params,
  hostPlatform = NULL,
  runInBackground = FALSE,
  ...
)

Arguments

model

PK/PD model class object.

vpcParams

VPC argument setup. See NlmeVpcParams. If missing, default values generated by NlmeVpcParams() are used.

params

Engine argument setup. See engineParams. The following arguments are the subject of interest: sort, ODE, rtolODE, atolODE, maxStepsODE. If missing, default values generated by engineParams(model) are used.

hostPlatform

Host definition for model execution. See hostParams. If missing, simple local host is 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.

...

Additional class initializer arguments for NlmeVpcParams 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 NlmeVpcParams arguments are supplied through both vpcParams argument and additional argument, then its slots will be overridden by additional arguments.

Value

If runInBackground = FALSE, a named list of data.tables loaded from the engine's VPC outputs (predcheck*.csv files, any user-defined simulationTables, plus predout.csv / simout.csv depending on params@isPopulation). The list also carries runMode = "vpc", runTime, and RsNLMEVersion elements alongside the data. Otherwise an NlmeSimulationJob object that can be materialised later via collectJob(), which produces the same result list.

See also

Examples

if (FALSE) { # \dontrun{
model <- pkmodel(
  numComp = 1,
  absorption = "Extravascular",
  ID = "Subject",
  Time = "Act_Time",
  CObs = "Conc",
  Aa = "Amount",
  data = pkData,
  modelName = "PkModel",
  workingDir = tempdir()
)

 host <- hostParams(
  sharedDirectory = tempdir(),
  parallelMethod = "NONE",
  hostName = "local",
  numCores = 1
 )

job <- fitmodel(model = model,
                hostPlatform = host)

finalModelVPC <- copyModel(model,
                           acceptAllEffects = TRUE,
                           modelName = "model_VPC",
                           workingDir = tempdir())

# View the model
print(finalModelVPC)

# Set up VPC arguments to have PRED outputted to simulation output dataset "predout.csv"
vpcSetup <- NlmeVpcParams(outputPRED = TRUE)

# Run VPC using the default host, default values for the relevant NLME engine arguments
finalVPCJob <- vpcmodel(model = finalModelVPC, vpcParams = vpcSetup, hostPlatform = host)
# the same as:
# finalVPCJob <- vpcmodel(model = finalModelVPC, outputPRED = TRUE)

# Observed dataset predcheck0.csv
dt_ObsData <- finalVPCJob$predcheck0

# Simulation output dataset predout.csv
dt_SimData <- finalVPCJob$predout

# Add PRED from REPLICATE = 0 of simulation output dataset to observed input dataset
dt_ObsData$PRED <- dt_SimData[REPLICATE == 0]$PRED

# tidyvpc package VPC example:
# library(tidyvpc)
# library(magrittr)
# Create a regular VPC plot with binning method set to be "jenks"
# binned_VPC <- observed(dt_ObsData, x = IVAR, yobs = DV) %>%
# simulated(dt_SimData, ysim = DV) %>%
# binning(bin = "jenks") %>%
# vpcstats()

# plot_binned_VPC <- plot(binned_VPC)

# Create a pcVPC plot with binning method set to be "jenks"
# binned_pcVPC <- observed(dt_ObsData, x = IVAR, yobs = DV) %>%
#   simulated(dt_SimData, ysim = DV) %>%
#   binning(bin = "jenks") %>%
#   predcorrect(pred = PRED) %>%
#   vpcstats()

# plot_binned_pcVPC <- plot(binned_pcVPC)
} # }