RE: Simulation with covariates

From: Mark Sale Date: February 15, 2007 technical Source: mail-archive.com
Kim, See simulation example two in the documentation (below). For the 0|1 you can either use and normal ETA (mean = 0) easily enough if you want it 50-50 (if ETA.LE.0 THEN 0, ELSE 1) if you want something other than 50-50, see documentation for RANDOM below the simulation 2 example stuff, and use a uniform seed. You can get a number from a uniform distribution between 0 and 1, then do something like, if you want 1/3 0 and 2/3 1 REAL R CALL RANDOM(2,R) IF(R.LT.0.333) THEN TRT = 0 ELSE TRT = 1 END IF Mark Next Level Solutions ___________________________________________________________ | | | SIMULATION 2 EXAMPLE | |_________________________________________________________________| This is an example of simulation with population data. It is a con- tinuation of Simulation Example 1. First, during the Simulation Step, values of the covariate WT are simulated, as well as DV values, as PK-defined items SIMWT. Normally-distributed values of ETA(3) are used. Values of CL are cal- culated based on SIMWT. SIMWT replaces WT in the table file, and, because the ONLYSIM option is used, tabled values of SIMWT are simu- lated values. Second, this process is repeated 10 times, using the same model, by means of the SUBPROBLEMS option. The table file contains the con- catenated output of all the subproblems, and is the simulated data for 20 individuals. $PROBLEM Simulation of population data and weight $INPUT ID TIME WT AMT DV $DATA SIMORIG IGNORE=# $SUBROUTINE ADVAN1 $PK SIMWT=70+70*ETA(3) CL=THETA(1)*SIMWT*EXP(ETA(1)) V=THETA(2)*EXP(ETA(2)) K=CL/V S1=V $ERROR Y=F+F*EPS(1) $THETA .0625 10 $OMEGA .09 .05 .04 $SIGMA .01 $SIMULATION (9215690) ONLYSIM SUBPROBLEMS=10 $TABLE ID TIME SIMWT AMT NOPRINT FILE=SIMDATA2 NOHEADER SIMORIG is the same as with Simulation Example 1. Contents of SIMORIG (for the first two individuals) follow. # ID TIME WT AMT DV 1 0 80 100 . 1 1 80 . . 2 0 75 100 . 2 2 75 . . Contents of SIMDATA2 follow, with floating-point notation converted to fixed-point for the convenience of the reader. 1. 0. 77.486 100. 0.000 10.000 0.000 0.000 1. 1. 77.486 0. 6.825 6.457 0.369 0.000 2. 0. 72.882 100. 0.000 10.000 0.000 0.000 2. 2. 72.882 0. 3.515 4.169 -0.653 0.000 REFERENCES: Guide IV, section III.B.13 (p. 31), IV.I (p. 53) REFERENCES: Guide V, section 12.4.8 (p. 137) REFERENCES: Guide VI, section III.C (p. 10), III.E (p. 17), IV.B (p. 45), IV.G.1 (p. 53) Random documentation ___________________________________________________________________ | | | RANDOM | |_________________________________________________________________| MEANING: RANDOM subroutine CONTEXT: NONMEM utility routine USAGE: INTEGER KR REAL R CALL RANDOM (KR,R) DISCUSSION: The NONMEM utility routine RANDOM may be called (by PRED, PK or ERROR) during the Simulation Step (ICALL=4) and when data averages are being computed (ICALL=5) to obtain numbers from different random sources. Input argument: KR An integer variable or integer constant. The index of a random source. Output argument: R A number from the KRth source. Always a single-precision number. Each time RANDOM is called, a new number is output. Random sources are defined using the $SIMULATION record. Typically, the first source is reserved by NONMEM to generate realizations of the eta and epsilon variables and/or to randomly mix individuals into dif- ferent subpopulations according to the mixing parameter. Thus, typi- cally, RANDOM must be called with KR > 1. However, there are cases when NONMEM itself needs no random sources, and all defined random sources can be used by PRED (see references). EXAMPLES OF USAGE: WT (an item in the data record, and a local variable with the same name) is generated with a simulated value having mean 70 and standard deviation 7. The second random source is assumed to be pseudo-normal, which is the default distribution for each random source. An abbreviated code may use RANDOM explicitly in either a simulation or a data average block. When RANDOM is called in abbreviated code, R is reserved and is used for the random number. E.g., IF (ICALL.EQ.4.AND.NEWIND.NE.2) THEN CALL RANDOM(2,R) ENDIF IF (ICALL.EQ.4) WT=70+7*R REFERENCES: Guide IV, section III.B.13 (p. 31), IV.I (p. 56) REFERENCES: Guide V, section 12.4.8 (p. 137) --- "Kristensen, Kim" <[EMAIL PROTECTED]> wrote: > Dear NONMEM User > > Having done a simple 2 compartment model containing > variability on CL and V2 explained by a continoues > covariate (BW) and a categorical covariate (DRUG) > variable like: > > TVCL = THETA(1)*BW+THETA(2) > IF (DRUG.EQ.0) TVV2=TVV2*THETA(3) > IF (DRUG.EQ.1) TVV2=TVV2*THETA(4) > > I then wish to do a simulation using ONLYSIM > SUBPROBLEMS=1000 > My question is how do I set up NONMEM to do a random > selection of the covariates during the simulation? > Say that I want to pick values of BW between 10 and > 100 by random and DRUG equal 0 or 1? > > Thanks in advance > Kim > > ________________________________ > Kim Kristensen, M.Sc(pharm),Ph.D. > Pharmacokineticist, Clinical Pharmacology > Medical Science Sweden > AstraZeneca R&D Lund > SE-221 87 Lund, Sweden > ________________________________ > > Mark Sale MD Next Level Solutions, LLC www.NextLevelSolns.com
Quoted reply history
> -------- Original Message -------- > Subject: [NMusers] Simulation with covariates > From: "Kristensen, Kim" <[EMAIL PROTECTED]> > Date: Thu, February 15, 2007 12:01 pm > To: <[email protected]> > > Dear NONMEM User > > Having done a simple 2 compartment model containing variability on CL and V2 > explained by a continoues covariate (BW) and a categorical covariate (DRUG) > variable like: > > TVCL = THETA(1)*BW+THETA(2) > IF (DRUG.EQ.0) TVV2=TVV2*THETA(3) > IF (DRUG.EQ.1) TVV2=TVV2*THETA(4) > > I then wish to do a simulation using ONLYSIM SUBPROBLEMS=1000 > My question is how do I set up NONMEM to do a random selection of the > covariates during the simulation? Say that I want to pick values of BW > between 10 and 100 by random and DRUG equal 0 or 1? > > Thanks in advance > Kim > > ________________________________ > Kim Kristensen, M.Sc(pharm),Ph.D. > Pharmacokineticist, Clinical Pharmacology > Medical Science Sweden > AstraZeneca R&D Lund > SE-221 87 Lund, Sweden > ________________________________
Feb 15, 2007 Kim Kristensen Simulation with covariates
Feb 15, 2007 Mark Sale RE: Simulation with covariates