Tutorials › Pharmacometric Workflows and Reproducible Modeling › Interpreting mrgsolve Simulation Outputs

Software Landscape and Interoperability · Tutorial 214 of 399

Interpreting mrgsolve Simulation Outputs

Learn a systematic way to inspect mrgsolve outputs, verify repeated-dose concentrations, and distinguish simulated quantities from model parameters.

Intermediate 10 min read

What You'll Learn

  • Identify common subject, time, state, derived-variable, and parameter columns in mrgsolve output.
  • Explain how dose events affect model states without treating event records as concentration observations.
  • Calculate concentrations after repeated bolus doses and compare them with simulated values.
  • Distinguish a state variable, a derived output, and a model parameter.
  • Diagnose ambiguous same-time records, unexpected values, and incomplete output tables.

Reading a Simulation Table as a Record of Model Behavior

An mrgsolve output table is not simply a list of concentrations. A row can identify a subject and time, report the model’s state at that time, include a calculated quantity, or carry information about an event. Some columns may instead report parameter values. These quantities answer different questions: a concentration describes the simulated system at a time, whereas a parameter helps define how the system evolves.

A reliable interpretation starts by asking what each column represents and how the output records were requested. In particular, a dose event can change a state without being an observation, and a reported parameter value is not itself a simulated concentration. The examples use a hypothetical one-compartment model with repeated intravenous bolus doses.

Definition: A simulation output record is a row reporting selected information for a subject at a simulation time, and, depending on the requested output, possibly associated with an event record. A state variable is a quantity integrated by the model’s differential equations, such as an amount in a compartment. A derived variable is calculated from states, parameters, covariates, or time, such as concentration calculated from amount divided by volume. A parameter is a value used to specify the model’s behavior; it is not automatically a time-varying outcome just because it appears in a table.

What the Columns Represent

The standard subject and time identifiers commonly appear as ID and time. State columns report the model’s state variables at the reported times; for example, CENT may represent the amount in a central compartment. A derived column such as CP might report plasma concentration calculated from that amount. Exact names depend on the model code, and the presence of a column depends on what was requested for output.

Event information has a different role. A dose record describes an input to the model: for example, dose amount, compartment, event identifier, or infusion information. These fields describe the dosing instruction, not the concentration response. Depending on the simulation settings and output request, event information may be carried into output, event records may appear as rows, or output may focus on requested observation times. Therefore, do not infer that every row is a measured observation or that every dose record must appear as a distinct output row.

A model parameter such as clearance or volume is also distinct from a state. A parameter may be used internally without being included in the output. If it is explicitly included, its value may be repeated across rows for a subject. Repetition does not turn it into an observed concentration. Conversely, a variable calculated from a state and a parameter can change over time even when the parameter is constant.

Column roleExampleInterpretation
Subject identifierIDIdentifies which simulated subject the record describes.
TimetimeSimulation time, interpreted using the model’s time units.
Event informationevid, amt, cmtDescribes a dosing or other input record when included.
StateCENTAmount in a compartment at the reported time.
Derived variableCPA calculation from states and model quantities, such as amount divided by volume.
ParameterCL, VA value specifying model behavior, included in output only if requested.

Repeated Bolus Doses: A Reference Calculation

Consider a one-compartment model with central amount \(A(t)\), concentration \(C(t)=A(t)/V\), clearance \(CL\), and volume \(V\). Between instantaneous intravenous bolus doses, assume linear elimination with rate constant \(k=CL/V\). A bolus of amount \(D_j\) at time \(t_j\) increases the amount by \(D_j\), so the state has a jump at that event. The derivation below assumes the system starts at \(t_0\) with amount \(A(t_0)\), and includes all subsequent bolus doses through time \(t\). Values at a dose time are interpreted immediately after the dose when the event-time output is post-dose.

$$ \frac{dA(t)}{dt}=-kA(t) \quad \text{between doses}, \qquad A(t_j^+)=A(t_j^-)+D_j. $$

Between events, the differential equation has solution \(A(t)=A(s)e^{-k(t-s)}\), where \(s\) is the start of that interval. Each dose therefore contributes its amount multiplied by the fraction remaining at the time of interest. The initial amount contributes in the same way; it must not be omitted unless it is assumed to be zero.

$$ A(t)=A(t_0)e^{-k(t-t_0)} +\sum_{j:t_0<t_j\le t}D_j e^{-k(t-t_j)}, \qquad C(t)=\frac{A(t)}{V}. $$

