PKmod: PK models with linear elimination

Description Usage Arguments Details Value Examples

View source: R/PKPDmodels.R

Description

Create a model function with gradient evaluation (and, optionally, Hessian evaluation) for a model according to the number of compartments, the form of administration and dosage of the drug after performing any substitutions given.

Usage

1
2
3
  PKmod(admin = c("bolus", "infusion", "oral"),
    dosage = c("sd", "md", "ss"), subst = list(), cpt = 1L,
    hessian = FALSE)

Arguments

admin

form of administration of the drug, one of "bolus", "infusion" or "oral". Defaults to "bolus".

dosage

type of dosage of the drug, one of "sd" (single dose), "md" (multiple dose) or "ss" (steady-state). Defaults to "sd".

subst

a list of formulas of substitutions to perform

cpt

scalar integer - the number of model compartments.

hessian

a logical value indicating whether the second derivatives should be calculated and incorporated in the return value.

Details

The substitutions are given as a list of formulas, such as list(k ~ Cl/V, Cl ~ exp(lCl), V ~ exp(lV)). They are applied left to right.

Value

a byte-compiled model function with gradient evaluation

Examples

1
2
## return a function with substitutions
PKmod("bolus", "sd", list(k ~ Cl/V, Cl ~ exp(lCl), V ~ exp(lV)))

Example output

function (dose, t, lCl, lV) 
{
    .expr1 <- exp(lCl)
    .expr2 <- exp(lV)
    .expr3 <- .expr1/.expr2
    .expr6 <- exp(-.expr3 * t)
    .expr7 <- dose * .expr6
    .expr15 <- .expr2^2
    .value <- .expr7/.expr2
    .grad <- array(0, c(length(.value), 2L), list(NULL, c("lCl", 
        "lV")))
    .grad[, "lCl"] <- -(dose * (.expr6 * (.expr3 * t))/.expr2)
    .grad[, "lV"] <- dose * (.expr6 * (.expr1 * .expr2/.expr15 * 
        t))/.expr2 - .expr7 * .expr2/.expr15
    attr(.value, "gradient") <- .grad
    .value
}
<bytecode: 0x23b7e08>

PKPDmodels documentation built on May 1, 2019, 7:59 p.m.