Dear Lance
I am attaching a project that answers your question.
The code is for a simple 1 compartment model as below:
The idea is that you must integrate the time from 0 to the final time point only when the predicted concentration is above a threshold value.
In order to do that you first need to define an index that will take the value of 1 if the predicted concentration above the threshold and 0 otherwise.
Then you write
deriv(tthreshold=index)
tthresholdis the time above the threshold level and if you were always above the threshold index would be 1 all the time and derive(tthreshold=1) would be equal to the actual time at each time.
This comes from the definition of a derivative.
dX/dt=1 dx=dt which means that the change of your response (x) equal the change in time.
however when C is below the threshold, index=0 and therefore during that time the threshold does not accumulate.
the overall result is that for each patient you can follow at each time how much time they were above the threshold.
Obviously this time can never be larger than the current time. BEST SCENAIRO IS EQUAL WHEN YOUA RE ALWASY ABOVE THE THRESHOLD.
I am attaching an example project to help you.
best Regards
Serge
the code for a compt model IV input
test(){
deriv(A1 = - (Cl * C))
urinecpt(A0 = (Cl * C))
C = A1 / V
threshold=60
index=(C>threshold?1:0)
deriv(tthreshold=index)
tthresholdgraph=tthreshold
dosepoint(A1, idosevar = A1Dose, infdosevar = A1InfDose, infratevar = A1InfRate)
error(CEps = 0.1)
observe(CObs = C * (1 + CEps))
stparm(V = tvV * exp(nV))
stparm(Cl = tvCl * exp(nCl))
fixef(tvV = c(, 1, ))
fixef(tvCl = c(, 0.2, ))
ranef(diag(nV, nCl) = c(0.1, 0.1))
}