if-the-statement for 3 class categorical covariate

6 messages 6 people Latest: Jul 25, 2013
Dear all I am shoked because NONMEM sents a crash message when i factor in covariate modeling using a 4 class categorical variable genotype: IF (GENE.EQ.3) THEN ;GG CL = THETA(1)* EXP(ETA(1)) ELSE IF (GENE.EQ.2)THEN ;GT CL = THETA(6)* EXP(ETA(3)) IF (GENE.EQ.1) THEN ;TT CL = THETA(7)* EXP(ETA(4)) IF (GENE.EQ.4) THEN ;MISSING CL = THETA(7)* EXP(ETA(4)) END IF However if i binarize the code, nonmem runs successfully IF (GENE.EQ.3) THEN CL = THETA(1)* EXP(ETA(1)) ELSE CL = THETA(6)* EXP(ETA(3)) END IF Thanks in advance -- Bernard Ngara Trainee Biostatistician Africa Institute of Biomedical Science and Technology P. O Box 2294 Harare Zimbabwe +263 772 160 896
Hi Bernard, Try using just IF statements instead of including the ELSE IF and END IF like this: IF (GENE.EQ.3) THEN CL = THETA(1)* EXP(ETA(1)) ;GG IF (GENE.EQ.2) THEN CL = THETA(6)* EXP(ETA(3)) ;GT IF (GENE.EQ.1) THEN CL = THETA(7)* EXP(ETA(4)) ;TT IF (GENE.EQ.4) THEN CL = THETA(7)* EXP(ETA(4)) ;MISSING It's also worth verifying that GENE is always 1 to 4. The crash could be happening because you have a value other than 1 to 4. A way around this is to have a default value and then only apply changes like: CL = THETA(7)* EXP(ETA(4)) ; for TT or MISSING IF (GENE.EQ.3) THEN CL = THETA(1)* EXP(ETA(1)) ;GG IF (GENE.EQ.2) THEN CL = THETA(6)* EXP(ETA(3)) ;GT That will ensure that it works for all cases and will generally be more robust code. Thanks, Bill
Quoted reply history
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Bernard Ngara Sent: Thursday, July 25, 2013 10:09 AM To: nmusers Subject: [NMusers] if-the-statement for 3 class categorical covariate Dear all I am shoked because NONMEM sents a crash message when i factor in covariate modeling using a 4 class categorical variable genotype: IF (GENE.EQ.3) THEN ;GG CL = THETA(1)* EXP(ETA(1)) ELSE IF (GENE.EQ.2)THEN ;GT CL = THETA(6)* EXP(ETA(3)) IF (GENE.EQ.1) THEN ;TT CL = THETA(7)* EXP(ETA(4)) IF (GENE.EQ.4) THEN ;MISSING CL = THETA(7)* EXP(ETA(4)) END IF However if i binarize the code, nonmem runs successfully IF (GENE.EQ.3) THEN CL = THETA(1)* EXP(ETA(1)) ELSE CL = THETA(6)* EXP(ETA(3)) END IF Thanks in advance -- Bernard Ngara Trainee Biostatistician Africa Institute of Biomedical Science and Technology P. O Box 2294 Harare Zimbabwe +263 772 160 896
Hi, NM-TRAN has some restrictions on its language so that it can do the really tricky stuff behind the scenes that is needed to create the FORTRAN that NONMEM uses. These restrictions apply tocoding conditional statements. First of all you cannot have nested IF-THEN-ELSE blocks with NM-TRAN if they include random variables. The NM-TRAN error message states this if you try this. 326 RANDOM VARIABLE IS DEFINED IN A NESTED IF STRUCTURE. The example provided by Bernard is a nested structure containing random effects (ETA variables). As coded by Bernard it is not legal. ENDIF statements are always required for every IF-THEN. So the 'crash' experienced by Bernard was caused by not following the rules. I have re-coded it below to show the nested structure. However, this will fail in NM-TRAN because of the use of ETA variables in the expressions. IF (GENE.EQ.3) THEN ;GG CL = THETA(1)* EXP(ETA(1)) ELSE IF (GENE.EQ.2)THEN ;GT CL = THETA(6)* EXP(ETA(3)) IF (GENE.EQ.1) THEN ;TT CL = THETA(7)* EXP(ETA(4)) IF (GENE.EQ.4) THEN ;MISSING CL = THETA(7)* EXP(ETA(4)) ENDIF ENDIF ENDIF ENDIF The second rule is that one line IF statements cannot include THEN so the suggestion from Bill won't work. It needs to be written like this: IF (GENE.EQ.3) CL = THETA(1)* EXP(ETA(1)) ;GG IF (GENE.EQ.2) CL = THETA(6)* EXP(ETA(3)) ;GT IF (GENE.EQ.1) CL = THETA(7)* EXP(ETA(4)) ;TT IF (GENE.EQ.4) CL = THETA(7)* EXP(ETA(4)) ;MISSING Best wishes, Nick
Quoted reply history
On 25/07/2013 4:54 p.m., Denney, William S. wrote: > Hi Bernard, > > Try using just IF statements instead of including the ELSE IF and END IF like > this: > > IF (GENE.EQ.3) THEN CL = THETA(1)* EXP(ETA(1)) ;GG > IF (GENE.EQ.2) THEN CL = THETA(6)* EXP(ETA(3)) ;GT > IF (GENE.EQ.1) THEN CL = THETA(7)* EXP(ETA(4)) ;TT > IF (GENE.EQ.4) THEN CL = THETA(7)* EXP(ETA(4)) ;MISSING > > It's also worth verifying that GENE is always 1 to 4. The crash could be > happening because you have a value other than 1 to 4. A way around this is to > have a default value and then only apply changes like: > > CL = THETA(7)* EXP(ETA(4)) ; for TT or MISSING > IF (GENE.EQ.3) THEN CL = THETA(1)* EXP(ETA(1)) ;GG > IF (GENE.EQ.2) THEN CL = THETA(6)* EXP(ETA(3)) ;GT > > That will ensure that it works for all cases and will generally be more robust > code. > > Thanks, > > Bill > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Bernard Ngara > Sent: Thursday, July 25, 2013 10:09 AM > To: nmusers > Subject: [NMusers] if-the-statement for 3 class categorical covariate > > Dear all > > I am shoked because NONMEM sents a crash message when i factor in covariate > modeling using a 4 class categorical variable genotype: > IF (GENE.EQ.3) THEN ;GG > CL = THETA(1)* EXP(ETA(1)) > ELSE IF (GENE.EQ.2)THEN ;GT > CL = THETA(6)* EXP(ETA(3)) > IF (GENE.EQ.1) THEN ;TT > CL = THETA(7)* EXP(ETA(4)) > IF (GENE.EQ.4) THEN ;MISSING > CL = THETA(7)* EXP(ETA(4)) > END IF > However if i binarize the code, nonmem runs successfully IF (GENE.EQ.3) THEN > CL = THETA(1)* EXP(ETA(1)) > ELSE > CL = THETA(6)* EXP(ETA(3)) > > END IF > > Thanks in advance > -- > Bernard Ngara > Trainee Biostatistician > Africa Institute of Biomedical Science and Technology P. O Box 2294 Harare > Zimbabwe > +263 772 160 896 -- Nick Holford, Professor Clinical Pharmacology Dept Pharmacology & Clinical Pharmacology, Bldg 503 Room 302A University of Auckland,85 Park Rd,Private Bag 92019,Auckland,New Zealand office:+64(9)923-6730 mobile:NZ +64(21)46 23 53 FR +33(7)85 36 84 99 email: [email protected] http://holford.fmhs.auckland.ac.nz/ Holford NHG. Disease progression and neuroscience. Journal of Pharmacokinetics and Pharmacodynamics. 2013;40:369-76 http://link.springer.com/article/10.1007/s10928-013-9316-2 Holford N, Heo Y-A, Anderson B. A pharmacokinetic standard for babies and adults. J Pharm Sci. 2013: http://onlinelibrary.wiley.com/doi/10.1002/jps.23574/abstract Holford N. A time to event tutorial for pharmacometricians. CPT:PSP. 2013;2: http://www.nature.com/psp/journal/v2/n5/full/psp201318a.html Holford NHG. Clinical pharmacology = disease progression + drug action. British Journal of Clinical Pharmacology. 2013: http://onlinelibrary.wiley.com/doi/10.1111/bcp.12170/abstract
Hi Bernard, There are many ways to code it. Another way to code is: GENE1=0 GENE2=0 GENE3=0 IF (GENE.EQ.1.OR.GENE.EQ.4) GENE1=1 ; TT/missing IF (GENE.EQ.2) GENE2=1 ; GT IF (GENE.EQ.3) GENE3=1 ; GG CL = THETA(1)*GENE1*EXP(ETA(1)) + THETA(2)*GENE2*EXP(ETA(2)) + THETA(3)*GENE3*EXP(ETA(3)) Best Mukul Minocha University of Maryland Baltimore
Quoted reply history
On Thu, Jul 25, 2013 at 10:08 AM, Bernard Ngara <[email protected]>wrote: > Dear all > > I am shoked because NONMEM sents a crash message when i factor in > covariate modeling using a 4 class categorical variable genotype: > IF (GENE.EQ.3) THEN ;GG > CL = THETA(1)* EXP(ETA(1)) > ELSE IF (GENE.EQ.2)THEN ;GT > CL = THETA(6)* EXP(ETA(3)) > IF (GENE.EQ.1) THEN ;TT > CL = THETA(7)* EXP(ETA(4)) > IF (GENE.EQ.4) THEN ;MISSING > CL = THETA(7)* EXP(ETA(4)) > END IF > However if i binarize the code, nonmem runs successfully > IF (GENE.EQ.3) THEN > CL = THETA(1)* EXP(ETA(1)) > ELSE > CL = THETA(6)* EXP(ETA(3)) > > END IF > > Thanks in advance > -- > Bernard Ngara > Trainee Biostatistician > Africa Institute of Biomedical Science and Technology > P. O Box 2294 > Harare > Zimbabwe > +263 772 160 896 > -- -Mukul
It is not a good idea to use enclosed IF loops. Use CODE1=0 IF(GENE.EQ.1) CODE1=1 .... CODE4=0 IF(GENE.EQ.4) CODE4=1 CL=(CODE1*THETA(1)+...+CODE4*THETA(4))*EXP(ETA(1)) Leonid -------------------------------------- Leonid Gibiansky, Ph.D. President, QuantPharm LLC web: www.quantpharm.com e-mail: LGibiansky at quantpharm.com tel: (301) 767 5566
Quoted reply history
On 7/25/2013 10:08 AM, Bernard Ngara wrote: > Dear all > > I am shoked because NONMEM sents a crash message when i factor in > covariate modeling using a 4 class categorical variable genotype: > IF (GENE.EQ.3) THEN ;GG > CL = THETA(1)* EXP(ETA(1)) > ELSE IF (GENE.EQ.2)THEN ;GT > CL = THETA(6)* EXP(ETA(3)) > IF (GENE.EQ.1) THEN ;TT > CL = THETA(7)* EXP(ETA(4)) > IF (GENE.EQ.4) THEN ;MISSING > CL = THETA(7)* EXP(ETA(4)) > END IF > However if i binarize the code, nonmem runs successfully > IF (GENE.EQ.3) THEN > CL = THETA(1)* EXP(ETA(1)) > ELSE > CL = THETA(6)* EXP(ETA(3)) > > END IF > > Thanks in advance
Dear Bernard, If you want to model the effect of a 4 categorical covariate (genotype) on CL I would try the following code: ;3 dummy categories because you have one covariate of 4 categories.UG1=0UG2=0UG3=0 ;Reference category [I have supposed TT (GENE.EQ.1)]IF (GENE.EQ.2) UG1=1 ;GTIF (GENE.EQ.3) UG2=1 ;GGIF (GENE.EQ.4) UG3=1 ;MISSING MU1 = LOG(THETA(1)*(THETA(2)**UG1*THETA(3)**UG2*THETA(4)**UG3)) CL = EXP(MU_1+ETA(1)) Hope it helps. On the other hand, why do you use a different ETA for each category of the genotype variable? Best regards. Mario > Date: Thu, 25 Jul 2013 07:08:32 -0700 > Subject: [NMusers] if-the-statement for 3 class categorical covariate > From: [email protected] > To: [email protected] > > Dear all > > I am shoked because NONMEM sents a crash message when i factor in > covariate modeling using a 4 class categorical variable genotype: > IF (GENE.EQ.3) THEN ;GG > CL = THETA(1)* EXP(ETA(1)) > ELSE IF (GENE.EQ.2)THEN ;GT > CL = THETA(6)* EXP(ETA(3)) > IF (GENE.EQ.1) THEN ;TT > CL = THETA(7)* EXP(ETA(4)) > IF (GENE.EQ.4) THEN ;MISSING > CL = THETA(7)* EXP(ETA(4)) > END IF > However if i binarize the code, nonmem runs successfully > IF (GENE.EQ.3) THEN > CL = THETA(1)* EXP(ETA(1)) > ELSE > CL = THETA(6)* EXP(ETA(3)) > > END IF > > Thanks in advance > -- > Bernard Ngara > Trainee Biostatistician > Africa Institute of Biomedical Science and Technology > P. O Box 2294 > Harare > Zimbabwe > +263 772 160 896