---
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 = "#>"
)
```

<style type="text/css">
body{
font-size: 12pt;
}

h1.title {
font-size: 40pt;
}
</style>

<style>h1,h2,h3,h4 { border-bottom: 0; } </style>


```{css, echo=FALSE}
.boxModel {
  border: 1.5px solid black;
}
```

<!-- The document presents the library of pharmacokinetic (PK) and pharmacodynamic (PD) models incorporated into the PFIM software.  -->

# 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

<!-- The list of PK models with Michaelis-Menten elimination implemented in PFIM are summarised in Appendix I.2. Presently, there is no implementation for multiple dosing with IV bolus administration in the PFIM software. For infusion and oral administration, the implementation in PFIM does not allow designs with different groups of doses as the dose is included in the model. -->

### 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<t_D$}\\[0.05cm] 
C\left(t_{D}\right)&= {\frac{D}{V}}\\
\end{cases}\\[0.2cm]
&\frac{dC}{dt}= -\frac{{V_m}\times C}{K_m+C}\\
\end{aligned}
\end {equation}$$


```{r class.source= ".boxModel", eval= FALSE}
MichaelisMenten1BolusSingleDose_VmKmV
```

#### Infusion

+ single dose

$$	\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }C\left(t\right)=0 \text{	for $t<t_D$}\\[0.05cm]
&\frac{dC}{dt}=-\frac{{V_m}\times C}{K_m+C}+input\\[0.2cm]
&input\left(t\right)=
\begin{cases}
{\frac{D}{Tinf}\frac{1}{V}} &\text{if $0\leq t-t_{D}\leq Tinf$}\\[0.05cm]
0 &\text{if not.}
\end{cases}
\end{aligned}
\label{infusion1mmsd}
\end {equation}	$$

+ multiple doses

$$\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }C\left(t\right)=0 \text{	for $t<t_{D_{1}}$}\\[0.05cm]
&\frac{dC}{dt}=-\frac{{V_m}\times C}{K_m+C}+input\\[0.2cm]
&input\left(t\right)=
\begin{cases}
{\frac{D_{i}}{Tinf_{i}}\frac{1}{V}} &\text{if $0\leq t-t_{D_{i}}\leq Tinf_{i}$,}\\[0.05cm]
0 &\text{if not.}
\end{cases}
\end{aligned}\label{infusion1mmss}	
\end {equation}$$


```{r class.source= ".boxModel", eval= FALSE}
??????
```

#### First order absorption

+ single dose

$$
\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }C\left(t\right)=0\text{	for $t< t_D$}\\[0.05cm]
&\frac{dC}{dt}=-\frac{{V_m}\times C}{K_m+C}+ input\\[0.2cm]
&input\left(t\right)=\frac{D}{V}k_ae^{-k_a\left(t-t_D\right)}
\end{aligned}
\end {equation}$$

+ multiple doses

$$			\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }C\left(t\right)=0\text{	for $t< t_{D_{1}}$}\\[0.05cm]
&\frac{dC}{dt}=-\frac{{V_m}\times C}{K_m+C}+ input\\[0.2cm]
&input\left(t\right)=\sum^{n}_{i=1}\frac{D_i}{V}k_ae^{-k_a\left(t-t_{D_{i}}\right)}
\end{aligned}\label{oral11mmss}
\end {equation}$$


```{r class.source= ".boxModel", eval= FALSE}
MichaelisMenten1FirstOrderSingleDose_kaVmKmV,
MichaelisMenten2FirstOrderSingleDose_kaVmKmk12k21V1V2
```

### Two-compartment models

#### Intravenous bolus

+ single dose

$$
\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }\begin{cases}
C_1\left(t\right)= &0 \text{	for $t<t_D$}\\[0.05cm]
C_2\left(t\right)= &0 \text{	for $t\leq t_D$}\\[0.05cm]
C_1\left(t_{D}\right)=&{\frac{D}{V}}\\[0.05cm]
\end{cases}\\[0.15cm]
&\frac{dC_{1}}{dt}=-\frac{{V_m}\times C_1}{K_m+C_1}-k_{12}C_1+\frac{ k_{21 }V_2}{V}C_2\\[0.2cm]
&\frac{dC_{2}}{dt}=\frac{ k_{12 }V}{V_2}C_1-k_{21}C_2	\\
\end{aligned}
\end {equation}$$


```{r class.source= ".boxModel", eval= FALSE}
MichaelisMenten2BolusSingleDose_VmKmk12k21V1V2
```

#### Infusion

+ single dose

$$	\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }\begin{cases}
C_1\left(t\right)=&0 \text{	for $t<t_D$}\\[0.05cm]
C_2\left(t\right)=&0 \text{	for $t\leq t_D$}\\[0.05cm]
\end{cases}\\[0.15cm]
&\frac{dC_{1}}{dt}=-\frac{{V_m}\times C_1}{K_m+C_1}-k_{12}C_1+\frac{ k_{21 }V_2}{V}C_2+input\\[0.2cm]
&\frac{dC_{2}}{dt}=\frac{ k_{12 }V}{V_2}C_1-k_{21}C_2\\[0.2cm]
&input\left(t\right)=\begin{cases}
{\frac{D}{Tinf}\frac{1}{V}} &\text{if $0\leq t-t_{D}\leq Tinf$}\\[0.05cm]
0 &\text{if not.}
\end{cases}
\end{aligned}
\end {equation}$$

+ multiple doses

$$\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }\begin{cases}
C_1\left(t\right)=&0 \text{	for $t<t_{D_{1}}$}\\[0.05cm]
C_2\left(t\right)=&0 \text{	for $t\leq t_{D_{1}}$}\\[0.05cm]
\end{cases}\\[0.15cm]
&\frac{dC_{1}}{dt}=-\frac{{V_m}\times C_1}{K_m+C_1}-k_{12}C_1+\frac{ k_{21 }V_2}{V}C_2 + input\\[0.2cm]
&\frac{dC_{2}}{dt}=\frac{ k_{12}V}{V_2}C_1-k_{21}C_2\\[0.2cm]
&input\left(t\right)=
\begin{cases}
{\frac{D_{i}}{Tinf_{i}}\frac{1}{V}} &\text{if $0\leq t-t_{D_{i}}\leq Tinf_{i}$,}\\[0.05cm]
0 &\text{if not.}
\end{cases}
\end{aligned}
\end {equation}$$


```{r class.source= ".boxModel", eval= FALSE}
MichaelisMenten2InfusionSingleDose_VmKmk12k21V1V2
```

#### First order absorption

+ single dose

$$
\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }\begin{cases}
C_1\left(t\right)=&0 \text{	for $t< t_D$}\\[0.05cm]
C_2\left(t\right)=&0 \text{	for $t\leq t_D$}\\
\end{cases}\\[0.15cm]
&\frac{dC_{1}}{dt}=-\frac{{V_m}\times C_1}{K_m+C_1}-k_{12}C_1+\frac{ k_{21}V_2}{V}C_2+input\\[0.2cm]
&\frac{dC_{2}}{dt}=\frac{ k_{12}V}{V_2}C_1-k_{21}C_2\\[0.2cm]
&input\left(t\right)=\frac{D}{V}k_ae^{-k_a\left(t-t_D\right)}
\end{aligned}
\end {equation}$$

+ multiple doses

$$\begin {equation}
\begin{aligned}
\text{Initial }&\text{conditions:	 }\begin{cases}
C_1\left(t\right)=&0 \text{	for $t< t_{D_{1}}$}\\[0.05cm]
C_2\left(t\right)=&0 \text{	for $t\leq t_{D_{1}}$}\\
\end{cases}\\[0.15cm]
&\frac{dC_{1}}{dt}=-\frac{{V_m}\times C_1}{K_m+C_1}-k_{12}C_1+\frac{ k_{21}V_2}{V}C_2+input\\[0.2cm]
&\frac{dC_{2}}{dt}=\frac{ k_{12}V}{V_2}C_1-k_{21}C_2\\[0.2cm]
&input\left(t\right)=\sum^{n}_{i=1}\frac{D_i}{V}k_ae^{-k_a\left(t-t_{D_{i}}\right)}
\end{aligned}
\end {equation}	$$	


```{r class.source= ".boxModel", eval= FALSE}
MichaelisMenten2FirstOrderSingleDose_kaVmKmk12k21V1V2
MichaelisMenten2FirstOrderSingleDose_kaVmKmk12k21V1V2
```

# Pharmacodynamic models

## Immediate response models 

For these response models, the effect $E\left(t\right)$ is expressed as:

$$	\begin{equation}
E\left(t\right)=A\left(t\right)+S\left(t\right)
\end{equation}$$

\noindent where $A\left(t\right)$ represents the model of drug action and $S\left(t\right)$ corresponds to the baseline/disease model. $A\left(t\right)$ is a function of the concentration $C\left(t\right)$ in the central compartment.

The drug action models are presented in section [Drug action models](#drugactionmodels) for $C(t)$. The baseline/disease models are presented in section [Baseline/disease models](#baselinediseasemodel). Any combination of those two models is available in the PFIM library.

Parameters

+	$A_{lin}$: constant associated to $C\left(t\right)$
+ $A_{quad}$: constant associated to the square of $C\left(t\right)$
+ $A_{log}$: constant associated to the logarithm of $C\left(t\right)$
+ $E_{max}$: maximal agonistic response
+ $I_{max}$: maximal antagonistic response				
+ $C_{50}$: concentration to get half of the maximal response (\textit{i.e.} drug potency)
+ $\gamma$: sigmoidicity factor
+ $S_0$: baseline value of the studied effect
+ $k_{prog}$: rate constant of disease progression

NB: $V_m$ is in concentration per time unit and $K_m$ is in concentration unit.

### Drug action models {#drugactionmodels}

+ linear model
$$\begin{equation}
A\left(t\right)=A_{lin}C\left(t\right)
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugLinear_S0Alin
```

