$SIMULATION

Instructions for the NONMEM Simulation Step.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 $SIMULATION  (seed1 [seed2] [NORMAL|UNIFORM|NONPARAMETRIC] [NEW]) ...
              [CLOCKSEED=[0|1]]
              [SOURCE_EPS=n]
              [SUBPROBLEMS=n] [ONLYSIMULATION] [OMITTED]
              [REQUESTFIRST] [REQUESTSECOND] [PREDICTION|NOPREDICTION]
              [TRUE=INITIAL|FINAL|PRIOR] [TTDF=n]
              [BOOTSTRAP=n [REPLACE|NOREPLACE] [STRAT=label] [STRATF=label]]
              [NOREWIND|REWIND] [SUPRESET|NOSUPRESET]
              [RANMETHOD=[n|S|m|P] ]
              [PARAFILE=[filename|ON|OFF]

;# EXAMPLE
 $SIMULATION  (889215690) (2239177789 UNIFORM)

Discussion

Optional. Requests that the NONMEM Simulation Step be implemented. May also be coded $SIMULATE or $SIML. The simulation (see NOPREDICTION option for an exception) generates the Y variable (with NMTRAN abbreviated code) or the F variable (with a user-supplied PRED or ERROR routine) using the initial parameter estimates specified in $THETA, $OMEGA, $SIGMA. Thus initial estimates must be given for all parameters.

The interpretation of ETAs depends on the control records and options provided:

  • if the $ESTIM (or $SIMUL) and $SIMUL [LIKELIHOOD | -2LOGLIKELIHOOD] option are used, ETAs are for population data;
  • if the $ESTIM (or $SIMUL) is used, $SIMUL [LIKELIHOOD | -2LOGLIKELIHOOD] option is not used but EPS is used, ETAs are for population data;
  • if the $ESTIM (or $SIMUL) is used, neither [LIKELIHOOD | -2LOGLIKELIHOOD] option or EPS is used, ETAs are for single-subject data;
  • With option NOPREDICTION (see below)

In addition to this control record, a "simulation block" (executed when ICALL=4) can be used in $PK, $ERROR, and $PRED for simulation.

Internally the simulation of ETA and EPS are performed by SIMETA and SIMEPS routines, respectively.

Options

Each parenthese defines an instance of pseudo random number generator (pRNG). The pRNGs are ordered as defined on the $SIMUL record. User can use NONMEM utility routine RANDOM to access the pRNG. By default, the first pRNG is for the simulating ETA and EPS and not available to the user. This can be changed with the SOURCE_EPS option below.

seed1, seed2

Seed1 is the first seed for the random source, an integer between 0 and 2147483647. If this is not the first problem specification in the control stream, then seed1 can be -1, indicating that the random source is to be continued from the previous problem.

Seed2 is the second seed for the random source, an integer between 0 and 2147483647. It is used when it is desired that the current problem make use of a continuation of a random source defined in a preceding NONMEM run. It is seldom used.

NORMAL | UNIFORM | NONPARAMETRIC

Specifies distribution used by the pseudo-random number generator (pRNG) of the source. NORMAL (default) indicates normal distribution with mean 0 and variance 1 (unless the source is "1" that is used to generate ETA and EPSILON, in which case the variance-covariance of these variables is that specified in the $OMEGA and $SIGMA records). UNIFORM indicates uniform distribution on [0,1].

NONPARAMETRIC indicates that the first source defined with the NONPARAMETRIC attribute are used to generate realizations of random vectors from a (multivariate) nonparametric distribution on ETA, obtained from the Nonparametric Step of an earlier problem. An input MSF must also be present. It is understood that the ETAs are to be simulated from the nonparametric distribution rather than from the pseudo-normal distribution associated with the first source. The NONPARAMETRIC attribute can only be used in the definition of the second or subsequent source.

NEW

The NEW option requests a new call to pRNG (through routine SIMETA and SIMEPS) to genereate ETA/EPS, rather than only at the start of each individual record/level-two record. That is, with NEW, a call to SIMETA/SIMEPS will obtain new ETA/EPS, even if ID/L2 has not changed The output NONMEM report describes this as

1
DIFFERENT ETA AND EPS WITH EACH CALL TO SIMETA AND SIMEPS

CLOCKSEED=[0|1] (NM75)

If CLOCKSEED=1 (default is 0), actual starting seed will be 10000*(seconds after midnight)+SEED (applies to both seed1 and seed2, if specified.) This allows a control stream to produce different stochastic results for automated replications, without the need to modify the seed value in the control stream file in each replication.

SOURCE_EPS=n (NM75)

May be used to specify that the simulation of EPSILONs should use a different source than the default, which is the first. n is the number of the source for EPSILONs. This source must have the NORMAL attribute.

ONLYSIMULATION

By default, when the Simulation Step is implemented, various statistics used for data analysis are always computed from the simulated data. These are the value of the objective function at the initial parameter estimates and if a table is requested, the weighted residuals based on these estimates. The data may be simulated in a way that gives rise to a problem with computing these statistics. For example, perhaps the simulation model is not appropriate for data analysis using the NONMEM default objective function. Option ONLYSIMULATION requests simulation but to evaluate an objective function on these data. WRES values in tables and scatterplots will be 0. PRED-defined data items in tables and scatterplots will be computed using simulated ETAs and initial THETAs.

$ESTIM, $COV and $NONP cannot be used with ONLYSIMULATION. See also the PREDICTION and NOPREDICTION options.

SUBPROBLEMS=n

Requests that the entire NONMEM problem is to be repeated n times in succession (including all NONMEM steps: simulation, estimation, covariance, table, scatterplot). Each subproblem includes the Simulation Step, but the random sources are simply continued from subproblem to subproblem. If n=0 or n=1, there is only one subproblem; this is the default. May also be coded SUBPROBS, NSUBPROBLEMS, NSUBPROBS. With all versions of NONMEM, the data set for each subproblem after the first is the same data set used by the previous subproblem, and includes any changes (transgeneration) made by the previous subproblem.

With NONMEM 7.4 and higher, see REWIND, below.

With NONMEM 7.3 and higher, the maximum number of subproblems is increased from 9999 to 2147483647.

REQUESTFIRST

NONMEM sets a variable IFIRSTEM in Module ROCM_INT (referenced as FIRSTEM in abbreviated code) informing PRED whether or not PRED needs to compute first-partial derivatives with respect to eta. Normally, during the Simulation Step, these derivatives are not needed, either by NONMEM or by the user. However, the user may want the first-partial eta derivatives of a PRED-defined item and may want FIRSTEM to reflect this. With the REQUESTFIRST option, the FIRSTEM variable is set so to inform PRED that the derivatives need to be computed. In this case, if an abbreviated code is used to compute the PRED-defined item, the item should not be computed within a simulation block, because NM-TRAN does not provide derivatives for PRED-defined items in a simulation block.

REQUESTSECOND

NONMEM sets a variable ISECDER in Module ROCM_INT (referenced as MSEC in abbreviated code) informing PRED whether or not PRED needs to compute second-partial derivatives with respect to eta. Normally, during the Simulation Step, these derivatives are not needed, either by NONMEM or by the user. However, the user may want the second-partial eta derivatives of a PRED-defined item and may want the MSEC variable to reflect this. With the REQUESTSECOND option, the MSEC variable is set so to inform PRED that the derivatives need to be computed. In this case, if an abbreviated code is used to compute the PRED-defined item, the item should not be computed within a simulation block, because NM-TRAN does not provide derivatives for PRED-defined items in a simulation block. REQUESTSECOND implies REQUESTFIRST.

PREDICTION | NOPREDICTION

PREDICTION: default, used only with ONLYSIM. The simulated observation is taken to be the quantity to which the Y variable (with NM-TRAN abbreviated code) or F variable (with a user-supplied PRED or ERROR routine) is set. In a simulation block, the DV variable may be directly set to the simulated observation, but the Y (or

  1. variable should also be set to this observation. That is
1
2
3
  $SIMULATION
  DV=...
  Y=DV

NOPREDICTION: permitted only with ONLYSIM. Indicates that the simulated observation will be taken to be the value to which the DV variable is set. When Y=... is used in a simulation block, one should use it to assign DV: DV=Y. ETAs are understood to be population ETAs, even if EPSILONs do not appear.

TRUE

  • TRUE=INITIAL: the initial estimates given in the control stream are used as the parameter values ("true values") in the simulation, except when a model specification file is input. When a model specification file is input, the initial estimates with the previous run are used as the parameter values ("true values") in the simulation, and the final estimates with the previous run are used as the initial estimates in all tasks other than the simulation. The UCP used with these other tasks are the same as with the previous run. This is the default. May not be used with $MSFI in conjunction with SUBPROBLEMS=n (n > 1).
  • TRUE=FINAL: An input model specification file must be used. The final estimates with the previous run are used as the parameter values ("true values") in the simulation and as the initial estimates in all tasks other than the simulation. The UCP used with these other tasks are new, so that a UCP value of 0.1 now corresponds to a final estimate from the previous run.
  • TRUE=PRIOR: The values stored in THET_P, OMEG_P, SIGM_P by the PRIOR routine are used as the true parameter values ("true values") in the simulation.

TTDF=n (NM75)

With TTDF set to a non-zero integer, THETAs can be simulated from the t-distribution with TTDF degrees of freedom, when setting also TRUE=PRIOR. For example:

1
2
$SIMULATION (567811 NORMAL) (2933012 UNIFORM) SUBPROBLEMS=10 ONLYSIM
TTDF=4 TRUE=PRIOR

This also requires set up priors, such as:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
$PRIOR NWPRI PLEV=0.999
$THETAP  (1.68 FIXED)  (1.58 FIXED) (8.12E-01 FIXED) ( 2.37 FIXED)
$THETAPV BLOCK(4)
0.04 FIX
0.00 0.4
0.00  0.00 0.4
0.00  0.00 0.0 0.4
$OMEGAP BLOCK(4)
 1.65276E-01  FIXED
 4.62368E-03  1.33770E-01
 6.35274E-03  1.69155E-02  2.13881E-01
 -1.53098E-02  1.25855E-02  5.32524E-02  1.62771E-01
$OMEGAPD (50 FIX)
$SIGMAP BLOCK(1) 0.0544 FIXED
$SIGMAPD (300 FIXED)

See $TTDF for specifying degrees of freedom for each THETA. $SIML TTDF over-rides the $TTDF settings.

BOOTSTRAP=n

With the BOOTSTRAP option, NONMEM does not perform the usual simulation activity of randomly creating DV values for a new data set, but rather selects a random set of subjects from an existing "template" data set (which must already have legitimate DV values). The BOOTSTRAP number n refers to how many subjects are to be randomly selected from the data set. Setting -1 means to randomly select as many subjects as in the data set.

1
$SIML BOOTSTRAP=-1 SUBP=100

For example, if 400 subjects are in the simulation template data set, then 400 subjects are randomly selected. The random source is, in effect, uniform, because any subject is equally probable. If n is greater than the number of subjects, NONMEM will use the number of subjects.

BOOTSTRAP can also be applied to single-subject data, in obtaining summary statistics. For example ("examples/control3boot"):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$PROBLEM  THEOPHYLLINE   SINGLE SUBJECT DATA
$INPUT  DOSE=AMT TIME CP=DV CAT
$DATA  DATA3B
$SUBROUTINES  ADVAN2

$PK
CALLFL=1
KA=THETA(1)
K=THETA(2)
SC=THETA(3)

$ERROR
IPRED=F
W=1.0
; first observation after dose is part of "first subject".  So, put in dummy record, CAT=3,
; and give it a residual variance that is very large, so it does not influence the fit.
IF(CAT==3.0) W=1.0E+10
Y=F+W*ERR(1)

$THETA  (0,1.7)  (0,.102)  (0,29)
$OMEGA 0.2

$SIML (567666 NORMAL) (33012 UNIFORM) BOOTSTRAP=-1 STRAT=CAT SUBP=100

$ESTIMATION MAXEVAL=9999  PRINT=2
$COVR
$TABLE TIME CAT AMT CP IPRED W NOAPPEND NOPRINT file=control3boot.tab

The data file is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    320    .0     .    1
     .     .1    3.0   3
     .     .27   1.71  2
     .     .52   7.91  2
     .    1.     8.31  2
     .    1.92   8.33  2
     .    3.5    6.85  2
     .    5.02   6.08  2
     .    7.03   5.4   2
     .    9.     4.55  2
     .   12.     3.01  2
     .   24.3     .90  2

The CAT data item identifies category number, used in stratification (see STRAT option), so that each record will be presented in every random dataset. The single dose record has CAT=1 ,and the observation events have CAT=2. Every bootstrap sample will contrain records with each CAT value. NONMEM assumes the dose record and the first data record after it belong to “one individual”, therefore this first record (time=0.1) will always be sampled with the dose record. To ensure that this dummy record does not contribute to the estimate, it is given a large residual deviation W=1.0E+10, equivalent to very little weight in the model estimate.

REPLACE | NOREPLACE

REPLACE: subjects are selected with replacement. This results in some subjects not being selected at all, and some subjects selected more than once. This is the default.

NOREPLACE: Subjects are selected without replacement, that is, without repeating a subject. The NOREPLACE feature is reasonable if there are many more than n subjects to choose from in the template dataset (for example, 1000 subjects in the template, and for each sub-problem, 50 of them are randomly chosen without replacement, that is, without repeating a subject).

STRAT

A single stratification data item may be entered. In the above bootstraping single-subject example, the data item CAT serves as the stratification. This splits the data set into distinct sub-sets, guaranteeing a specific number of subjects will be selected from each category. For example, if in the base data set CAT has values of 1 or 2, with 33 subjects in group 1 and 67 subjects in group 2 out of 100 total subjects, then exactly 33% of of subjects from group 1 will be randomly selected out of 50 total (16), and exactly 67% of subjects will be randomly selected from group 2 (34). This has value when desiring that a bootstrap analysis maintain the same proportion of subjects belonging to certain categories, such as gender, or age bracket. To stratify by both age bracket and gender, create a stratification data item that would be, for example, valued 1 for subjects who are male under 30, 2 for subjects that are female under 30, 3 for subjects who are male over 30, 4 for subjects who are female over 30. Any discrete numerical values will do, as long as the stratifier is not a continuous variable, and the subjects need not be sorted according to the stratification data item.

STRATF

The option STRATF points to a data item that contains the fraction that should represent a category in the bootstrapped data set. Without STRATF, the number of subjects to be taken from a given category is proportional to the number of subjects in the base data set. If you want the category to be represented at a different proportion, then specify a STRATF data item, in this example, FCAT. Suppose FCAT=0.5 for CAT=1 and 0.5 for CAT=2 as well. Even though only 33% of subjects in the base data set belong to category 1, exactly 50% of subjects from group 1 will be randomly selected out of 50 total (25), and exactly 50% of subjects will be randomly selected from group 2 (25) in the formation of each bootstrap data set. This allows you to alter the proportions in each category from what is in the original data set.

NOREWIND|REWIND

The NOREWIND option requests that if any input data item(s) are changed (transgenerated) during a the simulation step of a subproblem, they remain changed at the start of the next sub-problem. This is the default. With NONMEM 7.4, the REWIND option requests that the original data set be used for all sub-problems. If the data set is not changed during simulation, the NOREWIND and REWIND options give the same results.

Keep in mind that transgeneration performed on the data set using $INFN with ICALL=1 affects the original data set and these changes are unaffected by REWIND and NOREWIND options. For example:

1
2
3
4
5
6
$INFN
IF (ICALL==1) THEN
DOWHILE(DATA)
 ... data transgeneration statements here
ENDDO
ENDIF

SUPRESET|NOSUPRESET

This option affects seeds for random sources when a $SIMULATION record is included in the scope of a $SUPER problem. The SUPRESET option requests that, with subsequent iterations of a superproblem, the seed(s) for all random sources are reset back to that listed in the $SIMULATION record of the control stream file. This is the default. With NONMEM 7.4, the NOSUPRESET option may be used to prevent resetting the random seeds, so that each iteration serves as a new random instance.

RANMETHOD=[n|S|m|P]

As of NM73, the RANMETHOD option is available for the $SIM record, to use alternative random numbers generators (default is NONMEM’s traditional one, number 4):

Option n is the random number generator type, S is Sobol sequence, and m is the Sobol scrambler. See the description of RANMETHOD under I.39 Monte Carlo Importance Sampling EM.

As of NM74, RANMETHOD will also act on the P modifier, which will retain separate random number sequences for each subject, so that the random variable patterns are retained regardless of whether the simulation is done in single computing or parallel computing mode. So, when parallel computing, you may select

1
$SIM PARAFILE=ON RANMETHOD=P

Before NM74, a P descriptor could be given without an error message, but it was ignored because the parallel random number generation for each individual was not yet developed for $SIM.

NONMEM’s default random number generator for the $SIM step is 4 (in contrast, default random number generator for $EST and $TABLE is 3). Number 4 is NONMEM’s classic random number generator. Whatever random number source is selected, it affects all seed1 sources, and all source seed2 if not also selecting P. The P descriptor sets initial seed2 to 0 when creating starting seeds for each individual.

The Sobol method is used only to generate normally distributed random vectors of ETAs and EPSILONs, when the S descriptor is selected, and SEED1 of source 1 is used to set the seed. Among the Sobol sequence methods, the S2 method appears to provide the least biased random samples, that is nearly uniform distribution, with good mixing in multi-dimensional spaces.

(See also $ESTIMATION).

PARAFILE=filename

As of NONMEM 7.4, the Simulation Step computation may be parallelized. by default. By default, parallelization is not turned on, because simulation is very rapid anyway, and often does not need to be accelerated. When modeling with super-ID nested ETA levels ($LEVEL record is present), parallelization will not occur, since these ETAs are shared across individuals, and there is no guarantee that all subjects sharing the same ETAs will be simulated by the same process. PARAFILE=filename specifies a different parafile than was used for the previous step. PARAFILE=ON turns on parallelization for the Simulation Step. Set RANMETHOD=P to permit assure consistient seed patterns regardless of whether or not parallelization is performed, e.g.,

1
$SIML ... PARAFILE=ON RANMETHOD=P

The default PARAFILE=OFF turns off parallelization for the Simulation Step.

OMITTED

The Simulation Step is not implemented.