---
title: "Library of models"
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 4
vignette: >
%\VignetteIndexEntry{Library of models}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{css, echo=FALSE}
.boxModel {
border: 1.5px solid black;
}
```
# Pharmacokinetic models
## Compartmental models and parameters
Six parameters are common to one, two or three compartment models:
+ $V$ or $V_1$, the volume of distribution in the central compartment
+ $k$, the elimination rate constant
+ $CL$, the clearance of elimination
+ $V_m$, the maximum elimination rate for Michaelis-Menten elimination
+ $K_m$, the Michaelis-Menten constant
+ $k_a$, the absorption rate constant for oral administration
## One-compartment models
There are two parameterisations implemented in PFIM for one-compartment models, $\left(V\text{ and }k\right)$ or $\left(V\text{ and }CL\right)$. The equations are given for the first parameterisation $\left(V, k\right)$. For extra-vascular administration, $V$ and $CL$ are apparent volume and clearance. The equations for the second parameterisation $\left(V, CL\right)$ are derived using $k={\frac{CL}{V}}$.
## Models with linear elimination
### One-compartment models
#### Intravenous bolus
+ single dose
$$\begin {equation}
\begin{aligned}
C\left(t\right)=\frac{D}{V}e^{-k\left(t-t_{D}\right)}
\end{aligned}
\end {equation}$$
+ multiple doses
$$\begin {equation}
\begin{aligned}
&
C\left(t\right)=\sum^{n}_{i=1}\frac{D_{i}}{V}e^{-k\left(t-t_{D_{i}}\right)}\\
&
\end{aligned}
\end {equation}$$
+ Library of models
```{r class.source= ".boxModel", eval= FALSE}
Linear1BolusSingleDose_kV
Linear1BolusSingleDose_ClV
```
+ steady state
$$\begin {equation}
C(t)=\frac{D}{V}\frac{e^{-k(t-t_D)}}{1-e^{-k\tau}}\\
\end {equation}$$
```{r class.source= ".boxModel", eval= FALSE}
Linear1BolusSteadyState_kVtau
Linear1BolusSteadyState_ClVtau
```
#### Infusion
+ single dose
$$\begin{equation}
C\left(t\right)=
\begin{cases}
{\frac{D}{Tinf}\frac{1}{kV}\left(1-e^{-k\left(t-t_{D}\right)}\right)} & \text{if $t-t_{D}\leq Tinf$,}\\[0.5cm]
{\frac{D}{Tinf}\frac{1}{kV}\left(1-e^{-kTinf}\right)e^{-k\left(t-t_{D}-Tinf\right)}} & \text{if not.}\\
\end{cases}\\
\end{equation}$$
+ multiple doses
$$\begin{equation}
C\left(t\right)=
\begin{cases}
\begin{aligned}
\sum^{n-1}_{i=1}\frac{D_{i}}{Tinf_{i}}
\frac{1}{kV}
&\left(1-e^{-kTinf_{i}}\right)
e^{-k\left(t-t_{D_{i}}-Tinf_i\right)}\\
&+\frac{D_{n}}{Tinf_{n}}
\frac{1}{kV}
\left(1-e^{-k\left(t-t_{D_{n}}\right)}\right)
\end{aligned}
& \text{if $t-t_{D_{n}} \leq Tinf_{n}$,}\\[1cm]
{\displaystyle\sum^{n}_{i=1}\frac{D_{i}}{Tinf_{i}}
\frac{1}{kV}}
\left(1-e^{-kTinf_{i}}\right)
e^{-k\left(t-t_{D_{i}}-Tinf_i\right)} & \text{if not.}\\
\end{cases}
\end{equation}
$$
```{r class.source= ".boxModel", eval= FALSE}
Linear1InfusionSingleDose_kV
Linear1InfusionSingleDose_ClV
```
+ steady state
$$\begin{equation}
\begin{aligned}
&
C\left(t\right)=
\begin{cases}
{\frac{D}{Tinf}
\frac{1}{kV}}
\left[
\left(1-e^{-k(t-t_D)}\right)
+e^{-k\tau}
{\frac{\left(1-e^{-kTinf}\right)e^{-k\left(t-t_D-Tinf\right)}}{1-e^{-k\tau}}}
\right] &\text{if $(t-t_D)\leq Tinf$,}\\[0.6cm]
{\frac{D}{Tinf}
\frac{1}{kV}
\frac{\left(1-e^{-kTinf}\right)e^{-k\left(t-t_D-Tinf\right)}}{1-e^{-k\tau}}} &\text{if not.}\\
\end{cases}\\
&
\end{aligned}
\end{equation}$$
```{r class.source= ".boxModel", eval= FALSE}
Linear1InfusionSteadyState_kVtau
Linear1InfusionSteadyState_ClVtau
```
#### First order absorption
+ single dose
$$\begin {equation}
C\left(t\right)=\frac{D}{V}
\frac{k_{a}}{k_{a}-k}
\left(e^{-k\left(t-t_{D}\right)}-e^{-k_{a}\left(t-t_{D}\right)}\right)
\end {equation}$$
+ multiple doses
$$\begin {equation}
C\left(t\right)=\sum^{n}_{i=1}\frac{D_{i}}{V}
\frac{k_{a}}{k_{a}-k}
\left(e^{-k\left(t-t_{D_{i}}\right)}-e^{-k_{a}\left(t-t_{D_{i}}\right)}\right)
\end {equation} $$
```{r class.source= ".boxModel", eval= FALSE}
Linear1FirstOrderSingleDose_kakV
Linear1FirstOrderSingleDose_kaClV
```
+ steady state
$$\begin {equation}
C\left(t\right)=\frac{D}{V}
\frac{k_{a}}{k_{a}-k}
\left(\frac{e^{-k(t-t_D)}}{1-e^{-k\tau}}-\frac{e^{-k_{a}(t-t_D)}}{1-e^{-k_a\tau}}\right)
\end {equation}$$
```{r class.source= ".boxModel", eval= FALSE}
Linear1FirstOrderSteadyState_kakVtau
Linear1FirstOrderSteadyState_kaClVtau
```
### Two-compartment models
For two-compartment model equations, $C(t)=C_1(t)$ represent the drug concentration in the first compartment and $C_2(t)$ represents the drug concentration in the second compartment.
As well as the previously described PK parameters, the following PK parameters are used for the two-compartment models:
+ $V_2$, the volume of distribution of second compartment
+ $k_{12}$, the distribution rate constant from compartment 1 to compartment 2
+ $k_{21}$, the distribution rate constant from compartment 2 to compartment 1
+ $Q$, the inter-compartmental clearance
+ $\alpha$, the first rate constant
+ $\beta$, the second rate constant
+ $A$, the first macro-constant
+ $B$, the second macro-constant
There are two parameterisations implemented in PFIM for two-compartment models: $\left(V\text{, }k\text{, }k_{12}\text{ and }k_{21}\right)$, or $\left(CL\text{, }V_1\text{, }Q\text{ and }V_2\right)$. For extra-vascular administration, $V_1$ ($V$), $V_2$, $CL$, and $Q$ are apparent volumes and clearances.
The second parameterisation terms are derived using:
+ $V_1=V$
+ $CL=k \times V_1$
+ $Q=k_{12} \times V_1$
+ $V_2= {\frac{k_{12}}{k_{21}}}\times V_1$
For readability, the equations for two-compartment models with linear elimination are given using the variables $\alpha\text{, }\beta\text{, }A\text{ and }B$ defined by the following expressions:
$$\alpha = {\frac{k_{21}k}{\beta}} = {\frac{{\frac{Q}{V_2}}{\frac{CL}{V_1}}}{\beta}}$$
$$\beta=
\begin{cases}
{\frac{1}{2}\left[k_{12}+k_{21}+k-\sqrt{\left(k_{12}+k_{21}+k\right)^2-4k_{21}k}\right]}\\[0.4cm]
{
\frac{1}{2}
\left[
\frac{Q}{V_1}+\frac{Q}{V_2}+\frac{CL}{V_1}-\sqrt{\left(\frac{Q}{V_1}+\frac{Q}{V_2}+\frac{CL}{V_1}\right)^2-4\frac{Q}{V_2}\frac{CL}{V_1}}
\right]
}
\end{cases}$$
The link between A and B, and the PK parameters of the first and second parameterisations depends on the input and are given in each subsection.
#### Intravenous bolus
For intravenous bolus, the link between $A$ and $B$, and the parameters ($V$, $k$, $k_{12}$ and $k_{21}$), or ($CL$, $V_1$, $Q$ and $V_2$) is defined as follows:
$$A={\frac{1}{V}\frac{\alpha-k_{21}}{\alpha-\beta}}
={\frac{1}{V_1}\frac{\alpha-{\frac{Q}{V_2}}}{\alpha-\beta}}$$
$$B={\frac{1}{V}\frac{\beta-k_{21}}{\beta-\alpha}}
={\frac{1}{V_1}\frac{\beta-{\frac{Q}{V_2}}}{\beta-\alpha}}$$
+ single dose
$$\begin {equation}
C\left(t\right)=D\left(Ae^{-\alpha \left(t-t_D\right)}+Be^{-\beta \left(t-t_D\right)}\right)
\end {equation}$$
+ multiples doses
$$\begin {equation}
C\left(t\right)=\sum^{n}_{i=1}D_{i}\left(Ae^{-\alpha \left(t-t_{D_{i}}\right)}+Be^{-\beta \left(t-t_{D_{i}}\right)}\right)
\end {equation} $$
```{r class.source= ".boxModel", eval= FALSE}
Linear2BolusSingleDose_ClQV1V2
Linear2BolusSingleDose_kk12k21V
```
+ steady state
$$\begin {equation}
C\left(t\right)=D\left(\frac{Ae^{-\alpha t}}{1-e^{-\alpha \tau}}+\frac{Be^{-\beta t}}{1-e^{-\beta \tau}}\right)
\end{equation}$$
```{r class.source= ".boxModel", eval= FALSE}
Linear2BolusSteadyState_ClQV1V2tau
Linear2BolusSteadyState_kk12k21Vtau
```
#### Infusion
For infusion, the link between $A$ and $B$, and the parameters ($V$, $k$, $k_{12}$ and $k_{21}$), or ($CL$, $V_1$, $Q$ and $V_2$) is defined as follows:
$$A={\frac{1}{V}\frac{\alpha-k_{21}}{\alpha-\beta}}
={\frac{1}{V_1}\frac{\alpha-{\frac{Q}{V_2}}}{\alpha-\beta}}$$
$$B={\frac{1}{V}\frac{\beta-k_{21}}{\beta-\alpha}}
={\frac{1}{V_1}\frac{\beta-{\frac{Q}{V_2}}}{\beta-\alpha}}$$
+ single dose
$$ \begin {equation}
C\left(t\right)=
\begin{cases}
{\frac{D}{Tinf}}\left[
\begin{aligned}
\frac{A}{\alpha}\left(1-e^{-\alpha \left(t-t_D\right)}\right)\\[0.1cm]
+ \frac{B}{\beta}\left(1-e^{-\beta \left(t-t_D\right)}\right)
\end{aligned}
\right] & \text{if $t-t_D\leq Tinf$,}\\[1cm]
{\frac{D}{Tinf}}\left[
\begin{aligned}
\frac{A}{\alpha}\left(1-e^{-\alpha Tinf}\right) e^{-\alpha \left(t-t_D-Tinf\right)}\\[0.1cm]
+ \frac{B}{\beta}\left(1-e^{-\beta Tinf}\right) e^{-\beta \left(t-t_D-Tinf\right)}
\end{aligned}
\right] & \text{if not.}\\
\end{cases}
\end {equation} $$
+ multiple doses
$$\begin {equation}
C\left(t\right)=
\begin{cases}
\begin{aligned}
\sum^{n-1}_{i=1}&\frac{D_i}{Tinf_i}
\left[
\begin{aligned}
\frac{A}{\alpha}\left(1-e^{-\alpha Tinf_i}\right) e^{-\alpha \left(t-t_{D_{i}}-Tinf_i\right)}\\[0.1cm]
+ \frac{B}{\beta}\left(1-e^{-\beta Tinf_i}\right) e^{-\beta \left(t-t_{D_{i}}-Tinf_i\right)}
\end{aligned}
\right]\\[0.2cm]
&+\frac{D}{Tinf_n}
\left[
\begin{aligned}
\frac{A}{\alpha}\left(1-e^{-\alpha \left(t-t_{D_{n}}\right)}\right)\\[0.1cm]
+ \frac{B}{\beta}\left(1-e^{-\beta \left(t-t_{D_{n}}\right)}\right)
\end{aligned}
\right]
\end{aligned} & \text{if $t-t_{D_{n}}\leq Tinf$,}\\
{\displaystyle \sum^{n}_{i=1}\frac{D_i}{Tinf_i}}
\left[
\begin{aligned}
\frac{A}{\alpha}\left(1-e^{-\alpha Tinf_i}\right) e^{-\alpha \left(t-t_{D_{i}}-Tinf_i\right)}\\[0.1cm]
+ \frac{B}{\beta}\left(1-e^{-\beta Tinf_i}\right) e^{-\beta \left(t-t_{D_{i}}-Tinf_i\right)}
\end{aligned}
\right] & \text{if not.}
\end{cases}
\end {equation} $$
```{r class.source= ".boxModel", eval= FALSE}
Linear2InfusionSingleDose_kk12k21V,
Linear2InfusionSingleDose_ClQV1V2,
```
+ steady state
$$\begin {equation}
\hspace{-0.5cm}
C\left(t\right)=\begin{cases}
{\frac{D}{Tinf}}
\left[
\begin{aligned}
&\frac{A}{\alpha}
\left(
\begin{aligned}
&\left(1-e^{-\alpha (t-t_D)}\right)\\
&+ e^{-\alpha \tau}
\frac{ \left(1-e^{-\alpha Tinf}\right) e^{-\alpha \left(t-t_D - Tinf\right)}}
{1-e^{-\alpha \tau}}
\end{aligned}
\right)\\[0.1cm]
&+ \frac{B}{\beta}
\left(
\begin{aligned}
&\left(1-e^{-\beta (t-t_D)}\right)\\
&+ e^{-\beta \tau}
\frac{ \left(1-e^{-\beta Tinf}\right) e^{-\beta \left(t-t_D - Tinf\right)}}
{1-e^{-\beta \tau}}
\end{aligned}
\right)
\end{aligned}
\right] &\!\!\!\!\!\text{if $t-t_D\leq Tinf$,}\vspace*{0.5cm}\\
{\frac{D}{Tinf}}
\left[
\begin{aligned}
&\frac{A}{\alpha}
\left(
\frac{ \left(1-e^{-\alpha Tinf}\right) e^{-\alpha \left(t-t_D - Tinf\right)}}
{1-e^{-\alpha \tau}}
\right)\\[0.1cm]
&+ \frac{B}{\beta}
\left(
\frac{ \left(1-e^{-\beta Tinf}\right) e^{-\beta \left(t-t_D - Tinf\right)}}
{1-e^{-\beta \tau}}
\right)
\end{aligned}
\right] &\!\!\!\!\!\text{if not.}
\end{cases}
\label{infusion2lss}
\end {equation}$$
```{r class.source= ".boxModel", eval= FALSE}
Linear2InfusionSteadyState_kk12k21Vtau
Linear2InfusionSteadyState_ClQV1V2tau
```
#### First-order absorption
For first order absorption, the link between $A$ and $B$, and the parameters ($k_a$, $V$, $k$, $k_{12}$ and $k_{21}$), or $\left(k_a\text{, } CL\text{, }V_1\text{, }Q\text{ and }V_2\right)$ is defined as follows:
$$A={\frac{k_a}{V}\frac{k_{21}-\alpha}{\left(k_a-\alpha\right)\left(\beta-\alpha\right)}}
={\frac{k_a}{V_1}\frac{{\frac{Q}{V_2}}-\alpha}{\left(k_a-\alpha\right)\left(\beta-\alpha\right)}}$$
$$B={\frac{k_a}{V}\frac{k_{21}-\beta}{\left(k_a-\beta\right)\left(\alpha-\beta\right)}}
={\frac{k_a}{V_1}\frac{{\frac{Q}{V_2}}-\beta}{\left(k_a-\beta\right)\left(\alpha-\beta\right)}}$$
+ single dose
$$ \begin {equation}
C\left(t\right)=D
\left(
Ae^{-\alpha \left(t-t_D\right)}+Be^{-\beta \left(t-t_D\right)}-(A+B)e^{-k_a \left(t-t_D\right)}
\right)
\end {equation}$$
+ multiple doses
$$\begin {equation}
C\left(t\right)=\sum^{n}_{i=1}D_{i}
\left(
Ae^{-\alpha \left(t-t_{D_{i}}\right)}+Be^{-\beta \left(t-t_{D_{i}}\right)}-(A+B)e^{-k_a \left(t-t_{D_{i}}\right)}
\right)
\end {equation}$$
```{r class.source= ".boxModel", eval= FALSE}
Linear2FirstOrderSingleDose_kaClQV1V2
Linear2FirstOrderSingleDose_kakk12k21V
```
+ steady state
$$\begin {equation}
C\left(t\right)=D
\left(
\frac{Ae^{-\alpha (t-t_D)}}{1-e^{-\alpha \tau}}
+\frac{Be^{-\beta (t-t_D)}}{1-e^{-\beta \tau}}
-\frac{(A+B)e^{-k_a (t-t_D)}}{1-e^{-k_a \tau}}
\right)
\end {equation}$$
```{r class.source= ".boxModel", eval= FALSE}
Linear2FirstOrderSteadyState_kaClQV1V2tau
Linear2FirstOrderSteadyState_kakk12k21Vtau
```
## Models with Michaelis-Menten elimination
### One-compartment models
#### Intravenous bolus
+ single dose
$$\begin{equation}
\begin{aligned}
\text{Initial }&\text{conditions: }\begin{cases}
C\left(t\right)&= 0 \text{ for $t