+ quadratic model
$$\begin{equation}
A\left(t\right)=A_{lin}C\left(t\right)+A_{quad}C\left(t\right)^{2}
\end{equation}$$	

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugImaxQuadratic_S0AlinAquad
```
+ logarithmic model
$$\begin{equation}
A\left(t\right)=A_{log}log(C\left(t\right))
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugImaxLogarithmic_S0Alog
```
+ $E_{max}$ model
$$\begin{equation}
A\left(t\right)=\frac{E_{max}C\left(t\right)}{C\left(t\right)+C_{50}}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugEmax_S0EmaxC50
```
+ sigmoïd $E_{max}$ model
$$\begin{equation}
A\left(t\right)=\frac{E_{max}C\left(t\right)^{\gamma}}{C\left(t\right)^{\gamma}+C_{50}^{\gamma}}
\end{equation}$$	

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugSigmoidEmax_S0EmaxC50gamma
```
+ $I_{max}$ model
$$\begin{equation}
A\left(t\right)=1-\frac{I_{max}C\left(t\right)}{C\left(t\right)+C_{50}}
\end{equation}$$	

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugImax_S0ImaxC50
```
+ sigmoïd $I_{max}$ model
$$\begin{equation}
A\left(t\right)=1-\frac{I_{max}C\left(t\right)^{\gamma}}{C\left(t\right)^{\gamma}+C_{50}^{\gamma}}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugImax_S0ImaxC50_gamma
```
+ full $I_{max}$ model
$$\begin{equation}
A\left(t\right)=-\frac{C\left(t\right)}{C\left(t\right)+C_{50}}
\end{equation}$$	


