library(Rsmlx)
initializeMlxConnectors(software = "monolix")
library(ggplot2)
theme_set(theme_bw())

Read and plot the data

Let us first read the PKPD remifentanil data

remifentanil <- list(
  dataFile = "data/remifentanil_data.csv",
  headerTypes = c("id","time","amount","rate","observation","obsid","mdv","contcov","catcov","contcov","ignore"),
  administration = "iv")

remifentanil.data <- readDatamlx(data=remifentanil)
print(names(remifentanil.data))
## [1] "treatment" "y1"        "y2"        "covariate" "id"        "N"        
## [7] "catNames"

We now plot the PK data (\(y_1\)) and ignore the PD data (\(y_2\))

ggplot(remifentanil.data$y1, aes(x=time, y=y1, color=id)) + geom_point(size=1) + geom_line() +
  theme(legend.position = "none") + scale_y_continuous(trans='log10')


Get some good initial estimates

pkpopini gives some very good initial estimates for a 2 compartment model:

r2 <- pkpopini(parameter=c("V1", "Cl","V2", "Q"), data=remifentanil, new.dir="remifentanil") 
print(r2$pop.ini)
##       V1       Cl       V2        Q 
## 7.698842 2.701300 9.741293 1.298235

The Monolix project “remifentanil/pk_V1V2QCl.mlxtran” was also created by pkpopini. We can then load this project in Monolix and check the initial estimates