## Usage

```
MM_opt(
poppar,
model,
data,
nsamp = 1,
weight = list(none = 1),
predInt = 0.5,
mmInt,
outeq = 1,
...
)
```

## Arguments

- poppar
An object of class

*PMfinal*(see makeFinal)- model
Name of a suitable model file template in the working directory. The default is "model.txt". This file will be converted to a fortran model file. If it is detected to already be a fortran file, then the simulation will proceed without any further file conversion.

- data
Either a PM_data object or character vector with the filename of a Pmetrics data file that contains template regimens and observation times. The value for outputs can be coded as any number(s) other than -99. The number(s) will be replaced in the simulator output with the simulated values.

- nsamp
The number of MM-optimal sample times to compute; default is 1, but can be any number. Values >4 will take an exponentially longer time.

- weight
List whose names indicate the type of weighting, and values indicate the relative weight. Values should sum to 1. Names can be any of the following:

`none`

The default. MMopt times will be chosen to maximally discriminate all responses at all times.`AUC`

MMopt times will be chosen to maximally discriminate AUC, regardless of the shape of the response profile.`max`

MMopt times will be chosen to maximally discriminate maximum, regardless of the shape of the response profile.`min`

MMopt times will be chosen to maximally discriminate minimum, regardless of the shape of the response profile.

Any combination of AUC, max, and min can be chosen. If "none" is specified, other weight types will be ignored and the relative value will be set to 1. For example,

`list(auc = 0.5,max = 0.5)`

or`list(auc = 0.2, min = 0.8)`

.- predInt
The interval in fractional hours for simulated predicted outputs at times other than those specified in the template

`data`

. The default is 0.5, which means there will be simulated outputs every 30 minutes from time 0 up to the maximal time in the template file. You may also specify`predInt`

as a vector of 3 values, e.g.`c(1,4,1)`

, similar to the R command seq, where the first value is the start time, the second is the stop time, and the third is the step value. Outputs for times specified in the template file will also be simulated. To simulate outputs*only*at the output times in the template data (i.e. EVID=0 events), use`predInt=0`

. Note that the maximum number of predictions total is 594, so the interval must be sufficiently large to accommodate this for a given number of output equations and total time to simulate over. If`predInt`

is set so that this cap is exceeded, predictions will be truncated.- mmInt
Specify the time intervals from which MMopt times can be selected. These should only include simulated times specified by

`predInt`

.- outeq
Output equation to optimize

- ...
Other parameters to pass to SIMrun, which are not usually necessary.

## Value

A object of class *MMopt* with 3 items.

- sampleTime
The MM-optimal sample times

- bayesRisk
The Bayesian risk of mis-classifying a subject based on the sample times. This is more useful for comparisons between sampling strategies, with minimization the goal.

- simdata
A

*PMsim*object with the simulated profiles- mmInt
A list with the

`mmInt`

values,`NULL`

if`mmInt`

is missing.

## Details

Based on the mulitple-model optimization algorithm. Bayard, David S., and Michael Neely. "Experiment Design for Nonparametric Models Based on Minimizing Bayes Risk: Application to Voriconazole." Journal of Pharmacokinetics and Pharmacodynamics 44, no. 2 (April 2017): 95–111. https://doi.org/10.1007/s10928-016-9498-5.