9  Start dosing after time = 0

So far, we’ve always started dosing on the first record of the simulation. In model 5, we show how to start dosing at some later time, after the simulation has been runing for a while.

We also show you how to turn a bolus dose into an infusion.

The model looks like this:

model/evtools-5.solv
[ plugin ] evtools

[ set ] outvars = "CP"

[ param ] 

CL = 1
V = 32
KA = 2

DOSE = 100
OVER = 2


[ pkmodel ] advan = 2

[ event ] 

if(NEWIND > 1) return; 

evt::ev dose = evt::bolus(DOSE, 1); 
evt::rate(dose, DOSE/OVER);
evt::retime(dose, 72); 
evt::ss(dose, 1); 
evt::ii(dose, 24); 
evt::addl(dose, 5); 

self.push(dose);

[ error ] 

capture CP = A2/V;

We’ve hard-coded the interval and total number of doses for clarity; you will probably want to make the number of doses and maybe the interval a parameter so you can change those from simulation to simulation.

mod <- mread("model/evtools-5.solv")
. Building evtools-5_solv ... done.
out <- mrgsim(mod, end = 336, delta = 0.25)

plot(out)