RE: Markov model dataset
Dear Achim,
The problem seems to be that you are resetting compartments (CMT= negative
value) that you have yet not initialized (CMT=positive value).
There might be bigger problems with the code and dataset especially if you are
planning to also use it for simulations. To do this I recommend that you at
each time point add a dose in each of the 4 compartments (EVID=1 and AMT=1).
Then you will use if statements in the model file to set F1, F2, F3 and F4.
Based on the previous observation so that the dose actually only enters the
relevant compartment. I also recommend that you observations have CMT = 0 and
the DV value = to the grade (0,1,2,3) this is also going to be more convenient
especially for simulations (I have added some example code below and including
code for simulations). The dataset can also be shortened by using a EVID = 4
dose to reset all compartments rather than resetting them 1 by 1. See an
example in the bottom of my email.
There are multiple ways of doing this I have only described my preferred way of
doing it.
Best of luck with the modeling!
Martin Bergstrand, PhD
Pharmacometrics Research Group
Dept of Pharmaceutical Biosciences
Uppsala University, Sweden
Postal address: Box 591, 751 24 Uppsala, Sweden
Phone +46 18 471 42 27
Mobile +46 709 994 396
Fax + 46 18 471 40 03
$PK
; << Beginning of $PK code >>
IF(NEWIND.NE.2) PSDV = 0
PRSP = PSDV ; Previous DV
; Compartment initialization
F1 = 0
F2 = 0
F3 = 0
F4 = 0
IF(PRSP.EQ.0) F1 = 1 ; Initialize compartment 1 if RSPP = 1 (no tox)
IF(PRSP.EQ.1) F2 = 1 ; Initialize compartment 2 if RSPP = 2 (grade 1)
IF(PRSP.EQ.2) F3 = 1 ; Initialize compartment 3 if RSPP = 3 (grade 2)
IF(PRSP.EQ.3) F4 = 1 ; Initialize compartment 4 if RSPP = 4 (grade 3)
$ERROR
IF(DV.EQ.0.AND.CMT.EQ.0) Y = A(1)
IF(DV.EQ.1.AND.CMT.EQ.0) Y = A(2)
IF(DV.EQ.2.AND.CMT.EQ.0) Y = A(3)
IF(DV.EQ.3.AND.CMT.EQ.0) Y = A(4)
; Cumulative probabilities
CUP1 = P1
CUP2 = P1 +P2
CUP3 = P1 +P2 +P3
CUP4 = P1 +P2 +P3 +P4
; Simulation code
IF(ICALL.EQ.4) THEN
CALL RANDOM (2,R)
IF(R.LE.CUP1) DV = 0
IF(R.GT.CUP1.AND.R.LE.CUP2) DV = 1
IF(R.GT.CUP2.AND.R.LE.CUP3) DV = 2
IF(R.GT.CUP3) DV = 3
ENDIF
; << End of $ERROR code >>
PSDV = DV ; Store previous DV
; To activate for simulation
;$SIM (7776) (8877 UNIFORM) ONLYSIM NOPREDICTION
<< Dataset example >>
C ID TIME DOSE DV EVID CMT AMT MDV
0 1 0 0 0 1 1 1 1
0 1 1 50 0 0 0 0 0
0 1 1 50 0 4 1 1 1
0 1 1 50 0 1 2 1 1
0 1 1 50 0 1 3 1 1
0 1 1 50 0 1 4 1 1
0 1 2 50 0 2 0 0 0
0 1 2 50 0 4 1 1 1
0 1 2 50 0 1 2 1 1
0 1 2 50 0 1 3 1 1
0 1 2 50 0 1 4 1 1
0 1 3 50 0 1 0 0 0
0 1 3 50 0 4 1 1 1
0 1 3 50 0 1 2 1 1
0 1 3 50 0 1 3 1 1
0 1 3 50 0 1 4 1 1