+ sigmoïd full $I_{max}$ model
$$\begin{equation}
A\left(t\right)=-\frac{C\left(t\right)^{\gamma}}{C\left(t\right)^{\gamma}+C_{50}^{\gamma}}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateDrugImax_S0ImaxC50_gamma
```

### Baseline/disease models {#baselinediseasemodel}

+ null baseline

$$\begin{equation}
S\left(t\right)=0
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateBaselineConstant_S0
```

+ constant baseline with no disease progression

$$\begin{equation}
S\left(t\right)=S_{0}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateBaselineConstant_S0
```

+ linear disease progression 

$$\begin{equation}
S\left(t\right)=S_{0}+k_{prog}t
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateBaselineLinear_S0kprog
```

+ exponential disease increase

$$\begin{equation}
S\left(t\right)=S_{0}e^{-k_{prog}t}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateBaselineExponentialincrease_S0kprog
```

+ exponential disease decrease

$$\begin{equation}
S\left(t\right)=S_{0}\left(1-e^{-k_{prog}t}\right)
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
ImmediateBaselineExponentialdecrease_S0kprog
```

## Turnover response models

In these models, the drug is not acting on the effect $E$ directly but rather on $R_{in}$ or $k_{out}$.

Thus the system is described with differential equations, given ${\frac{dE}{dt}}$ as a function of $R_{in}$, $k_{out}$ and $C\left(t\right)$ the drug concentration at time t.

