+--------------------------------------------------------------------+
 |                                                                    |
 |                       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.

      $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
         OPEN (50,FILE='BIAS') ; Give the output file a name
      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 (50,*) 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 TRUE=FINAL

      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 $TA-
      BLE 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).

 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.   .

 This data set cannot be run as-is. File dataA must include  more  sub-
 jects.   If  not,  the estimation step in problem 3 will not terminate
 correctly.  The final problem will produce the message:

 THE SIMULATION TASK REQUIRES THAT A BETTER FINAL ESTIMATE              |
  BE AVAILABLE IN THE MODEL SPECIFICATION FILE                          |
 OR                                                                     |
 MULTIPLE SUB_PROBLEMS IS INCOMPATIBLE WITH OTHER INFORMATION           |
  IN THE CONTROL STREAM AND INPUT MSF                                   |

 This error message is related to an earlier message                    |

 PARAMETER ESTIMATE IS NEAR ITS BOUNDARY                                |
 THIS MUST BE ADDRESSED BEFORE THE COVARIANCE STEP CAN BE IMPLEMENTED   |

 A larger version of dataA can be found in the  examples  directory  of
 the  NONMEM distribution medium.  The content of dataA above is repli-
 cated 28 times.  ID values 1 and 2 alternate so that there are 28 sub-
 jects.

 Contents of dataB follow:

       1   5.0    200.   .

 Comments on NONMEM 7 changes:                                          |

      In  this  example as distributed with earlier versions of NONMEM, |
      the WRITE statement specified unit 42:                            |
        WRITE (42,*) BIAS                                               |
      With NONMEM 7, this must be changed to                            |
        WRITE (50,*) BIAS                                               |
      This avoids a possible NONMEM error message                       |
         FORTRAN UNIT BEING OPENED OR CLOSED IN PROBLEM        1 IS OUTSIDE|
         ACCEPTABLE RANGE (50-2000)                                     |

      A new statement is added:                                         |
         OPEN (50,FILE='BIAS')                                          |
      This causes the output to be written to a file named BIAS  rather |
      than fort.50 or the like.

 REFERENCES: None.


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