Skip to contents

[Stable]

PM_model objects contain the variables, covariates, equations and error models necessary to run a population analysis.

Details

PM_model objects are passed to PM_fit objects to initiate a population analysis. The object is created by defining a list of lists directly in R, or by reading a model text file in the current working directory.

Methods


Method new()

Build a new PM_model from a variety of inputs.

Usage

PM_model$new(model, ..., julia = F)

Arguments

model

This can be a quoted name of a model text file in the working directory which will be read and passed to Fortran engines unless julia = TRUE in which case is will be passed as a Julia model. It can be a list of lists that defines the model directly in R. Similarly, it can be a function that defines a Julia model directly in R. See the user manual for more help on directly defining models in R.

...

Additional arguments passed to creation of new Julia model.

julia

Controls whether a filename defines a Fortran or Julia model. Default is FALSE, i.e. using Fortran.


Method print()

Print a model object to the console in readable format

Usage

PM_model$print(...)

Arguments

...

Not used currently.


Method update()

Update selected elements of a model object

Usage

PM_model$update(changes_list)

Arguments

changes_list

The named list containing elements and values to update. Because R6 objects are mini-environments, using typical R notation to copy an object like mod2 <- mod1 can lead to unexpected results since this syntax simply creates a copied object in the same environment. Therefore updating any one object (e.g., mod1 or mod2) will update the other. To avoid this behavior, use the $clone() function first if you want to create a copied, yet independent new model.

Examples

mod2 <- PmetricsData::modEx$clone() #create an independent copy of modEx called mod2
mod2$update(list(
  pri = list(
   Ke = ab(0, 1), #change the range
   V = NULL, #this deletes the variable
   V0 = ab(10, 100) #add a new variable
  ),
  sec = "V = V0 * WT" #add a new secondary equation
))
#note that they are different now
mod2
PmetricsData::modEx


Method write()

Write a PM_model object to a text file

Usage

PM_model$write(model_path = "genmodel.txt", engine = "npag")

Arguments

model_path

Full name of the file to be created, including the path relative to the current working directory

engine

Currently only "npag".

Examples

\dontrun{
PmetricsData::modEx$write("model.txt")
}


Method plot()

Plot method

Usage

PM_model$plot(...)

Arguments

...

Arguments passed to plot.PM_model

Details

See plot.PM_model.


Method clone()

The objects of this class are cloneable with this method.

Usage

PM_model$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `PM_model$update`
## ------------------------------------------------

mod2 <- PmetricsData::modEx$clone() #create an independent copy of modEx called mod2
mod2$update(list(
  pri = list(
   Ke = ab(0, 1), #change the range
   V = NULL, #this deletes the variable
   V0 = ab(10, 100) #add a new variable
  ),
  sec = "V = V0 * WT" #add a new secondary equation
))
#note that they are different now
mod2
#> $model_list
#>     $pri
#>       $Ka
#>          $min: 0.1
#>          $max: 0.9
#>          $mean: 0.5
#>          $sd: 0.133
#>          $gtz: FALSE
#>       $Ke
#>          $min: 0
#>          $max: 1
#>          $mean: 0.5
#>          $sd: 0.167
#>          $gtz: FALSE
#>       $Tlag1
#>          $min: 0
#>          $max: 4
#>          $mean: 2
#>          $sd: 0.667
#>          $gtz: FALSE
#>       $V0
#>          $min: 10
#>          $max: 100
#>          $mean: 55
#>          $sd: 15
#>          $gtz: FALSE
#> 
#>      $cov
#>       $covariate: WT
#>          $constant: FALSE
#> 
#>       $covariate: AFRICA
#>          $constant: FALSE
#> 
#>       $covariate: AGE
#>          $constant: FALSE
#> 
#>       $covariate: GENDER
#>          $constant: FALSE
#> 
#>       $covariate: HEIGHT
#>          $constant: FALSE
#> 
#> 
#>      $lag
#>        [1] "TLAG(1) = Tlag1"
#> 
#>      $eqn
#>        [1] "{algebraic: Ka,Ke,V,2}"
#>        [2] "dX[1] = BOLUS[1] - Ka*X[1]"
#>        [3] "dX[2] = RATEIV[1] + Ka*X[1] - Ke*X[2]"
#> 
#>      $out
#>       $Y1
#>          $val: "X[2]/V"
#>          $err
#>             $model
#>                $additive: 
#>                $proportional: 5
#>                $constant: FALSE
#>             $assay
#>                $coefficients: [1] 0.02, [2] 0.05, [3] -2e-04, [4] 0
#>                $constant: FALSE
#> 
#> 
#> 
#>      $sec
#>        [1] "V = V0 * WT"
PmetricsData::modEx
#> $model_list
#>     $pri
#>       $Ka
#>          $min: 0.1
#>          $max: 0.9
#>          $mean: 0.5
#>          $sd: 0.133
#>          $gtz: FALSE
#>       $Ke
#>          $min: 0.001
#>          $max: 0.1
#>          $mean: 0.051
#>          $sd: 0.016
#>          $gtz: FALSE
#>       $V
#>          $min: 30
#>          $max: 120
#>          $mean: 75
#>          $sd: 15
#>          $gtz: FALSE
#>       $Tlag1
#>          $min: 0
#>          $max: 4
#>          $mean: 2
#>          $sd: 0.667
#>          $gtz: FALSE
#> 
#>      $cov
#>       $covariate: WT
#>          $constant: FALSE
#> 
#>       $covariate: AFRICA
#>          $constant: FALSE
#> 
#>       $covariate: AGE
#>          $constant: FALSE
#> 
#>       $covariate: GENDER
#>          $constant: FALSE
#> 
#>       $covariate: HEIGHT
#>          $constant: FALSE
#> 
#> 
#>      $lag
#>        [1] "TLAG(1) = Tlag1"
#> 
#>      $eqn
#>        [1] "{algebraic: Ka,Ke,V,2}"
#>        [2] "dX[1] = BOLUS[1] - Ka*X[1]"
#>        [3] "dX[2] = RATEIV[1] + Ka*X[1] - Ke*X[2]"
#> 
#>      $out
#>       $Y1
#>          $val: "X[2]/V"
#>          $err
#>             $model
#>                $additive: 
#>                $proportional: 5
#>                $constant: FALSE
#>             $assay
#>                $coefficients: [1] 0.02, [2] 0.05, [3] -2e-04, [4] 0
#>                $constant: FALSE
#> 
#> 

## ------------------------------------------------
## Method `PM_model$write`
## ------------------------------------------------

if (FALSE) {
PmetricsData::modEx$write("model.txt")
}