The initial condition is: while $C\left(t\right)=0$, $E\left(t\right)= {\frac{R_{in}}{k_{out}}}$.

Parameters

+ $E_{max}$: maximal agonistic response
+ $I_{max}$: maximal antagonistic response				
+ $C_{50}$: concentration to get half of the maximal response (=drug potency)
+ $\gamma$: sigmoidicity factor
+ $R_{in}$: input (synthesis) rate
+ $k_{out}$: output (elimination) rate constant

### Models with impact on the input $(R_{in})$

+ $E_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}\left(1+\frac{E_{max}C}{C+C_{50}}\right)-k_{out}E
\label{indirect_emax}	
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverRinEmax_RinEmaxCC50koutE
```

+ sigmoïd $E_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}\left(1+\frac{E_{max}C^{\gamma}}{C^{\gamma}+C_{50}^{\gamma}}\right)-k_{out}E	
\label{indirect_sig_emax}				
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverRinSigmoidEmax_RinEmaxCC50koutE
```

+ $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}\left(1-\frac{I_{max}C}{C+C_{50}}\right)-k_{out}E	
\label{indirect_imax}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverRinFullImax_RinCC50koutE
```

+ sigmoïd $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}\left(1-\frac{I_{max}C^{\gamma}}{C^{\gamma}+C_{50}^{\gamma}}\right)-k_{out}E	
\label{indirect_simax}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverRinImax_RinImaxCC50koutE
```

+ full $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}\left(1-\frac{C}{C+C_{50}}\right)-k_{out}E	
\label{indirect_fimax}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverRinSigmoidImax_RinImaxCC50koutE
```

+ sigmoïd full $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}\left(1-\frac{C^{\gamma}}{C^{\gamma}+C_{50}^{\gamma}}\right)-k_{out}E	
\label{indirect_sfimax}				
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverRinFullImax_RinCC50koutE
```

### Models with impact on the output $(k_{out})$

+ $E_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}-k_{out}\left(1+\frac{E_{max}C}{C+C_{50}}\right)E	
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverkoutEmax_RinEmaxCC50koutE
```

+ sigmoïd $E_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}-k_{out}\left(1+\frac{E_{max}C^{\gamma}}{C^{\gamma}+C_{50}^{\gamma}}\right)E	
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverkoutSigmoidEmax_RinEmaxCC50koutEgamma
```

+ $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}-k_{out}\left(1-\frac{I_{max}C}{C+C_{50}}\right)E	
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverkoutImax_RinImaxCC50koutE
```

+ sigmoïd $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}-k_{out}\left(1-\frac{I_{max}C^{\gamma}}{C^{\gamma}+C_{50}^{\gamma}}\right)E	
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverkoutSigmoidImax_RinImaxCC50koutEgamma
```

+ full $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}-k_{out}\left(1-\frac{C}{C+C_{50}}\right)E	
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverkoutFullImax_RinCC50koutE
```

+ sigmoïd full $I_{max}$ model
$$\begin{equation}
\frac{dE}{dt}=R_{in}-k_{out}\left(1-\frac{C^{\gamma}}{C^{\gamma}+C_{50}^{\gamma}}\right)E	
\label{indirect_osfimax}
\end{equation}$$

```{r class.source= ".boxModel", eval= FALSE}
TurnoverkoutSigmoidFullImax_RinCC50koutE
```