This expression follows by propagating the initial state from \(t_0\) to \(t\), and propagating each dose from its administration time \(t_j\) to \(t\). At a dose time, the term for that dose is \(D_j e^0=D_j\), so the expression gives the post-dose value. If the dose is instead recorded at the starting time \(t_0\), define \(A(t_0)\) as the amount just after that dose, or include the dose in the sum using a pre-dose initial amount. The convention must be stated to avoid counting a starting dose twice.

Worked Example: Calculating Concentrations After Repeated Doses

Suppose a hypothetical subject receives 100 mg intravenous boluses at 0, 12, and 24 hours. Let \(CL=5\) L/h and \(V=50\) L, so \(k=CL/V=5/50=0.1000\) h\(^{-1}\). Assume the amount before the first dose is zero, and report values at dose times immediately after each dose.

At 6 hours, only the dose at time 0 has been given. The amount and concentration are

$$ A(6)=100e^{-0.1000(6)}=54.88\ \text{mg}, \qquad C(6)=\frac{54.88\ \text{mg}}{50\ \text{L}}=1.098\ \text{mg/L}. $$

At 12 hours immediately after the second dose, the first dose has decayed for 12 hours and the new dose contributes 100 mg:

$$ A(12^+)=100e^{-0.1000(12)}+100 =30.12+100=130.12\ \text{mg}, \qquad C(12^+)=\frac{130.12}{50}=2.602\ \text{mg/L}. $$

At 24 hours immediately after the third dose, the earlier doses have decayed for 24 and 12 hours, respectively:

$$ A(24^+)=100e^{-2.4}+100e^{-1.2}+100 =9.072+30.12+100=139.19\ \text{mg}, \qquad C(24^+)=\frac{139.19}{50}=2.784\ \text{mg/L}. $$

These are reference values for checking a simulated state and derived concentration under the stated assumptions. They are not parameter estimates: \(CL\) and \(V\) are model inputs in this example, while \(A(t)\) and \(C(t)\) are simulated quantities that vary over time.

A Practical Inspection Sequence

Before interpreting a numerical result, establish the record structure and units. A short, explicit inspection prevents several common errors: treating a dose as an observation, mixing subjects, assuming an unreported variable is zero, or reading an amount as a concentration.

1
Identify the row keys.
Find the subject identifier and time column. Check their units, whether time is relative to a defined origin, and whether records are ordered by subject and time.
2
Separate event data from outputs.
Check the dosing input and any carried event fields. Confirm which rows correspond to requested output times and whether event-related rows are included.
3
Classify each scientific variable.
Use the model definition to determine which columns are states, which are derived quantities, and which are parameters or covariates. Do not infer this classification from a column name alone.
4
Verify units and calculations.
For concentration from amount, check that the amount and volume units yield concentration units. Compare selected rows with a hand calculation or a model-specific expected value.
5
Investigate unexpected rows.
Check for repeated times, missing output times, incorrect subject identifiers, and event records that may have been mistaken for observations. Revisit the output request and event input before changing the model.

Worked Example: Classifying a Hypothetical Output Table

Suppose a simulated output for one hypothetical subject contains columns ID, time, CENT, CP, and CL. At 6 hours, the row reports ID 1, time 6 h, CENT 54.88 mg, CP 1.098 mg/L, and CL 5 L/h. The model defines \(CP=CENT/V\) and uses \(V=50\) L.

ID and time. ID 1 identifies the simulated subject; time 6 h identifies the reported simulation time.

CENT. This is a state amount. The value 54.88 mg agrees with the one-dose calculation \(100e^{-0.1(6)}=54.88\) mg.

CP. This is derived from the state and volume: \(54.88\ \text{mg}/50\ \text{L}=1.098\ \text{mg/L}\). It is a simulated concentration, not a parameter.

CL. This is a model parameter included in the table. Its value of 5 L/h helps determine the elimination rate; it is not a concentration or a second state. If it repeats with the same value on every row, that is consistent with a constant clearance for this subject.

Same-Time Records and Event-Time Ambiguity

A table can contain more than one record at the same time for a subject. For instance, an observation time may coincide with a dose time, or event-related records may be included alongside requested output records. A repeated time is therefore a signal to inspect the record’s role, not proof that the dose was administered twice. Review the input event records and the settings governing output; do not count doses by counting rows.

