IF(NEWIND.NE.2) equivalent for average concentration calcuation on the fly

Hi there,

Could you illustrate to make the Phoenix equivalent to this NONMEM twist, to get the the average concentration calculated on the fly, in period btw. current and since last effect response record.

Thx

Thomas

$PK

IF(NEWIND.NE.2)THEN ; set up variables for new subject

LAUC = 0 ; previous AUC

LTM = TIME ; previous time

LAVE = 0 ; average concentration since previous record

ENDIF

KA=THETA(1)

CL=THETA(2)

V=THETA(3)

$DES

DADT(1)=-KA*A(1)

DADT(2)=KAA(1)-CL/VA(2)

DADT(3)=A(2)

$ERROR

CP=A(2)/V

AUC=A(3)/V

DTIM = TIME - LTM ; Time difference

DAUC = AUC - LAUC ; Difference in AUC

IF(DTIM.EQ.0)THEN

CAVE = LAVE ; Time has not changed, average concentration is the same

ELSE

CAVE = DAUC/DTIM

ENDIF

; Record current AUC and TIME for next call

LAUC = AUC

LTM = TIME

LAVE = CAVE

BASE = FID1

EFF = EM*CAVEHILL/(ECHILL+CAVE**HILL)

IPRE = BASE - EFF

IF(IPRE.LT.0) IPRE=0

Y = IPRE + EPS(1)

Hi it will be good if you can provide a fully repoducible example with the data and complete control file so we can reproduce what you did in nonmem on our end and then show you exactly how to do it in pml.

These kind of computations should be possible using sequence, doafter and dobefore:

observe(CObs = C*(1+ CEps),doafter={prevAUC=AUC})

Hi

Thx - I have sent control stream and data support to suport, as I do not want to post it in public.

But the issue put simply is, how to get the AUC since last timepoint calculated for all timepoints and subjects.

What would the IF.NEWIND.NE.2 equivalent would be - ie., the trick to reset the AUC for each subject?

BR Thomas

Hi Thomas, please take a look at the attached project, specifically the last two models where I’ve calculated Cavg on a simple PK model at each observation time;

time as cov & time as fcov where I tried to illustrate that fcovariate and covariate do different things in comfination with dobefore and doafter statements.

essentially I set up the following;

[font=‘courier new’]fcovariate(time2) # carry forward time1 until time2
double(tprev)
double(AUCprev)[/font]

[font=‘Segoe UI’]then on the observe statement; (there are some extra variables there for illustration)[/font]

[font=‘courier new’] observe(CObs = C * (1 + CEps), dobefore={tprev=time2 Cprev=C}
doafter={AUCprev=AUC tprev2=time2}) #i.e.lags the previous Timepoint value[/font]

[font=‘Segoe UI’]and finally;[/font]

[font=‘Segoe UI’][font=‘courier new’]# calc of Cavg[/font][/font]
[font=‘Segoe UI’][font=‘courier new’] deriv(AUCinf = C) [/font][/font][font=‘Segoe UI’][font=‘courier new’] # simple AUCinf [/font][/font]
[font=‘Segoe UI’][font=‘courier new’] deriv(AUC = C) [/font][/font][font=‘Segoe UI’][font=‘courier new’] # AUC for interval[/font][/font]
[font=‘Segoe UI’][font=‘courier new’] timeinterval=t-tprev [/font][/font][font=‘Segoe UI’][font=‘courier new’] # length of time between Obs[/font][/font]
[font=‘Segoe UI’][font=‘courier new’]Cavg=(AUC-AUCprev)/timeinterval[/font][/font]

[font=‘Segoe UI’][font=arial]I think that is what you were looking for and you can probably code this more elegantly than me now ;0) since there are some redundant code in there I used to illustrate what was happening between dobefore and doafter [/font][/font]

[font=‘Segoe UI’][font=arial] Simon[/font]
[/font]ex21 zero order.phxproj (1.76 MB)

few comments

observe(CObs = C * (1 + CEps), dobefore={tprev=time2 Cprev=C}
doafter={AUCprev=AUC tprev2=time2}) #i.e.lags the previous Timepoint value

think of doafter AUCprev=AUC like we want to save the “current” cumulative AUC as a variable called AUCprev this “value” will be available to the next observation since we did save it after we read and computed for the previous one.

when the program reaches the new observation then AUCprev will be the value we “saved” from the previous one and so on.

any expression in PML like the once for Cavg below is evaluated at each row.

Cavg=(AUC-AUCprev)/timeinterval

in this example we did not need sequence since we only wanted computation right before or right after an observation is made.

I do not have access to what is sent to support

Dear Simon, smoukassi1,

Thx, yes, that was what I was looking for - thank you.

Just a bonus question: Say I want to summarize the Cave per x hours, but have a more dense TIME grid (as in NONMEM where I would include EVID =2 time points in between for later simulation) – how would you do that more elegantly that by just piecing together from the dAUC from the other example.

Suppose that would be some sequence/procedure statement?

Thx

Thomas

TIME C Cave(tau=24)

0 3 .

0.5 7 .

1 9 .

2 33 .

4 44 .

24 34 41432

24.5 57 .

25 92 .

26 102 .

48 37 59322

etc