RE: Coding for simulation

From: Magnus Åstrand Date: March 26, 2014 technical Source: mail-archive.com
Dear All Another solution would be to first generate (or add) the WT, GENDER and Genotype and put these in the indata set, with R most of what you are doing in NONMEM would be just 2-3 lines of code. I you want to peruse this I could guide you on how to. Also, a comment on the NONMEM code below, I had the impressions that "CALL SIMETA(ETA)" simulates ALL ETA's. If I'm correct the second while loop will overwrite the selection on ABS(ETA(1))<0.52 in the first loop. BW Magnus, happy to be corrected on my knowledge on CALL SIMETA(ETA)
Quoted reply history
From: [email protected] [mailto:[email protected]] On Behalf Of Åsa Johansson Sent: den 26 mars 2014 08:51 To: Matthew Hui; NONMEM user network (for question and remarks) Subject: Re: [NMusers] Coding for simulation Dear Matthew, For simulation of WT with known mean and variance I use this code (different mean and variance for males and females respectively): IF(ICALL == 4) THEN ;---- WT simulation --------------------------- IF(NEWIND /= 2) THEN DO WHILE (ABS(ETA(1)).GT.0.52) CALL SIMETA(ETA) ENDDO DO WHILE (ABS(ETA(2)).GT.0.60) CALL SIMETA(ETA) ENDDO ENDIF IF(MALE == 1) WT = THETA(1)*EXP(ETA(1)) ;WT simulation for males IF(MALE == 0) WT = THETA(2)*EXP(ETA(2)) ;WT simulation for females ENDIF $THETA 85 FIX ; 1 WT MALE $THETA 75 FIX ; 2 WT FEMALE $OMEGA 0.03 FIX ; 1 OM WT MALE $OMEGA 0.04 FIX ; 2 OM WT FEMALE $SIM (12345 NEW) The "DO WHILE"-loop is used to force the simulated ETAs to not be more than 3 standard deviations away from the typical value in the population (to avoid extreme WT values) and the "NEW" option in $SIM is required to simulate a new ETA in case the one just simulated doesn't fulfill the requirements in the "DO WHILE"-loop (is more than 3 standard deviations away from THETA). For simulation of different genotypes with known proportions, this code should work: IF(ICALL == 4)THEN ;---- Genotype simulation --------------------- IF(NEWIND /= 2) THEN CALL RANDOM (1,R) RAND = R ENDIF GENOT = 1 ; Genotype A (10%) IF(RAND <= 0.9) GENOT = 2 ; Genotype B (30%) IF(RAND <= 0.6) GENOT = 3 ; Genotype C (60%) ENDIF $SIM (12345 UNI) "CALL RANDOM" draws a random value using (in this case) the first seed number specified in $SIM and the "UNI" option in $SIM specifies that the random value should be drawn from a uniform distribution [0, 1]. Since the random value is between 0 and 1, this can be used to simulates proportions. Good luck! Åsa Johansson *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~* Åsa M. Johansson, MSc, PhD student *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~* Pharmacometrics Research Group Department of Pharmaceutical Biosciences Uppsala University P.O. Box 591 SE - 751 24 Uppsala SWEDEN Office: +46 18-471 43 29 Fax: +46 18-471 40 03 *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~* On 26/03/2014 05:29, Matthew Hui wrote: Dear all, I finished building a final model and now I am going on to do a simulation to investigate dose effect on plasma level. I wish to ask about some codes for the control stream for simulation. I want to simulate a population with 1. WT with known mean and variance 2. Different genotypes (A, B or C) with known proportions of each I am new to NONMEM and I have looked up and tried a few ways without success. Hope somebody could help. Thanks in advance, matthew -------------------------------------------------------------------------- Confidentiality Notice: This message is private and may contain confidential and proprietary information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorized use or disclosure of the contents of this message is not permitted and may be unlawful.
Mar 26, 2014 Matthew Hui Coding for simulation
Mar 26, 2014 Åsa Kragh Re: Coding for simulation
Mar 26, 2014 Magnus Åstrand RE: Coding for simulation