Repeated Observation Records

To assist in specialized methodologies such as stochastic differential equations (SDE) [1-3] (see also "examples/sde_inline"), a record in a data file may be set up for repeated calls to PK and ERROR. Each time, the same record is passed through PK and/or ERROR, but with a different EVID. The user’s control stream model in $PK or $ERROR may then take advantage of executing certain code conditional on the EVID value. For this to occur, the user must introduce one or more of the following data items in the data file, with these names:

1
XVID1 XVID2 XVID3 XVID4 XVID5

These stand for “extra” EVID’s. On the first call to PK/ERROR, the EVID is set to the value given in XVID1. On the second call, the EVID is set to that in column XVID2, etc. up to XVID5. Only as many XVID’s as are required are needed to be defined. All the other items in the record do not change, except that if the present EVID used is not 0, then the MDV value is set to 1 for that call. If an XVID is -1, then the call to PK/ERROR for that XVID is not made, nor for the remaining XVID’s. If there is an EVID column, the value in this column is not passed to PK/ERROR unless XVID1=-1, in which case a “normal” call on that record occurs.

The following is a control stream (courtesy of Dr. Christoffer Tornoe) that uses the XVID data items ("examples/sde"):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
;#  Based on sde_ex2_base.ctl, with SDE equations put in, and .csv file
;#  modified.  From Christoffer Tornoe, example 2, and can work with NONMEM VI
;#  Using XVID data item method as data file type

$PROBLEM PK ODE HANDS ON ONE
$INPUT ID TIME DV AMT CMT FLAG MDV EVID SDE QA=XVID1 QB=XVID2 QZ=XVID3
$DATA   sde_ex2_xvid.dat
        IGNORE=@

$SUBROUTINE ADVAN6 TOL 10 DP
$MODEL
       COMP = (CENTRAL);#
       COMP = (P1)

$THETA (0,10)               ;# 1 CL
$THETA (0,32)               ;# 2 VD
$THETA (0, 2)               ;# 4 SIGMA
$THETA (0,1) ;#  SGW1
$OMEGA 0.1                  ;# 1 CL
$OMEGA 0.01                 ;# 2 VD
$SIGMA 1 FIX                ;#  PK

$PK
IF(NEWIND.NE.2) OT = 0
TVCL  = THETA(1)
CL    = TVCL*EXP(ETA(1))
TVVD  = THETA(2)
VD    = TVVD*EXP(ETA(2))
SGW1 = THETA(4)

IF(NEWIND.NE.2) THEN
  AHT1 = 0
  PHT1 = 0
ENDIF

IF(EVID.NE.3) THEN
  A1 = A(1)
  A2 = A(2)
ELSE
  A1 = A1
  A2 = A2
ENDIF

IF(EVID.EQ.0) OBS = DV

IF(EVID.GT.2.AND.SDE.EQ.2) THEN
  RVAR = A2*(1/VD)**2+ THETA(3)**2
  K1   = A2*(1/VD)/RVAR
  AHT1 = A1 + K1*(OBS -( A1/VD))
  PHT1 = A2 - K1*RVAR*K1
ENDIF

IF(EVID.GT.2.AND.SDE.EQ.3) THEN
  AHT1 = A1
  PHT1 = 0
ENDIF

IF(EVID.GT.2.AND.SDE.EQ.4) THEN
  AHT1 = 0
  PHT1 = A2
ENDIF

IF(A_0FLG.EQ.1) THEN
  A_0(1) = AHT1
  A_0(2) = PHT1
ENDIF

$DES
DADT(1) = - CL/VD*A(1) ;# +0
DADT(2) = (-CL/VD)*(A(2))+(-CL/VD)*(A(2))+SGW1*SGW1

$ERROR (OBS ONLY)
IPRED = A(1)/VD
IRES  = DV - IPRED
W=SQRT(A(2)*(1/VD)**2+ THETA(3)**2)
IWRES = IRES/W
Y     = IPRED+W*EPS(1)

$EST MAXEVAL=9999 METHOD=1 LAPLACE NUMERICAL SLOW INTER NOABORT SIGDIGITS=3 PRINT=1
$COV MATRIX=R
$TABLE ID TIME FLAG AMT CMT IPRED IRES IWRES EVID
   ONEHEADER NOPRINT FILE=sde_ex2_foce_xvid.tab

Reference

[1] R.V. Overgaard, N. Jonsson, C.W. Tornoe, and H. Madsen, Non-Linear Mixed Effects Models with Stochastic Differential Equations: Implementation of an Estimation Algorithm. J. Pharmacokinetics and Pharmacodynamics, 2005; 32(1): 85-107.

[2] J.B. Moller, R.V. Overgaard, H. Madsen, T. Hansen, O. Pedersen, and S.H. Ingwersen. Predictive Performance for Population Models Using Stochastic Differential Equations Applied on Data From an Oral Glucose Tolerance Test. J. Pharmacokinetics and Pharmacodynamics 2010; 37:85-98.

[3] C.W. Tornoe, R.V. Overgaard, H. Agerso, H. Nielsen, H. Madsen, and E.N. Jonsson. Stochastic Differential Equations in NONMEM: Implementation, Application, and Comparison with Ordinary Differential Equations. Pharmaceutical Research, 2005; 22(8): 1247-1258.