Markov model dataset

4 messages 4 people Latest: Feb 12, 2016

Markov model dataset

From: Achim Fritsch Date: February 08, 2016 technical
Dear all, I am currently trying to model the transitions from CTCAE grade 0 - 3 (4 states) for several toxicities using a markov approach in Nonmem. However, I am facing some problems with the data set, which I cannot solve by myself. The set looks like this: C ID TIME DOSE DV EVID CMT AMT MDV 0 1 0 0 0 1 1 1 1 0 1 1 50 1 0 1 0 0 0 1 1 50 0 2 -1 0 1 0 1 1 50 0 2 -2 0 1 0 1 1 50 0 2 -3 0 1 0 1 1 50 0 2 -4 0 1 0 1 1 50 0 1 1 1 1 0 1 1 50 0 2 2 0 1 0 1 1 50 0 2 3 0 1 0 1 1 50 0 2 4 0 1 To implement the markov property the compartments are emptied and initialized after each observation. When I try to execute the model I get the following error message for every record where the compartment without a previous observation is emptied : COMPARTMENT ASSOCIATED WITH THE PREDICTION IS OFF In the example above this error refers to record 4 - 6. When I remove these records the model works, but then I am violating the markovian assumption, if I am not mistaken. Am I missing something important? Any help is highly appreciated! Here are the relevant parts of the control file: $DES K01_F = K01 * EXP(-GAM*T) + DOSE*SLP K02_F = K02 * EXP(-GAM*T) + DOSE*SLP K03_F = K03 * EXP(-GAM*T) + DOSE*SLP K12_F = K12 * EXP(-GAM*T) + DOSE*SLP K23_F = K23 * EXP(-GAM*T) + DOSE*SLP KB10 = KB * EXP(-BA*DOSE) KB21 = KB * EXP(-BA*DOSE) KB32 = KB * EXP(-BA*DOSE) KB20 = KB * EXP(-BA*DOSE) KB30 = KB * EXP(-BA*DOSE) DADT(1) = A(2)*KB10 + A(3)*KB20 + A(4)*KB30 - A(1) * (K01_F + K02_F + K03_F) ; No grade DADT(2) = A(1)*K01_F - A(2) * (K12_F + KB10) ; Grade 1 DADT(3) = A(2)*K12_F + A(1)*K02_F - A(3) * (K23_F + KB21 + KB20) ; Grade 2 DADT(4) = A(3)*K23_F + A(1)*K03_F - A(4) * (KB32 + KB30) ; Grade 3 $ERROR PB0 = A(1) PB1 = A(2) PB2 = A(3) PB3 = A(4) Y = 1 IF(DV.EQ.1.AND.CMT.EQ.1) Y = A(1) IF(DV.EQ.1.AND.CMT.EQ.2) Y = A(2) IF(DV.EQ.1.AND.CMT.EQ.3) Y = A(3) IF(DV.EQ.1.AND.CMT.EQ.4) Y = A(4) $ESTIMATION SIG=3 MAXEVAL=9999 PRINT=1 METHOD=1 LAPLACIAN LIKE NOABORT Thank you very much in advance! Kind regards ____________________ Achim Fritsch Pharmacist Klinische Pharmazie Pharmazeutisches Institut Universität Bonn An der Immenburg 4 53121 Bonn Tel.: 0228 / 73 5229 Fax.: 0228 / 73 9757 [email protected]

Re: Markov model dataset

