+--------------------------------------------------------------------+
 |                                                                    |
 |                       INTERPOLATION IN $DES                        |
 |                                                                    |
 +--------------------------------------------------------------------+

 This  is  an example of code that can be used in $DES to interpolate a
 covariate such as WT between values that  are  recorded  on  the  data
 records.   This example is new to NONMEM 7.4, although the code can be
 used with previous versions.

 If D_WT is used in the model for volume  of  distribution,  then  this
 would allow a time-varying volume of distribution to be integrated.

 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.
 Additional  code (for integrating D_WT in $DES and the geometric solu-
 tion in $ERROR) is for testing and would not be  part  of  the  user's
 control stream.

 The code cannot be used when any WT values are missing.  $PK sees only
 the previous and current record.  If WT is missing  from  the  current
 record, $PK has no way of knowing what WT will be on the next record.

 The  code  in  NONMEM  7.3  help  file  INFN_INTERPOLATION  EXAMPLE  2
 (infn2.exa) can be used to fill in missing  WT  values  in  the  event
 records.   The  $INFN  block  makes  two  passes through the data set.
 After the first pass, it knows what the WT values are on all the event
 records, so that it can interpolate to fill in a missing WT.

 The  finedata  utility   (fine1.exa)  can  also be used to fill in the
 missing values, and performs interpolation if necessary.

 (See infn2.exa).
 (See fine1.exa).

 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 geometrically 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 geometric solution as a test.
 ; Does not use compartment amounts.
 ; Use 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 geometric 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

REFERENCES: Guide RENCES:

  
Go to main index.
  
Created by nmhelp2html v. 1.0 written by Niclas Jonsson (Modified by AJB 5/2006,11/2007,10/2012)