Re: 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
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
Quoted reply history
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