Re: how to model blood volume change during and after hemodialysis?

From: Luann Phillips Date: January 21, 2013 technical Source: mail-archive.com
Nele, To set up the dataset for this type of problem, I would recommend inserting 'other type' records at the start and stop time of dialysis (evid=2). I would also include an indicator variable (I'll call it DIAL) to show when dialysis is on (DIAL=1) and off (DIAL=0). As James mentioned, NONMEM imputes covariate values backwards. This means as NONMEM works from TIME=N to TIME=N+1 it uses the values of the covariates on the TIME=N+1 record. Example 1 Dataset: Not using EVID=2 records ID TIME EVID DIAL 1 0 1 1 ;dose record and dialysis started 1 0.2 0 1 ;observation record 1 1 0 1 ;observation record 1 3 0 0 ;observation record and dialysis stop time 1 8 0 0 ;observation record 1 12 1 1 ;2nd dose record and dialysis started 1 14 0 1 ;observation record 1 18 0 0 ;observation record For example 2, dial=1 (on) as NONMEM steps from TIME=0 to TIME=0.2, 0.2 to 1 dial=0 (off) as NONMEM steps from TIME=1 to 3, and 3 to 8 dial=1 (on) as NONMEM steps from TIME=8 to 12 and 12 to 14 dial=0 (off) as NONMEM steps from TIME=14 to 18 Note: This leads to incorrect settings of dialysis. Dialysis should not be shut off until time=3. However, the above dataset in effect shuts it off at TIME=1 and it remains off for 1 <= T <= 8. Dialysis should turn back on at time=12. However, the above dataset in effect turns dialysis on at TIME=8 and it remains on for 8 <= T <= 14. Dialysis should shut off at time=15. However, the above dataset in effect turns off dialysis at TIME=14 and it remains off for 14 <= T <= 18. Example 2 Dataset: Using EVID=2 Records (Correct Behavior) ID TIME EVID DIAL 1 0 1 0 ;dose record 1 0.01 2 1 ;dialysis started at time of dose (seconds after prior record) 1 0.2 0 1 ;observation record 1 1 0 1 ;observation record 1 3 0 1 ;observation record 1 3.01 2 0 ;dialysis stop time (seconds after prior record) 1 8 0 0 ;observation record 1 12 1 0 ;2nd dose record 1 12.01 2 1 ;dialysis started for 2nd dose (seconds after prior record) 1 14 0 1 ;observation record 1 15 2 1 ;other type record to transition Vc from decr. to incr. correctly 1 15.01 2 0 ;2nd dialysis stop time 1 18 0 0 ;observation For example 1, dial=0 (off) as NONMEM steps from TIME=0 to TIME=0.01 dial=1 (on) as NONMEM steps from TIME=0.01 to 0.2, 0.2 to 1, and 1 to 3 dial=0 (off) as NONMEM steps from TIME=3 to 3.01, 3.01 to 8, and 8 to 12 dial=1 (on) as NONMEM steps from TIME=12 to 12.01, 12.01 to 14, and 14 to 15 dial=0 (off) as NONMEM steps from TIME=15 to 15.01, etc. Putting in an EVID=2 record for each dialysis start and stop time within seconds after the prior dose or observation record allows NONMEM to use the correct value of DIAL for T values in between the observations. If a dialysis start or stop time does not have a dose or observation record that could be within seconds prior to the dialysis record, insert an EVID=2 record (see TIME=15 in example. If it had not been included in the dataset NONMEM would have shut off dialysis at TIME=14). I've modified the code you provided to fully implement the model based upon the dataset structure provided in Example 2. I have not tested the code so there may be typos or some other error that I may have missed. Also note this code will not work if you use ADDL on dose records unless you always include an EVID=2 record immediately prior to the dialysis evid=2 records. $SUBROUTINE ADVAN13 TOL=5 $MODEL NCOMP=2 COMP=(CENTRAL) COMP=(PERIPH) ; ----------------[ Structural Model ]---------------- $PK TVVM=THETA(1) VM=TVVM*EXP(ETA(1)) TVKM=THETA(2) KM=TVKM ;set initial value of Vc TVV1=THETA(3) INITVC=TVV1*EXP(ETA(2)) ;slope of Vc during dialysis VSLOPE=THETA(7) ;note equation implements the negative ;so initial estimate should be positive ;slope of Vc post-dialysis ;you could make this the same as VSLOPE but if you do the "Vc" ;will keep getting larger over time ;because the time dialysis is off is longer than the time ;dialysis is on. VSLOPEUP=THETA(8) TVQ=THETA(4) Q=TVQ TVV2=THETA(5) V2=TVV2 TVCL=THETA(6) CL=TVCL S1=1 ;scaling will be taken care of in ERROR block ;----------------[differential equations]------------- ;NOTE: If you have an observation at the exact TIME of dialysis start or stop ; an infinite value of the objective function will occur because using ; linear functions forms a cusp at TIME=DSTART or DSTOP ; If you have an observation or dose at the exact time of a dialysis start or stop ; increase the start or stop time of dialysis by a few seconds. $DES ;initialize variables IF(T.EQ.0) THEN LASTINT=0 PREVINT=0 DSTART=0 DSTOP=0 ENDIF ;with the EVID=2 records in the data at each start & stop time of dialysis ;the following code will allow the computation of elapsed time within each dialysis period ;PREVINT is set equal to the value of V1 calculated using the last value of T NONMEM used prior ;to the EVID=2 dialysis record. This value of PREVINT will remain fixed until the next EVID=2 record ; The - VSLOPEUP*(TLAST-DSTART) and + VSLOPE*(TLAST-DSTOP) in the PREVINT equations is to correct ; the previous value of V1 to the current value of T because when the diff eq. solver is stepping ; from TIME(N) to TIME(N+1) it may use a value of T slightly larger than TIME(N+1). ; If you have questions about this aspect of the code, feel free to call me (716-633-3463 ext. 236). IF(EVID.EQ.2.AND.DIAL.EQ.1.AND.TYPE.EQ.1)THEN DSTART=T ;capture the last value of V1 prior to turning dialysis on PREVINT=LASTINT - VSLOPEUP*(TLAST-DSTART) ENDIF IF(EVID.EQ.2.AND.DIAL.EQ.0.AND.TYPE.EQ.1) THEN DSTOP=T ;capture the last value of V1 prior to turning dialysis off PREVINT=LASTINT + VSLOPE*(TLAST-DSTOP) ENDIF ;if it is not the first dialysis start time set flg=1 FLG=0 IF(DSTART.GT.1)FLG=1 ;first start Vc begins declining from the initial value of Vc ;2nd and greater start Vc begins declining from the value it had just prior to re-starting dialysis ;the value of LASTINT will update every time NONMEM increments T IF(DIAL.EQ.1) THEN V1=(1-FLG)*(INITVC-VSLOPE*(T-DSTART)) + FLG*(PREVINT - VSLOPE*(T-DSTART)) LASTINT=V1 TLAST=T ELSE ;when dialysis shuts off it should always start increasing from the value it had just prior to ;shutoff of dialysis V1=PREVINT + VSLOPEUP*(T-DSTOP) LASTINT=V1 TLAST=T ENDIF CP=A(1)/V1 K12=Q/V1 K21=Q/V2 K10=CL/V1 DADT(1) = - K12*A(1) + K21*A(2) - A(1)*VM/(KM+A(1)) -K10*A(1) DADT(2) = K12*A(1) - K21*A(2) ; ----------------[ Error Model ]---------------- $ERROR ;Suggestion ;First model run: use DEL=0 & IF(AMT.GT.0)DEL=0.01 (only change W on dose records) ;changing the ipred or w on a dose record does not change the MVOF ;Changing the W on observation records changes the MVOF ;Only if you get an IPRED=0 on an observation record should you implement this coding ;because the MVOF is very sensitive to the value of DEL chosen. ;if a covariate or change in parameter values allows IPRED to be 0.00000001 for one model ;instead of 0 for the first model then that observation now has a weight of 0.00000001 instead ;of 0.01. This can lead to large changes in the MVOF (>50) indicating significance when the ;model only changed the estimate of the one observation by a very tiny amount. ;If you have to implement this type of code on observation records, I suggest running the same ;model with smaller and smaller values of DEL until the ;MVOF stays the same to prevent this issue. (I would start at DEL=0.00001) IPRED=CP ;or IPRED=A(2)/V1 DEL=0 IF (IPRED.EQ.0) DEL=0.01 W=CP+DEL IRES=DV-IPRED IWRES=IRES/W Y=IPRED + W*ERR(1) I hope this is helpful to solving some of the problems that you have encountered. Luann Phillips Director PK/PD Cognigen Corporation (716) 633-3463 ext. 236
Quoted reply history
On 1/21/2013 8:31 AM, James G Wright wrote: > Dear Nele, > > You are on the right track, it is just the NONMEM coding you need to work out. > Unfortunately, I have > a lot of work on this week so I won't have time to go through this, but it is > very likely you will > get excellent answers from other people on the list. > > The only tip I would give is it is usually easier to code the dialysis as a > covariate in the dataset > than manually put the times in the code. Watch out though as NONMEM usually > backward imputes > covariates (so you set your dialysis covariate to 0 at the start of dialysis > and 1 at the end to get > the correct profile). > > Good luck with the idiosyncracies of NONMEM! Kind regards, James > > On 21/01/2013 09:21, Kaessner, Nele wrote: > > > Hi James, dear all, > > Thanks for your answer. I have understood what you were writing, however I > > still have problems to > > implement the suggestions in NONMEM. This is mainly due to the somewhat > > inflexible way NONMEM > > works. My problems are the following: > > > > * The final V1 needs to be defined in $DES, as otherwise I cannot use T > > * V1 is used as a scaling factor to determine concentration. This would > > normally be done in $PK, > > where I cannot use parameters that are defined in $DES > > * Y and IPRED are calculated using A(1) and V1, but again $ERROR does not > > allow the use of T. My > > code circumvents this now by using TIME in $ERROR and T in $DES, but I > > don't like the solution > > of defining everything twice. > > * Basically, my major issue is that I can use T in $DES, but any PK parameter > > I calculate from > > this can then not be used in $PK or $ERROR, where I would actually need > > this. I am sure there > > must be a solution, but I cannot see it… > > * Additional problem: My code only allows for continuous volume decrease over > > the first > > hemodialysis session. Also, after dialysis it jumps directly back to the > > volume that I had > > before dialysis. What I would like to model instead would be a continuous > > drop in volume over > > dialysis, and then a reincrease to pre-dialysis levels over the next ~2h. > > You mentioned a > > linear rate after dialysis. How do you implement this? Any suggestions, > > preferably in NONMEM code? > > > > What I have right now: > > $SUBROUTINE ADVAN13 TOL=5 > > $MODEL NCOMP=2 > > COMP=(CENTRAL) > > COMP=(PERIPH) > > ; ----------------[ Structural Model ]---------------- > > $PK > > TVVM=THETA(1) > > VM=TVVM*EXP(ETA(1)) > > TVKM=THETA(2) > > KM=TVKM > > TVV1=THETA(3) > > VC=TVV1*EXP(ETA(2)) > > TVQ=THETA(4) > > Q=TVQ > > TVV2=THETA(5) > > V2=TVV2 > > TVCL=THETA(6) > > CL=TVCL > > TVVAC=THETA(7) > > V1ACC=TVVAC > > ; ----------------[ Error Model ]---------------- > > $ERROR > > ;parameter to describe volume decrease over dialysis > > VEDD=V1ACC > > ;after dialysis end (3h) volume back to higher levels > > IF (TIME.GT.3) VEDD=0 > > VD1=VC -VEDD*TIME ;I would like to use T, but get an error message if I do > > CE1=A(1)/VD1 > > IPRED=CE1 > > DEL=0 > > IF (IPRED.EQ.0) DEL=0.01 > > W=CE1 > > IRES=DV-IPRED > > IWRES=IRES/(W+DEL) > > Y=CE1+CE1*ERR(1) > > ;----------------[differential equations]------------- > > $DES > > VADD=V1ACC > > IF (T.GT.3) VADD=0 > > V1=VC-VADD*T > > ;Scaling needed to be shifted from $PK as it uses V1 > > S1=V1 > > K12=Q/V1 > > K21=Q/V2 > > K10=CL/V1 > > DADT(1) = - K12*A(1) + K21*A(2) - A(1)*VM/(KM+A(1)) -K10*A(1) > > DADT(2) = K12*A(1) - K21*A(2) > > Thanks again for your help. It is very much appreciated! > > Best > > Nele > > ______________________________________________________________ > > Dr. Nele Käßner > > Principal Scientist Modeling and Simulation > > Global Pharmacometrics > > Experimental Medicine > > Takeda Pharmaceuticals International GmbH > > Thurgauerstrasse 130 > > 8152 Glattpark-Opfikon (Zürich) > > Switzerland > > Visitor address: > > Alpenstrasse 3 > > 8152 Glattpark-Opfikon (Zürich) > > Switzerland > > Phone: (+41) 44 / 55 51 404 > > Mobile: (+41) 79 / 654 33 99 > > mailto: [email protected] > > http://www.takeda.com > > -----Original Message----- > > From: James G Wright [mailto:[email protected]] > > Sent: Freitag, 18. Januar 2013 5:10 > > To: Kaessner, Nele > > Cc: Ahmed N Mohamed; [email protected] > > Subject: Re: [NMusers] how to model blood volume change during and after > > hemodialysis? > > Dear Nele, > > You can use T if you just re-write the model using $DES and ADVAN13. > > What is slightly unusual and quite nice about dialysis volume changes is > > that you can model them with just one additional parameter. This > > fortunate situation arises because you know the times of dialysis > > (hopefully precisely). In-between dialysis occasions the plasma volume > > rises, as most subjects must/will consume more water than they can > > excrete, and then plasma volume falls back to the baseline during > > dialysis. So all you need to do is define you central volume as V1 > > (usually immediately post-dialysis) and then an additional parameter > > V1acc which is the impact of V1 on the additional accumulation of fluid > > per day since the last dialysis, so it has units of L/day, and multiply > > by the time since the last dialysis finished. Provided dialysis is > > completed, you can generally assume that all of V1acc*days is removed at > > an approximately linear rate during dialysis. This model can account > > for differences in dialysis schedule (e.g. weekends) and you can put a > > random effect on V1acc to account for differences in fluid accumulation > > between different patients. > > It's not perfect, but it is simple. Usually, peripheral volumes are > > less sensitive to body water so you don't see anything on these. This > > simple model can often be successfully superimposed on a dialysis > > clearance model. > > Best regards, James > > On 18/01/2013 15:12, Kaessner, Nele wrote: > > > Dear Ahmed and all, > > > > > > First of all, thank you for your response. > > > The reason I believe that blood volume is altered is because I see an > > increase in concentrations > > until the end of hemodialysis, despite the fact that compound infusion ended > > two hours earlier. I > > would want to estimate the decreasing volume using information from both > > subjects with and without > > hemodialysis (for those without dialysis, concentrations drop as expected after > > the end of the > > infusion). Clearance via hemodialysis is not a problem by the way, compound is > > too big :-) > > > My problem mostly relates to the coding in NONMEM. How do I model a > > continuous change in V1 over > > time? $PK does not allow the variable 'T' to be used, and I don't just want to > > use TIME, as this > > would only consider time points actually contained in the data set. > > > Any suggestions? > > > > > > Thank you and best regards > > > Nele > > > ______________________________________________________________ > > > > > > Dr. Nele Käßner > > > Principal Scientist Modeling and Simulation > > > Global Pharmacometrics > > > Experimental Medicine > > > > > > Takeda Pharmaceuticals International GmbH > > > Thurgauerstrasse 130 > > > 8152 Glattpark-Opfikon (Zürich) > > > Switzerland > > > > > > Visitor address: > > > Alpenstrasse 3 > > > 8152 Glattpark-Opfikon (Zürich) > > > Switzerland > > > > > > Phone: (+41) 44 / 55 51 404 > > > Mobile: (+41) 79 / 654 33 99 > > > > > > mailto: [email protected] > > > http://www.takeda.com > > > > > > > > > -----Original Message----- > > > From: Ahmed N Mohamed [mailto:[email protected]] > > > Sent: Freitag, 18. Januar 2013 3:28 > > > To: Kaessner, Nele > > > Cc: [email protected] > > > Subject: Re: [NMusers] how to model blood volume change during and after > > hemodialysis? > > > > > > Hello, > > > > > > In terms of how long it takes to restore blood volume, i think it should be > > immediate because > > they usually give fluids during the dialysis to replace lost blood volume. > > Otherwise, there will > > be a significant drop in BP. You may have the volumes of fluid given in the > > patient charts if you > > have that. > > > > > > In terms of changing volume you can do that in two ways: > > > 1. If you have serial measurements of patient body weight, you can link that > > to volume as a > > covariate and it will change with change in weight (time-varying covariate). > > But this needs hourly > > or even more frequent weight measurements. > > > > > > 2. You can model the change in volume with time using a simple linear slope > > model where volume > > decreases with time during dialysis and increases with time after dialysis and > > estimate the slope > > for each process. However, i think this will be difficult to estimate separate > > from changes in > > clearance and the slope estimates you get will just be arbitrary. If you have > > samples from > > dialysate, it might be better. > > > > > > I hope this helps. > > > > > > ----- Original Message ----- > > > From: "Nele Kaessner" <[email protected]> > > > To: [email protected] > > > Sent: Friday, January 18, 2013 8:24:05 AM > > > Subject: [NMusers] how to model blood volume change during and after > > hemodialysis? > > > > > > > > > > > > > > > Dear nmusers, > > > > > > > > > > > > I would like to model PK profiles of a compounds which mostly distributes in > > blood volume. The > > subjects which were investigated underwent hemodialysis for approx. the first > > three hours after > > infusion start, and the compound was given over a time period of ~5-10 min. > > > > > > It is well known that during hemodialysis, blood volume changes. Therefore, I > > would like to add > > a dynamic component to the central volume parameter, allowing it to decrease > > during hemodialysis > > and then to reincrease after dialysis has ended. I have all information about > > start and end time > > of both dosing and dialysis. Individual times between subjects differed. > > Unfortunately, I have not > > been creative enough to come up with a NONMEM code that can do this. Could any > > of you help out? > > > > > > Also, I probably do not have late enough time points to estimate when exactly > > blood volume would > > be restored. Does anyone know how much time the body needs after dialysis has > > ended until it is > > back to the original blood volume? > > > > > > > > > > > > Thanks for your help and best > > > > > > Nele > > > > > > ______________________________________________________________ > > > > > > > > > > > > Dr. Nele Käßner > > > > > > Principal Scientist Modeling and Simulation > > > > > > Global Pharmacometrics > > > > > > Experimental Medicine > > > > > > > > > > > > Takeda Pharmaceuticals International GmbH > > > > > > Thurgauerstrasse 130 > > > > > > 8152 Glattpark-Opfikon (Zürich) > > > > > > Switzerland > > > > > > > > > > > > Visitor address: > > > > > > Alpenstrasse 3 > > > > > > 8152 Glattpark-Opfikon (Zürich) > > > > > > Switzerland > > > > > > > > > > > > Phone: (+41) 44 / 55 51 404 > > > > > > Mobile: (+41) 79 / 654 33 99 > > > > > > > > > > > > mailto: [email protected] > > > > > > http://www.takeda.com > > > > > > -------------------------------------------------------------------- > > > > > > The content of this email and of any files transmitted may contain > > confidential, proprietary or > > legally privileged information and is intended solely for the use of the > > person/s or entity/ies to > > whom it is addressed. If you have received this email in error you have no > > permission whatsoever > > to use, copy, disclose or forward all or any of its contents. Please > > immediately notify the sender > > and thereafter delete this email and any attachments. > > > > > > -------------------------------------------------------------------- > > > > > > -------------------------------------------------------------------- > > > > > > The content of this email and of any files transmitted may contain > > confidential, proprietary or > > legally privileged information and is intended solely for the use of the > > person/s or entity/ies to > > whom it is addressed. If you have received this email in error you have no > > permission whatsoever > > to use, copy, disclose or forward all or any of its contents. Please > > immediately notify the sender > > and thereafter delete this email and any attachments. > > > > > > -------------------------------------------------------------------- > > > > > -- > > James G Wright PhD, > > Scientist, Wright Dose Ltd > > Tel: UK (0)772 5636914 > > -------------------------------------------------------------------- > > > > The content of this email and of any files transmitted may contain > > confidential, proprietary or legally privileged information and is intended > > solely for the use of the person/s or entity/ies to whom it is addressed. If > > you have received this email in error you have no permission whatsoever to use, > > copy, disclose or forward all or any of its contents. Please immediately notify > > the sender and thereafter delete this email and any attachments. > > > > -------------------------------------------------------------------- > > -- > James G Wright PhD, > Scientist, Wright Dose Ltd > Tel: UK (0)772 5636914