# Note that we have written the PK model so that time is the first predictor (xidep[,1])
# and dose the second
model1cpt<-function(psi,id,xidep) {
tim<-xidep[,1]
dose<-xidep[,2]
ka<-psi[id,1]
V<-psi[id,2]
CL<-psi[id,3]
k<-CL/V
ypred<-dose*ka/(V*(ka-k))*(exp(-k*tim)-exp(-ka*tim))
return(ypred)
}
x<-saemixModel(model=model1cpt,description="One-compartment model with first-order absorption",
psi0=matrix(c(1.5,30,1), ncol=3,byrow=TRUE, dimnames=list(NULL, c("ka","V","CL"))))
# Plot the model over 0-24h, using the parameters given in psi0 and a dose of 300
plot(x, range=c(0,24), predictors=300, verbose=TRUE)
# Plot the model over 0-24h, using another set of parameters and a dose of 350
plot(x, range=c(0,24), psi=c(1.5,20,2), predictors=350, verbose=TRUE)
Run the code above in your browser using DataLab