R script: pk3.R


# 1 Introduction

The dose amount can easily be defined a the function of some individual covariate, such as the weight.

In the two following examples, the dose amount is defined per kilo (2 mg per kilo) and the weight is used as the fraction which is absorbed.

# 2 Examples

## 2.1 Defining the weight in the Mlxtran model file

We use the function pkmodel in this example with the input argument p.

The weight w is defined as a covariate which is randomly sampled from the model defined in section [COVARIATE].

We use a PK model for iv bolus administration, assuming that the volume of the central compartment is equal to 1. The concentration at $$t=0$$ is therefore the dose amount administrated at $$t=0$$, i.e. twice the individual weight.

pkmodel1 <- inlineModel("
[LONGITUDINAL]
input = {V, k, w}
EQUATION:
Cc = pkmodel(V, k, p=w)

;----------------------------------------------
[COVARIATE]
input = {w_pop, omega_w}
DEFINITION:
w = {distribution = normal, mean = w_pop, sd = omega_w}
")

p   <- c(w_pop=70, omega_w=12, k=0.1, V=10)
dosePerKg <- 2
trtPerKg <- list(amt=dosePerKg, time=c(0, 12, 24))
Cc  <- list(name='Cc', time=seq(0, 36, by=1))
w   <- list(name='w')

res <- simulx(model     = pkmodel1,
parameter = p,
treatment = trtPerKg,
output    = list(Cc,w),
group     = list(size=3, level="covariate"),
settings  = list(seed=123))

print(res$parameter) ## id w ## 1 1 71.55185 ## 2 2 58.28215 ## 3 3 91.86812 print(res$Cc[res$Cc$time==0,])
##    id time       Cc
## 1   1    0 14.31037
## 38  2    0 11.65643
## 75  3    0 18.37362
print(ggplot(data=res$Cc) + geom_line(aes(x=time, y=Cc, colour=id)) + theme(legend.position=c(.9, .8))) ## 2.2 Defining the individual weights in the R script Of course, it is also possible to define the weights in the R script as a data frame and use it as an input argument of the model: pkmodel2 <- inlineModel(" [LONGITUDINAL] input = {V, k, w} EQUATION: Cc = pkmodel(V, k, p=w) ") weight <- data.frame(id=(1:3), w=c(60,80,90)) res <- simulx(model = pkmodel2, parameter = list(p, weight), treatment = trtPerKg, output = Cc) print(res$Cc[res$Cc$time==0,])
##    id time Cc
## 1   1    0 12
## 38  2    0 16
## 75  3    0 18
print(ggplot(data=res$Cc) + geom_line(aes(x=time, y=Cc, colour=id)) + theme(legend.position=c(.9, .8))) ## 2.3 Defining the individual dose regimens in the R script The doses can also be defined in the R script. In such case, the treatment should be defined a a data frame: pkmodel3 <- inlineModel(" [LONGITUDINAL] input = {V, k} EQUATION: Cc = pkmodel(V, k) ") w <- c(60,80,90) N <- length(w) times <- c(0, 12, 24) nbTimes <- length(times) trt <- data.frame(id = rep(1:N,each=nbTimes), time = rep(times,N), amount = rep(dosePerKg*w,each=nbTimes)) res <- simulx(model = pkmodel3, parameter = p, treatment = trt, output = Cc) print(res$Cc[res$Cc$time==0,])
##    id time Cc
## 1   1    0 12
## 38  2    0 16
## 75  3    0 18
print(ggplot(data=res$Cc) + geom_line(aes(x=time, y=Cc, colour=id)) + theme(legend.position=c(.9, .8))) ## 2.4 Using an ODE based model with depot The same PK model is defined here by an ODE with the PK macro depot and the input argument p. The individual weights w are defined as an input of the model. pkmodel4 <- inlineModel(" [LONGITUDINAL] input = {V, k, w} PK: depot(target=Ac, p=w) EQUATION: ddt_Ac = -k*Ac Cc = Ac/V ") res <- simulx(model = pkmodel4, parameter = list(p, weight), treatment = trtPerKg, output = list(Cc)) print(res$Cc[res$Cc$time==0,])
##    id time Cc
## 1   1    0 12
## 38  2    0 16
## 75  3    0 18
print(ggplot(data=res\$Cc) + geom_line(aes(x=time, y=Cc, colour=id)) +
theme(legend.position=c(.9, .8)))