Dear Nick, Thorsten and others,

Nick's example is very good.
He models WT so that it increases linearly with TIME:
DWT_T=WT_ZERO + WT_ALPHA*T
where WT_ZERO and WT_ALPHA are thetas.

It occurs to me that some users may not have a model for WT vs. T, 
but have only observed values of WT at fixed points.
In this case, WT can be interpolated within the $DES block.

Here is a small example of code that can be used to interpolate WT 
between values that are recorded on the data records.
All the code in $PK to compute OLDTIME and OLDWT and SLOPE, and
the code for D_WT in $DES, could be copied to user's control stream.
Other code (for integrating D_WT in $DES and the analytic solution in
$ERROR)
is for testing and would not be part of the user's control stream.  

Here is the control file:

$PROB  INTERPOLATE WT IN $DES
; this example shows how to interpolate WT in $DES.
; it is assumed that WT is recorded on every data record.     
; As a test, the value of D_WT in $DES is integrated to obtain AUC of WT
VS. T
; This is also calculated analytically in $ERROR.

$INPUT      ID TIME WT DV
$DATA       desinterp.dat

$SUBROUTINES  ADVAN6  TOL=5
$MODEL 
COMP=(AUC_WT DEFOBS)

$PK
; initialize OLDTIME and OLDWT
IF (NEWIND.LE.1) THEN
  OLDTIME=TIME
  OLDWT=WT
ENDIF

; calculate the slope for $DES
DELTA_TIME=TIME-OLDTIME
DELTA_WT=WT-OLDWT

IF (DELTA_TIME>0) THEN
   SLOPE=DELTA_WT/DELTA_TIME
ELSE
   SLOPE=0.
ENDIF

; save wt and time for next $PK record
OLDTIME=TIME
OLDWT=WT

$DES
   D_WT=OLDWT+SLOPE*(T-OLDTIME) ; D_WT is the value of WT at time T
   DADT(1)=D_WT                 ; compute AUC of D_WT as a test

$ERROR
   Y=F+ETA(1)+EPS(1)

; Compute analytic solution as a test. 
; Does not use compartment amounts.
; Uses only the values of WT and TIME on event records.
; Suppose WT vs T looks like this:
; 
; 
;         WT
;          |           
;          |               w3   w4 
;          |          w2            w5
;          |      w1
;          |
;          --------------------------------> TIME
;                 t1  t2   t3   t4  t5 
;             
; at t2, the contribution to the sum is 
;   the rectangle  w1 x (t2-t1) 
;   plus the triangular piece
;   (w2-w1)/(t2-t1) / 2
;
;                   w2
;                  /|
;                 / |
;                /__|
;              w1   |
;               |   |
;               |   |
;           ------------
;               t1  t2
IF (NEWIND.LE.1) THEN
   PREV_WT=WT ; Initialize WT from previous data record
   SUM=0
ELSE
   SUM=SUM+PREV_WT*DELTA_TIME+DELTA_WT*DELTA_TIME/2
ENDIF
PREV_WT=WT ; save WT from previous data record

$OMEGA 1
$SIGMA 1

$TABLE  ID TIME WT PRED=AUC_WT SUM FILE=desinterp.tbl NOPRINT NOAPPEND 
; The following two values should always be equal:
; PRED (which is the AUC of WT obtained by integrating WT) 
; SUM (which is the analytic solution) computed in $ERROR

Here is the data file for the first subject. Note that WT 
sometimes is constant and sometimes decreases:
  1 0.    10  0 
  1 1.    20  0 
  1 2.    35  0 
  1 2.    35  0 
  1 4.    45  0 
  1 5.    40  0 

Here is the table file:
TABLE NO.  1
 ID          TIME        WT          AUC_WT      SUM
  1.0000E+00  0.0000E+00  1.0000E+01  0.0000E+00  0.0000E+00
  1.0000E+00  1.0000E+00  2.0000E+01  1.5000E+01  1.5000E+01
  1.0000E+00  2.0000E+00  3.5000E+01  4.2500E+01  4.2500E+01
  1.0000E+00  2.0000E+00  3.5000E+01  4.2500E+01  4.2500E+01
  1.0000E+00  4.0000E+00  4.5000E+01  1.2250E+02  1.2250E+02
  1.0000E+00  5.0000E+00  4.0000E+01  1.6500E+02  1.6500E+02

