96  Repeated Observation Records (NM72)

Introduction to NONMEM 7.6.0

Author

Robert J. Bauer

Published

June 1, 2025

To assist in specialized methodologies such as stochastic differential equations ([15,16,17], and see ..\examples\sde_inline\readme.txt), 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:

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 file to a stochastic differential equation (SDE) problem (courtesy of Dr. Christoffer Tornoe), that uses the XVID data items (..\examples\sde\sde_ex2_foce_xvid.ctl in the examples):

; 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

With the following fragment of the data file:

ID TIME DV     AMT CMT FLAG MDV EVID SDE XVID1 XVID1 XVID3

10          0  1000 1 0   11                   2 -1  -1  -1
1 0.5 24.317 0        11  00                   20    2   3
11          18.469 0  11  00                   20    2   3
1 1.5 18.018 0        11  00                   20    2   3
12          18.728 0  11  00                   20    2   3
1 2.5 13.445 0        11  00                   20    2   3
13          14.924 0  11  00                   20    2   3
1 3.5 11.846 0        11  00                   20    2   3
14          10.691 0  11  00                   20    2   3
1 4.5 9.9394 0        11  00                   20    2   3
15          9.9075 0  11  00                   20    2   3
1 5.5 10.7 0          11  00                   20    2   3
16          8.9861 0  11  00                   20    2   3
17          7.2274 0  11  00                   20    2   3
18          6.4909 0  11  00                   20    2   3
19          3.7281 0  11  00                   20    2   3
1 10 1.9238 0         11  00                   20    2   3
1 11 2.172 0          11  00                   20    2   3
1 12 1.0763 0         11  00                   20    2   3
20          0  1000 1 0   11                   2 -1  -1  -1
2 0.5 17.586 0        11  00                   20    2   3
21          13.758 0  11  00                   20    2   3
2 1.5 9.6241 0        11  00                   20    2   3
22          9.6419 0  11  00                   20    2   3
2 2.5 8.5945 0        11  00                   20    2   3
23          6.3709 0  11  00                   20    2   3
2 3.5 7.7656 0        11  00                   20    2   3
24          4.5152 0  11  00                   20    2   3
2 4.5 5.0167 0        11  00                   20    2   3
25          4.6339 0  11  00                   20    2   3
2 5.5 4.2107 0        11  00                   20    2   3
26          3.1452 0  11  00                   20    2   3
27          2.0888 0  11  00                   20    2   3
28          2.4506 0  11  00                   20    2   3
29          0.001 0   11  00                   20    2   3
2 10 1.1174 0         11  00                   20    2   3
2 11 0.001 0          11  00                   20    2   3
2 12 0.001 0          11  00                   20    2   3

Compare this data file with sde_ex2.dat with its repeated data record (and see its control stream file ..\examples\sde\sde_ex2_foce.ctl), which is the traditional way of programming an SDE problem in NONMEM. The ..\examples\sde\sde_ex2_base.ctl control stream file is the problem without an SDE component.