# 3 Input data sets

Input data sets are used in mrgsolve to allow the user to specify interventions and input data items.

Please see the mrgsolve help topic ?exdatasets for examples of all of the data sets discussed in this chapter. The example data sets are embedded in the mrgsolve package and may be used at any time.

## 3.1 Overview

Data sets are the primary mechanism for establishing the scope of your simulations in mrsolve, including individuals, interventions, observation times, and parameter values. For both data_set and idata_set (see below), you may include columns in the data sets that have the same names as the parameters in your model (section 1.1, 2.2.4). mrgsolve can recognize these columns and update the parameter list as the simulation proceeds. This process is of key importance when planning and executing complex simulations and is further discussed in section 11.3.

## 3.2 Event data sets (data)

Event data sets are entered as data.frame, with one event per row. Events may be observations, doses, or other type events. In mrgsolve documentation, we refer to these data sets as data or data_set (after the function that is used to associate the data set with the model object prior to simulation).

Event data sets have several special column names that mrgsolve is always aware of:

• ID the subject id. This id does not need to be unique in the data_set: mrgsolve detects an new individual when the current value of ID is different from the immediate preceding value of ID. However, we always recommend using unique ID.

• time or TIME: states the time of the data record

• evid or EVID: the event id indicator. evid can take the values:

• 0 = observation record
• 1 = dosing event (bolus or infusion)
• 2 = other type event, with solver stop and restart
• 3 = system reset
• 4 = reset and dose
• 8 = replace the amount in the compartment with amt
• amt or AMT: the dose amount (if evid==1)

• cmt or CMT: the dosing compartment number. This may also be a character value naming the compartment name. The compartment number must be consistent with the number of compartments in the model for dosing records (evid==1).
For observation records, a cmt value of 0 is acceptable. Use a negative compartment number with evid 2 to turn a compartment off.

.   ..$: chr [1:9] "ID" "WT" "Dose" "time" ... This can improve efficiency when performing a very large number of replicate simulations on the same data set, but is unlikely to provide a meaningful speed-up for a single simulation or a small number of simulations. ## 3.6 Data sets for use with $PRED

Because there are no compartments involved, there are relaxed data set requirements for models that utilize \$PRED.

• time or TIME is not required as input; when this is not supplied, a time column will be included in output with value 0
• When time or TIME is supplied, it may be negative; but records must still be sorted by time or TIME
• If supplied, cmt or CMT must be zero
• An error is generated if rate or RATE is supplied
• An error is generated if ss or SS is supplied