On Sat, Apr 23, 2016, at 01:43 AM, Nick Holford wrote:
> Thorsten,
> 
> Time varying V is no different from time varying CL (or any other 
> parameter). You should use the variable T in $DES, not TIME, in order to 
> have the time at the instant the DEQ solver evaluates $DES. T may occur 
> anywhere in the interval between the previous record TIME and the 
> current record TIME. TIME in $PK, $DES and $ERROR is the time at the end 
> of the $DES solution interval.
> 
> The other thing that you may wish to do is to assign the random effect 
> expression for V and CL in $PK so that you can estimate the random 
> variability after accounting for the fixed effect variability in WT. An 
> expression involving ETA() cannot be used in $DES so it has to be 
> assigned in $PK.
> 
> e.g.
> 
> $PK
> POP_V=THETA(1)
> POP_CL=THETA(2)
> WT_ZERO=THETA(3)
> WT_ALPHA=THETA(4)
> PPV_V=EXP(ETA(1)) ; random effect for V (PPV_V=population parameter 
> variability for V)
> PPV_CL=EXP(ETA(2)) ; random effect for CLT (PPV_CL=population parameter 
> variability for CL)
> 
> $DES
> ;Variable names e.g. DWT_T are used in $DES because the same variable 
> names cannot be assigned in both $DES and in $ERROR
> 
> DWT_T=WT_ZERO + WT_ALPHA*T ; fixed effect prediction of WT at T
> 
> ; Biology requires V and CL must both be functions of WT
> DGRP_V=POP_V*DWT_T/70
> DV=DGRP_V*PPV_V ; "individual" V at T using random effect for V
> 
> DGRP_CL=POP_CL*(DWT_T/70)**(3/4)
> DCL=DGRP_CL*PPV_CL ; "individual" CL at T using random effect for CL
> 
> DADT(1)= -DCL*A(1)/DV
> 
> $ERROR
> 
> WT_T=WT_ZERO + WT_ALPHA*TIME ; fixed effect prediction of WT at the TIME 
> of the current record
> 
> GRP_V=POP_V*WT_T/70
> GRP_CL=POP_CL*(WT_T/70)**(3/4)
> 
> V=VT*PPV_V ; "individual" V at the TIME of the current record
> CL=GRP_CL*PPV_CL ; "individual" CL at the TIME of the current record
> 
> C=A(1)/V
> 
> You may, of course, add random effects to WT_ZERO and/or WT_ALPHA as 
> well as having random effects on V and CL.
> 
> BTW You should consider using the term postmenstrual age rather than 
> gestational age. Gestational age is a single value defined at the time 
> of delivery according to the American Academy of Pediatrics (Engle et al 
> 2004). Postmenstrual age is a continuous variable which may be used 
> during pregnancy and after birth to represent the biological age of the 
> fetus/child.
> 
> Best wishes,
> 
> Nick
> 
> Engle WA. Age terminology during the perinatal period. Pediatrics. 
> 2004;114(5):1362-4.
> 
> 
> On 22-Apr-16 23:34, Thorsten Lehr wrote:
> >
> > Dear NMusers,
> >
> > I'm modeling a compound where body weight has a known impact on the 
> > volume of distribution. This compound is investigated in pregnant 
> > women over a long period (from gestational age of 8 weeks until they 
> > give birth). Consequently, the body weight changes over time and I 
> > have a decent formula to describe the individual body weight change. 
> > The PK model has to be coded by ODEs. Does anyone has experience how 
> > to integrate a time varying volume of distribution if differential 
> > equations are used?
> >
> > Best regards
> >
> > Thorsten
> >
> > -- 
> >
> > Thorsten Lehr, PhD
> > Junior Professor of Clinical Pharmacy
> > Saarland University
> > Campus C2 2
> > 66123 Saarbrücken
> > Germany
> >
> > Office:  +49/681/302-70255
> > Mobile: +49/151/22739489
> > [email protected]
> > www.clinicalpharmacy.me
> 
> -- 
> Nick Holford, Professor Clinical Pharmacology
> Dept Pharmacology & Clinical Pharmacology, Bldg 503 Room 302A
> University of Auckland,85 Park Rd,Private Bag 92019,Auckland,New Zealand
> office:+64(9)923-6730 mobile:NZ+64(21)46 23 53 FR+33(6)62 32 46 72
> email: [email protected]
> http://holford.fmhs.auckland.ac.nz/
> 
> "Declarative languages are a form of dementia -- they have no memory of
> events"
> 
> Holford SD, Allegaert K, Anderson BJ, Kukanich B, Sousa AB, Steinman A,
> Pypendop, B., Mehvar, R., Giorgi, M., Holford,N.H.G. Parent-metabolite
> pharmacokinetic models - tests of assumptions and predictions. Journal of
> Pharmacology & Clinical Toxicology. 2014;2(2):1023-34.
> Holford N. Clinical pharmacology = disease progression + drug action. Br
> J Clin Pharmacol. 2015;79(1):18-27.
> 


-- 
  Alison Boeckmann
  [email protected]

Reply via email to