Re: How to generate a random number with $EST

From: Luann Phillips Date: March 14, 2011 technical Source: mail-archive.com
Nieves, Two different thoughts using typical code. I'm not sure how you would provide a seed for the CALL RANDOM using verbatim code. (1) Generate the random numbers (one for all obs. or one for each time value) in another software and import them as part of the data (as Nick suggested). (2) If it is important that NONMEM generate the random numbers then you could try: a) Run your control stream once using SIMONLY to obtain the random numbers. Also have a line that saves the input DV to a new variable name (i.e. CP =DV). In the table file use the NOAPPEND option to prevent adding (DV,PRED,RES,WRES), output all the variables in the input datasets + the random number variable + CP. --------------- $PK CP=DV IF(ICALL.EQ.4)THEN CALL RANDOM (2,R) RN=1-R ENDIF .... $SIMULATION (1234123) (12343 UNIFORM) ONLYSIM $TABLE ID TIME DAY TSLD AMT RATE DUR DOSE N CP CVLQ CMT MDV EVID WTKG SAMP NUM RN FORMAT=sF8.4 NOAPPEND NOPRINT NOHEADER FILE=xxx.tbl ------------------- b) Use the table file from (a) as the input dataset. However, you will need to use CP as DV (since the original DV values were replaced in the simulation run). ------------------- $DATA trash-1.tbl $INPUT ID TIME DAY=DROP TSLD AMT RATE DUR DOSE N DV CVLQ CMT MDV EVID WTKG SAMP NUM RN $PK Normal model statements Use RN as your random number Note: TIME is now the time that NONMEM computes (elapsed time from first observation), so I dropped DAY. DV is really CP (the original DV). Also, note that you may want to specify the format (option in NM7) on the output table to maintain the precision of the numbers in your original input file. --------------------- Best regards, Luann Phillips Director, PK/PD Cognigen Corporation Nieves Vélez de Mendizabal wrote: > Dear NONMEM Users, > > I’m developing a model with NONMEM6|7. In this model, I need to generate a random number at every time step. The problem is that the use of the function “CALL RANDOM (2,R)” is supposed to be only for simulation, isn’t it? > > Thus, is it possible to generate a random number at every time step with NONMEM? Does anybody know how? > > This is part of the code that does not work (it’s not working because the condition ICALL.EQ.4 never happens and for that it’s not getting into the “if”, but on the other hand, in order to use the function RANDOM(2,R), such function requires ICALL.EQ.4): > > … > > $SUBS ADVAN6 TOL=5 > > $MODEL > > … > > $PK > > … > > IF (ICALL.EQ.4) THEN > > CALL RANDOM (2,R) ;Rand number in[0,1[ > > T=1-R > > … > > ENDIF > > $DES > > … > > $ERROR > > … > > $ESTIMATION MAXEVAL=0 NUMERICAL METHOD=COND LAPLACE LIKE CENTERING PRINT=2 MSFO=msfo3 > > Thank you! > > Nieves > > -- > -------------------------------- > Nieves Velez de Mendizabal, Ph.D > Departamento de Farmacia y Tecnología Farmacéutica > Facultad de Farmacia > Universidad de Navarra > Phone: (+34) 658 732 851 > Phone: (+34) 948 255 400 ext. 5827 > [email protected] > >
Mar 14, 2011 Nieves Vélez de Mendizabal How to generate a random number with $EST
Mar 14, 2011 Nick Holford Re: How to generate a random number with $EST
Mar 14, 2011 Matt Fidler RE: How to generate a random number with $EST
Mar 14, 2011 Matt Fidler RE: How to generate a random number with $EST
Mar 14, 2011 Luann Phillips Re: How to generate a random number with $EST
Mar 14, 2011 Jakob Ribbing RE: How to generate a random number with $EST
Mar 15, 2011 Nieves Vélez de Mendizabal Re: How to generate a random number with $EST