From: Jaya.Pisupati@quintiles.com  
Subject: [NMusers]info on a do-while-loop
Date: Tue, June 1, 2004 6:02 pm  

Can anyone provide me with info on what is a "do-while loop' and how can it
be added/coded in a control stream. An example would be great!
Thanks

Jaya Pisupati, PhD
Quintiles, Inc

_______________________________________________________

From: Nick Holford n.holford@auckland.ac.nz
Subject: RE:[NMusers]info on a do-while-loop
Date: Tue, June 1, 2004 7:06 pm  

Jaya,

Do-while loops can only be used with $SIMULATION and when ICALL.EQ.4. The only use I
have found for them is to resample from the ETA and EPS distributions to truncate
the distributions e.g. to ensure that all conc samples are non-negative. 

An example is shown below. The ETA sample distribution is truncated so that all
values lie within 99.9% of all possible values. The EPS sample distributions is
truncated so that all values are >= 0.

$PROB THEOPHYLLINE PHARMACODYNAMICS
$DATA theopd.dat IGNORE #
$INPUT ID TIME THEO AGE WT GEND RACE DIAG DV
$SIM (20000625 NORMAL NEW) SUBPROBLEMS=2

$ESTIM PRINT=0 MAXEVAL=9999

$THETA (0,150.,)  ; E0
$THETA (0,200.,)  ; EMAX
$THETA (.001,10,) ; EC50

$OMEGA 0.5  ; CVE0
$OMEGA 0.5  ; CVEMAX
$OMEGA 0.5  ; CVEC50

$SIGMA 100 ; SD 1 

$PRED

   E0=THETA(1)*EXP(ETA(1))
   EMAX=THETA(2)*EXP(ETA(2))
   EC50=THETA(3)*EXP(ETA(3))
   IF (ICALL.EQ.4) THEN ; simulation
       TRUNC=3.27 ; Z 2tailed alpha=0.01 i.e. include 99.9%
       TVE0=E0
       E0=TVE0*EXP(ETA(1))
       LNMU=LOG(TVE0)
       DLTA=TRUNC*0.717 ; MUST BE 3.27*SQRT(CVE0)!
       L0=EXP(LNMU-DLTA)
       H0=EXP(LNMU+DLTA)

       TVEMAX=EMAX
       EM=TVEMAX*EXP(ETA(2))
       LNMU=LOG(TVEMAX)
       DLTA=TRUNC*0.717 ; MUST BE 3.27*SQRT(CVEMAX)!
       LM=EXP(LNMU-DLTA)
       HM=EXP(LNMU+DLTA)

       TVEC50=EC50
       C5=TVEC50*EXP(ETA(3))
       LNMU=LOG(TVEC50)
       DLTA=TRUNC*0.717 ; MUST BE 3.27*SQRT(CVEC50)!
       L5=EXP(LNMU-DLTA)
       H5=EXP(LNMU+DLTA)

DOWHILE(E0.LT.L0.OR.E0.GT.H0.OR.EM.LT.LM.OR.EM.GT.HM.OR.C5.LT.L5.OR.C5.GT.H5)
          CALL SIMETA(ETA)
          EMAX=TVEMAX*EXP(ETA(2))
          E0=TVE0*EXP(ETA(1))
          EC50=TVEC50*EXP(ETA(3))
       ENDDO
   ENDIF

   EFFECT=E0 + EM*THEO/(THEO+C5)
   Y =  EFFECT + ERR(1)
   IF (ICALL.EQ.4) THEN ; simulation
      DOWHILE (Y.LT.0)
         CALL SIMEPS(EPS)
         Y=EFFECT + ERR(1)
      ENDDO
   ENDIF

$TABLE ID TIME THEO AGE WT GEND RACE DIAG
E0 EM C5 Y
NOPRINT ONEHEADER FILE=theopdsimtrunc.fit

--
Nick Holford, Dept Pharmacology & Clinical Pharmacology
University of Auckland, 85 Park Rd, Private Bag 92019, Auckland, New Zealand
email:n.holford@auckland.ac.nz tel:+64(9)373-7599x86730 fax:373-7556
http://www.health.auckland.ac.nz/pharmacology/staff/nholford/

_______________________________________________________

From: Adrian Dunne Adrian.Dunne@ucd.ie
Subject: RE:[NMusers]info on a do-while-loop
Date: Wed, June 2, 2004 5:23 am   

Jaya,
I use DOWHILE loops to simulate binomial data - for example if I want 
to simulate N Bernoulli trials each with probability of 'success' given by 
P and count the number of 'successes' the code would contain (DV is 
the simulated value);

DOWHILE(I.LE.N)
   CALL RANDOM(2,R) ; stream 2 contains uniform pseudo random 
numbers 
   IF(R.LE.P) DV=DV+1
   I=I+1
ENDDO

Adrian.-------------------------------------------
          Adrian Dunne                   
          Department of Statistics       
          University College Dublin      
          Belfield                       
          Dublin 4                       
          Ireland                        
          e-mail Adrian.Dunne@ucd.ie     
          Phone +353-1-7167151           
          FAX   +353-1-7161186            
       http://www.ucd.ie/~statdept/      
------------------------------------------

_______________________________________________________

From: Jaya.Pisupati@quintiles.com
Subject: RE:[NMusers]info on a do-while-loop
Date: Wed, June 2, 2004 9:37 am

Dr. Holford and Dr. Dunne.

Thanks. The examples were very informative.

Jaya Pisupati
_______________________________________________________