From: Ahmed Suleiman Date: February 08, 2016 technical
Hi Achim, After some quick testing, and for some reason (which I am not aware of), if a compartment (e.g. a PK compartment) is added before these adverse events compartments, then it works fine. I would be also interested to know why. Best regards, Ahmed Suleiman
Quoted reply history
On Mon, Feb 8, 2016 at 8:22 AM, Achim Fritsch <[email protected]> wrote: > Dear all, > > > > I am currently trying to model the transitions from CTCAE grade 0 - 3 (4 > states) for several > > toxicities using a markov approach in Nonmem. > > However, I am facing some problems with the data set, which I cannot solve > by myself. > > > > The set looks like this: > > > > C > > ID > > TIME > > DOSE > > DV > > EVID > > CMT > > AMT > > MDV > > 0 > > 1 > > 0 > > 0 > > 0 > > 1 > > 1 > > 1 > > 1 > > 0 > > 1 > > 1 > > 50 > > 1 > > 0 > > 1 > > 0 > > 0 > > 0 > > 1 > > 1 > > 50 > > 0 > > 2 > > -1 > > 0 > > 1 > > 0 > > 1 > > 1 > > 50 > > 0 > > 2 > > -2 > > 0 > > 1 > > 0 > > 1 > > 1 > > 50 > > 0 > > 2 > > -3 > > 0 > > 1 > > 0 > > 1 > > 1 > > 50 > > 0 > > 2 > > -4 > > 0 > > 1 > > 0 > > 1 > > 1 > > 50 > > 0 > > 1 > > 1 > > 1 > > 1 > > 0 > > 1 > > 1 > > 50 > > 0 > > 2 > > 2 > > 0 > > 1 > > 0 > > 1 > > 1 > > 50 > > 0 > > 2 > > 3 > > 0 > > 1 > > 0 > > 1 > > 1 > > 50 > > 0 > > 2 > > 4 > > 0 > > 1 > > > > To implement the markov property the compartments are emptied and > initialized after each observation. > > When I try to execute the model I get the following error message for > every record where the compartment without > > a previous observation is emptied : > > > > COMPARTMENT ASSOCIATED WITH THE PREDICTION IS OFF > > > > In the example above this error refers to record 4 - 6. > > > > When I remove these records the model works, but then I am violating the > markovian assumption, if I am not mistaken. > > > > Am I missing something important? Any help is highly appreciated! > > > > Here are the relevant parts of the control file: > > > > $DES > > > > K01_F = K01 * EXP(-GAM*T) + DOSE*SLP > > K02_F = K02 * EXP(-GAM*T) + DOSE*SLP > > K03_F = K03 * EXP(-GAM*T) + DOSE*SLP > > K12_F = K12 * EXP(-GAM*T) + DOSE*SLP > > K23_F = K23 * EXP(-GAM*T) + DOSE*SLP > > > > KB10 = KB * EXP(-BA*DOSE) > > KB21 = KB * EXP(-BA*DOSE) > > KB32 = KB * EXP(-BA*DOSE) > > KB20 = KB * EXP(-BA*DOSE) > > KB30 = KB * EXP(-BA*DOSE) > > > > DADT(1) = A(2)*KB10 + A(3)*KB20 + A(4)*KB30 - A(1) * (K01_F + K02_F + > K03_F) ; No grade > > DADT(2) = A(1)*K01_F - A(2) * (K12_F + > KB10) ; Grade 1 > > DADT(3) = A(2)*K12_F + A(1)*K02_F - A(3) * (K23_F + KB21 + > KB20) ; Grade 2 > > DADT(4) = A(3)*K23_F + A(1)*K03_F - A(4) * (KB32 + KB30) > ; Grade 3 > > > > $ERROR > > > > PB0 = A(1) > > PB1 = A(2) > > PB2 = A(3) > > PB3 = A(4) > > > > Y = 1 > > IF(DV.EQ.1.AND.CMT.EQ.1) Y = A(1) > > IF(DV.EQ.1.AND.CMT.EQ.2) Y = A(2) > > IF(DV.EQ.1.AND.CMT.EQ.3) Y = A(3) > > IF(DV.EQ.1.AND.CMT.EQ.4) Y = A(4) > > > > $ESTIMATION SIG=3 MAXEVAL=9999 PRINT=1 METHOD=1 LAPLACIAN LIKE NOABORT > > > > > > > > Thank you very much in advance! > > > > Kind regards > > > > > > > > ____________________ > > *Achim Fritsch* > > Pharmacist > > > > Klinische Pharmazie > > Pharmazeutisches Institut > > Universität Bonn > > An der Immenburg 4 > > 53121 Bonn > > > > Tel.: 0228 / 73 5229 > > Fax.: 0228 / 73 9757 > > > > [email protected] > > > > >

RE: Markov model dataset

From: Martin Bergstrand Date: February 08, 2016 technical
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

Re: Markov model dataset

From: Alison Boeckmann Date: February 12, 2016 technical
Here iis an explanation of why the error messages were being produced by PREDPP. At my request, Achim send me the $MODEL statement from the control stream. $MODEL NCOMP = 4 COMP=(G0) COMP=(G1) COMP=(G2) COMP=(G3) Compartment 1 is the default compartment for doses and observations, because no compartment has the name CENTRAL or the attribute DEFOBS. PREDPP always needs to compute a scaled compartment amount as the argument F for the ERROR routine. When compartment 1 is off and PREDPP needs to get the prediction from compartment 1 , the error messages are produced. 0DATA REC 4: COMPARTMENT ASSOCIATED WITH THE PREDICTION IS OFF 0DATA REC 5: COMPARTMENT ASSOCIATED WITH THE PREDICTION IS OFF 0DATA REC 6: COMPARTMENT ASSOCIATED WITH THE PREDICTION IS OFF Here's a work around, as Ahmed Suleiman suggested: $MODEL NCOMP = 5 COMP=(G0) COMP=(G1) COMP=(G2) COMP=(G3) COMP=(DUMMY,DEFOBS) Also add to the end of the $DES block: DADT(5)=0 Now compartment 5 is default for observations and there are no error messages. Martin Bergstrand made a number of suggestions. The one that is directly related to these error messages is to use "a EVID = 4 dose to reset all compartments rather than resetting them 1 by 1." EVID=4 is "reset and dose". All compartments are set to 0, and then the dose is applied to compartment 1. The data would look like this. No changes to $MODEL or $DES are needed, because compartment 1 is never turned off. C ID TIME DOSE DV EVID CMT AMT MDV 1 0 0 0 1 1 1 1 1 1 50 1 0 1 0 0 1 1 50 0 4 1 1 1 1 1 50 0 2 2 0 1 1 1 50 0 2 3 0 1 1 1 50 0 2 4 0 1 Martin made other valuable suggestions but I am just trying to explain the error messages.