Simulate an IQRmodel and scan the sensitivity of a specified parameter

Simulate an IQRmodel and scan the sensitivity of a specified parameter

sim_IQRmodel_sensitivityScan(
  simSpec,
  dFC,
  parName,
  foldChanges = 10^(seq(-2, 2)),
  measure.vars
)

Arguments

simSpec

createSimIQRmodelSpec

dFC

data.table of fold changes: data.table(sensitivityScanId (optional, will be created if non-existent), parameter1 = foldchanges1, ...). Can be missing, then parName and foldChanges are used to create a default dFC table

parName

Used only if missing(dFC). Character of the parameter to scan

foldChanges

Used only if missing(dFC). Numerical vector of fold changes

measure.vars

Character vector of variables/states to keep in final simulation result. More flexible than FLAGoutputsOnly. Can be missing. See examples.

Value

Simulation result in long format with sensitivityScan information: data.table(ID (used for simulation), ID0 (original ID in simSpec$IQReventTable), TIME, modelEntityId, simValue, sensitivityScanId)

Author

Daniel Lill (daniel.lill@intiquan.com)

Examples

if (FALSE) { # \dontrun{
td <- tempdir()
libraryPK_IQRtools(td)
fl <- file.path(td, "ModelLibraryPK/model_2cpt_linsat_iv.txt")

m <- IQRmodel(fl)
simSpec <- createSimIQRmodelSpec(m, simtime = seq(0,10,length.out = 101), dosingTable = IQRdosing(c(1,3,5),1,10,1))
simSpec$eventTable$TINF[1] <- 0.0001

# Scan a single parameter with parName and foldChanges
simres <- sim_IQRmodel_sensitivityScan(simSpec, parName = "CL", foldChanges = 10^(seq(-2,2)))
IQRggplot(simres, aes(TIME, simValue, color = sensitivityScanId)) +
  facet_wrap(~modelEntityId, scales = "free") +
  scale_y_log10_IQRtools() +
  geom_line()

# Create custom dFC to scan arbitrary values
dFC <- data.table::data.table(sensitivityScanId = c("none", "(CL,Vc)*10", "CL/10,Vc*100"), CL = c(1,10,1/10), Vc = c(1,10,100))
simres <- sim_IQRmodel_sensitivityScan(simSpec, dFC)
IQRggplot(simres, aes(TIME, simValue, color = sensitivityScanId)) +
  facet_wrap(~modelEntityId, scales = "free") +
  scale_y_log10_IQRtools() +
  geom_line()

# Use of measure.vars
simres <- sim_IQRmodel_sensitivityScan(simSpec, parName = "CL", foldChanges = 10^(seq(-2,2)), measure.vars = c("Ap1", "Cc"))
IQRggplot(simres, aes(TIME, simValue, color = sensitivityScanId)) +
  facet_wrap(~modelEntityId, scales = "free") +
  scale_y_log10_IQRtools() +
  geom_line()

# Multiple IDs in original eventTable
eventTable <- IQReventTable(data.frame(ID = c(1,2,2), TIME = c(0,0,1), ADM = 1, AMT = c(1,0.5,0.5), TINF = 0.0001, CL = 3), regression = "CL")
simSpec <- createSimIQRmodelSpec(m, simtime = seq(0,10,length.out = 101), eventTable = eventTable)
simres <- sim_IQRmodel_sensitivityScan(simSpec, parName = "CL", foldChanges = 10^(seq(-2,2)))
IQRggplot(simres, aes(TIME, simValue, color = sensitivityScanId)) +
  facet_wrap(~modelEntityId, scales = "free") +
  scale_y_log10_IQRtools() +
  geom_line(aes(linetype = factor(ID0)))
} # }