At an instantaneous bolus time, pre-dose and post-dose states differ by the administered amount. A reported value at that time is interpretable only when its event-time convention is understood. Where the output representation does not make the convention clear, compare nearby times and the dose input, or request output that makes the event and observation records distinguishable. A small interval after the dose should reflect the post-dose state followed by elimination; it should not be interpreted as a second dose unless the event input specifies one.

Worked Example: Diagnosing Two Records at One Dose Time

A hypothetical output contains two rows for ID 1 at 12 h. One reports CP 0.6024 mg/L and another reports CP 2.602 mg/L. The input schedule contains one 100 mg bolus at 12 h, and the dose at 0 h was also 100 mg. The parameters are \(CL=5\) L/h and \(V=50\) L.

Immediately before the dose at 12 h, the first dose has remaining amount \(100e^{-1.2}=30.12\) mg, giving \(30.12/50=0.6024\) mg/L. Immediately after the 12 h bolus, the amount is \(30.12+100=130.12\) mg, giving \(130.12/50=2.602\) mg/L. Thus, the two concentrations are compatible with pre-dose and post-dose values for the same event time. The duplicate time alone does not establish which row is an observation or indicate duplicate dosing. The event input and output-record conventions must establish that interpretation.

Diagnostics, Alternatives, and Limitations

Useful checks should target the meaning of the output, not merely whether the table looks orderly. Confirm that times use the expected units; that IDs map to the intended subjects; that state units are amounts rather than concentrations; and that derived quantities follow their stated formulas. For a bolus model, verify that the state jumps by the dose amount at the event and then declines between doses under elimination. In the example, an amount in mg divided by a volume in L must give mg/L. A result with units of mg/h would indicate a different calculation or a unit mismatch.

When event rows or same-time records are hard to interpret, two practical approaches are to examine a deliberately simple simulation with a small number of doses and output times, or to inspect the dosing input separately from the simulation output. An observation-focused output can be convenient for plotting concentration-time profiles, while an event-inclusive or event-carrying output can help audit dosing. Neither layout is universally superior: the right choice depends on whether the task is to summarize predicted values or verify event handling. Preserve enough information to identify which kind of record each row represents.

A model-based calculation is a diagnostic reference, not a guarantee that every output will match a hand calculation. Differences can arise if the implemented model has additional compartments, nonlinear elimination, time-varying covariates, nonzero initial states, infusion durations, or other event types. The reference equation above assumes a single compartment, linear elimination, instantaneous boluses, fixed \(CL\) and \(V\), and a stated initial amount. Check those assumptions before treating a mismatch as a software error.

Common mistake: “The column named CP is a parameter because it appears in the model output, and the two rows at 12 h mean the dose happened twice.” Both conclusions confuse record presence with scientific meaning. Classify a column from the model definition: CP may be a derived concentration, while CL is a parameter. Classify repeated-time rows from the event input and output settings; row count is not dose count.

Simulation output is most useful when it can be traced back to the model and the input events. Retain the model definition, parameter values, dosing records, output request, and units alongside a saved table. A table on its own may not reveal whether a variable was captured, how an event-time value was defined, or whether the output includes only selected times. Interpreting those details explicitly makes plots, summaries, and cross-checks reproducible.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. A row reports CENT = 80 mg and V = 40 L. If concentration is defined as amount divided by volume, what is the derived concentration, and is V a state variable?
  2. In the one-compartment example, what is the post-dose concentration at 24 h after the 100 mg dose, to three significant figures?
  3. Two rows have the same ID and time. What information should you inspect before concluding that a dose was duplicated?
  4. For a model starting with a nonzero amount \(A(t_0)\), why is a formula that sums only later dose contributions incomplete?
  5. CL appears with the same value on every output row. Does that make CL a simulated concentration or state? Explain.

Solutions. (1) \(80\ \text{mg}/40\ \text{L}=2.00\ \text{mg/L}\). V is a parameter in this setup, not a state. (2) \(C(24^+)=[100e^{-2.4}+100e^{-1.2}+100]/50=2.78\ \text{mg/L}\). (3) Inspect the dose input, any event fields, the requested output times, and the convention for event-time records; duplicate times alone do not prove duplicate dosing. (4) The initial amount also persists and is eliminated, contributing \(A(t_0)e^{-k(t-t_0)}\), so omitting it gives an incorrect amount unless the initial amount is zero. (5) No. CL remains a model parameter; repeating its value in the output does not change its role into a state or concentration.

Clinical Biostats