___________________________________________________________________
 |                                                                 |
 |                        SUPERPROBLEM 1 EXAMPLE                   |
 |_________________________________________________________________|

 There are four problems:

 Problem 1: The (true) probability that with an  individual  chosen  at
 random,  after a 200 mg dose, the true concentration at 5 hrs is above
 5, is computed using simulation.
 Problem 2: A population data set is simulated.
 Problem 3: Parameter estimates are obtained.
 Problem 4: The probability in question is estimated, using  simulation
 and the parameter estimates obtained in problem 3.

 Problems 2-4 comprise a  superproblem.   The  bias  in  the  estimator
 defined by problem 4 is estimated by iterating this superproblem.

 There are two ways to write a control stream with  multiple  problems.
 The first results in generated code, and is harder to construct and to
 understand.  The second, simpler and more natural way,  uses  the  NM-
 TRAN  Library.   With  the NM-TRAN library, it is possible to use dif-
 ferent abbreviated codes in each problem.

 Using generated code

      $PROB    COMPUTE PERCENTAGE OF POP. WITH CP>5 AT DOSE=200, TIME=5
      $INPUT ID TIME DOSE DV
      $DATA dataB
      $PRED
      IF (ICALL.EQ.0) THEN
         BIAS=0           ; initialize
         TRUE=0
      ENDIF
      IF (ICALL.EQ.1) THEN
         IF (IPROB.EQ.1.OR.IPROB.EQ.4) N=0   ; see rocm14
         CALL SUPP (1,1)
      ENDIF
            KA=THETA(1)*EXP(ETA(1))
            KE=THETA(2)*EXP(ETA(2))
            V=THETA(3)*EXP(ETA(3))
            A=EXP(-KE*TIME)
            B=EXP(-KA*TIME)
            C=KA-KE
            D=A-B
            E=KA*DOSE/(V*C)
            F=E*D
            Y=F+ERR(1)
      IF (ICALL.EQ.4) THEN
         IF (IPROB.EQ.1.OR.IPROB.EQ.4) THEN
            IF (F.GT.5) N=N+1
            IF (IREP.EQ.NREP) THEN           ; see rocm10
               PER=100.*N/NREP
               IF (IPROB.EQ.1) TRUE=PER
               IF (IPROB.EQ.4) THEN
                  BIAS=BIAS+(PER-TRUE)/TRUE
                  IF (S1IT.EQ.S1NIT) THEN
                     BIAS=BIAS/S1NIT
                     WRITE (42,*) BIAS
                  ENDIF
               ENDIF
            ENDIF
         ENDIF
      ENDIF
      $THTA (.4,1.7,7) (.025,.102,.4) (10,29,80)
      $OMEGA .04 .04 .04
      $SIGMA 1.5
      $SIM (5566898) ONLY SUB=1000
      ;
      $SUPER  SCOPE=3  ITERATIONS=10
      $PROB    SIMULATION
      $INPUT ID TIME DOSE DV
      $DATA dataA
      $THTA (.4,1.7,7) (.025,.102,.4) (10,29,80)
      $OMEGA .04 .04 .04
      $SIGMA 1.5
      $SIM (-1) ONLY
      $TABLE ID TIME DOSE DV FILE=simulation NOHEADER NOPRINT NOFORWARD
      ;
      $PROB    ESTIMATION
      $INPUT ID TIME DOSE DV
      $DATA simulation (4E12.0) NRECS=500 NOOPEN
      $THTA (.4,1.7,7) (.025,.102,.4) (10,29,80)
      $OMEGA .04 .04 .04
      $SIGMA 1.5
      $EST PRINT=0 MSFO=msf
      ;
      $PROB    ESTIMATE PERCENTAGE OF POP. WITH CP>5 AT DOSE=200, TIME=5
      $INPUT ID TIME DOSE DV
      $DATA dataB
      $MSFI msf
      $SIM (-1) ONLY SUB=100

      Comments:

      (1) Variables whose values are to  be  retained  across  problems
      (e.g.  BIAS and TRUE) should be defined in initialization blocks.
      In this instance these variables are defined at  ICALL=0,  before
      any of the problems are implemented

      (2) IREP and NREP are the number of the current  replication  and
      number of requested replications for the Simulation Step, respec-
      tively.

      (3) S1IT and S1NIT are the number of the  current  iteration  and
      number  of  requested  iterations for the (level 1) superproblem,
      respectively.

      (4) Problems 2 & 3 can, of course, be combined, making  the  con-
      trol  stream  much simpler.  But separation can sometimes be use-
      ful, and here we illustrate how this can be done.

      (5) The data set of problem 3 can be taken  to  be  the  internal
      data  set  created  with  problem  2  simply by removing both the
      $TABLE record of problem 2 and the $DATA  record  of  problem  3.
      But  these records are included here to illustrate the ability to
      use a table file as a data file in a subsequent  problem  of  the
      same  run.  When  so doing, all the items in the $INPUT record of
      the subsequent problem should be included in the $INPUT record of
      the problem with the $TABLE record.  (If a PRED-item in the table
      is to be used in the subsequent  problem  as  a  data  item,  the
      PRED-item  name  can  be different from the data item name.)  The
      FORMAT and NOOPEN options should be included in the $DATA  record
      of  the  subsequent problem.  The NRECS option is not needed, but
      if it is also included, it should be set to the number of records
      in  the  table  file, i.e.  to the number of data records in data
      set A (assumed here to be 500).

 Using the NM-TRAN Library

      $PROB    COMPUTE PERCENTAGE OF POP. WITH CP>5 AT DOSE=200, TIME=5
      $INPUT ID TIME DOSE DV
      $SUBROUTINES  LIBRARY
      $DATA dataB
      $PRED
      IF (ICALL.EQ.1) THEN
         TRUE=0
         N=0
         CALL SUPP (1,1)
      ENDIF
            KA=THETA(1)*EXP(ETA(1))
            KE=THETA(2)*EXP(ETA(2))
            V=THETA(3)*EXP(ETA(3))
            A=EXP(-KE*TIME)
            B=EXP(-KA*TIME)
            C=KA-KE
            D=A-B
            E=KA*DOSE/(V*C)
            F=E*D
            Y=F+ERR(1)
      IF (ICALL.EQ.4) THEN
            IF (F.GT.5) N=N+1
            IF (IREP.EQ.NREP) THEN
               PER=100.*N/NREP
               TRUE=PER
            ENDIF
      ENDIF
      $THTA (.4,1.7,7) (.025,.102,.4) (10,29,80)
      $OMEGA .04 .04 .04
      $SIGMA 1.5
      $SIM (5566898) ONLY SUB=1000
      ;
      $SUPER  SCOPE=3  ITERATIONS=10
      $PROB    SIMULATION
      $INPUT ID TIME DOSE DV
      $DATA dataA
      $PRED
      IF (ICALL.EQ.1.AND.S1IT.EQ.1) BIAS=0
      IF (ICALL.EQ.1) CALL SUPP (1,1)
      KA=THETA(1)*EXP(ETA(1))
      KE=THETA(2)*EXP(ETA(2))
      V=THETA(3)*EXP(ETA(3))
      A=EXP(-KE*TIME)
      B=EXP(-KA*TIME)
      C=KA-KE
      D=A-B
      E=KA*DOSE/(V*C)
      F=E*D
      Y=F+ERR(1)
      $THTA (.4,1.7,7) (.025,.102,.4) (10,29,80)
      $OMEGA .04 .04 .04
      $SIGMA 1.5
      $SIM (-1) ONLY
      $TABLE ID TIME DOSE DV FILE=simulation NOHEADER NOPRINT NOFORWARD
      ;
      $PROB    ESTIMATION
      $INPUT ID TIME DOSE DV
      $DATA simulation (4E12.0) NRECS=500 NOOPEN
      $THTA (.4,1.7,7) (.025,.102,.4) (10,29,80)
      $OMEGA .04 .04 .04
      $SIGMA 1.5
      $EST PRINT=0 MSFO=msf
      ;
      $PROB    ESTIMATE PERCENTAGE OF POP. WITH CP>5 AT DOSE=200, TIME=5
      $INPUT ID TIME DOSE DV
      $DATA dataB
      $PRED
      IF (ICALL.EQ.1) THEN
         N=0
         CALL SUPP (1,1)
      ENDIF
            KA=THETA(1)*EXP(ETA(1))
            KE=THETA(2)*EXP(ETA(2))
            V=THETA(3)*EXP(ETA(3))
            A=EXP(-KE*TIME)
            B=EXP(-KA*TIME)
            C=KA-KE
            D=A-B
            E=KA*DOSE/(V*C)
            F=E*D
            Y=F+ERR(1)
      IF (ICALL.EQ.4) THEN
            IF (F.GT.5) N=N+1
            IF (IREP.EQ.NREP) THEN
               PER=100.*N/NREP
               BIAS=BIAS+(PER-TRUE)/TRUE
               IF (S1IT.EQ.S1NIT) THEN
                  BIAS=BIAS/S1NIT
                  WRITE (42,*) BIAS
               ENDIF
            ENDIF
      ENDIF
      $MSFI msf
      $SIM (-1) ONLY SUB=100

      Comment:

      (1)  With a NM-TRAN Library routine, ICALL=0 is  not  recognized.
      The only initialization opportunities are at ICALL=1, initializa-
      tion before a problem.

 Contents of dataA (for individual 1 only) follow:

       1    .27   320.   .
       1    .52   320.   .
       1   1.     320.   .
       1   1.92   320.   .
       1   3.5    320.   .
       1   5.02   320.   .
       1   7.03   320.   .
       1   9.     320.   .
       1  12.     320.   .
       1  24.3    320.   .

 Contents of dataB follow:

       1   5.0    200.   .

 REFERENCES: None.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     


  
Go to main index.
  
Created by nmhelp2html v. 1.0 written by Niclas Jonsson (Modified by AJB 5/2006,11/2007)