Skip to contents

This function gets a model from the available model library

Usage

modellib(name = NULL, eta = NULL, reserr = NULL)

Arguments

name

character with the name of the model to load (if NULL, lists all available base models)

eta

vector with the parameters to add random effects (sometimes referred to as inter-individual variability, IIV) on

reserr

The type or types of residual error (currently "addSd", "propSd", and "lnormSd" are accepted)

Value

The function returns a function the model code (or NULL if the

model = NULL)

Details

This is a very first draft just to look at the proof of concept

Examples

modellib(name = "PK_1cmt")
#> function() {
#>   description <- "One compartment PK model with linear clearance"
#>   ini({
#>     lka <- 0.45 ; label("Absorption rate (Ka)")
#>     lcl <- 1 ; label("Clearance (CL)")
#>     lvc  <- 3.45 ; label("Central volume of distribution (V)")
#>     propSd <- 0.5 ; label("Proportional residual error (fraction)")
#>   })
#>   model({
#>     ka <- exp(lka)
#>     cl <- exp(lcl)
#>     vc  <- exp(lvc)
#> 
#>     Cc <- linCmt()
#>     Cc ~ prop(propSd)
#>   })
#> }
#> <environment: 0x5604e3889180>
modellib(name = "PK_1cmt", eta = c("ka", "vc"), reserr = "addSd")
#>  
#>  
#>  
#>  
#> → Adding eta to lka instead of ka due to mu-referencing
#>  
#>  
#> → Adding eta to lvc instead of vc due to mu-referencing
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#>  promote `etalka` to between subject variability with initial estimate 0.1
#>  change initial estimate of `etalka` to `0.1`
#>  promote `etalvc` to between subject variability with initial estimate 0.1
#>  change initial estimate of `etalvc` to `0.1`
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#> ! remove population parameter `propSd`
#>  add residual parameter `CcaddSd` and set estimate to 1
#>  change initial estimate of `CcaddSd` to `1`
#> function () 
#> {
#>     description <- "One compartment PK model with linear clearance"
#>     ini({
#>         lka <- 0.45
#>         label("Absorption rate (Ka)")
#>         lcl <- 1
#>         label("Clearance (CL)")
#>         lvc <- 3.45
#>         label("Central volume of distribution (V)")
#>         CcaddSd <- c(0, 1)
#>         etalka ~ 0.1
#>         etalvc ~ 0.1
#>     })
#>     model({
#>         ka <- exp(lka + etalka)
#>         cl <- exp(lcl)
#>         vc <- exp(lvc + etalvc)
#>         Cc <- linCmt()
#>         Cc ~ add(CcaddSd)
#>     })
#> }
#> <environment: 0x5604e0cce490>
modellib(name = "PK_1cmt", reserr = "addSd")
#>  
#>  
#> ! remove population parameter `propSd`
#>  add residual parameter `CcaddSd` and set estimate to 1
#>  change initial estimate of `CcaddSd` to `1`
#> function () 
#> {
#>     description <- "One compartment PK model with linear clearance"
#>     ini({
#>         lka <- 0.45
#>         label("Absorption rate (Ka)")
#>         lcl <- 1
#>         label("Clearance (CL)")
#>         lvc <- 3.45
#>         label("Central volume of distribution (V)")
#>         CcaddSd <- c(0, 1)
#>     })
#>     model({
#>         ka <- exp(lka)
#>         cl <- exp(lcl)
#>         vc <- exp(lvc)
#>         Cc <- linCmt()
#>         Cc ~ add(CcaddSd)
#>     })
#> }
#> <environment: 0x5604e2dda0e8>