Tutorials › Population Pharmacokinetics › Encode Dose Events in Longitudinal Records

Dataset Construction and Quality Control · Tutorial 21 of 599

Encode Dose Events in Longitudinal Records

Learn to encode dose, observation, and other event records consistently so that a pharmacokinetic analysis can reconstruct each subject’s study timeline.

Intermediate 10 min read

What You'll Learn

  • Distinguish an event’s type from the values recorded on its row.
  • Use event codes and fields to represent dose and sample records consistently.
  • Interpret common EVID conventions and understand the separate role of MDV.
  • Reconstruct a subject’s event sequence from longitudinal records.
  • Identify coding errors that can alter the analysis timeline.
  • Apply basic checks to event records before modeling.

Why Event Coding Matters

A longitudinal pharmacokinetic data set is more than a list of concentrations. It also needs to tell the analysis when a dose was administered, when a sample was collected, and what other relevant changes occurred. Each record contributes to a subject’s timeline. If a dose is mistakenly represented as a sample, or a sample is coded as a dose, the analysis may process a different sequence of events from the one that occurred.

The earlier material on linking subjects, samples, doses, and occasions establishes why those records must be connected to the correct subject and study period. Here the focus is how each record declares its event type and carries fields appropriate to that type. The examples use elapsed time in hours from a defined study origin; they do not address how timestamps are converted to elapsed time or how records at the same time are ordered.

Definition: An event record is one row representing a specified event for a subject at a specified time. An event type identifies what the row represents, such as a dose administration, a pharmacokinetic observation, or another model-relevant event. An event field stores a value associated with that event, such as dose amount or observed concentration. The event type and the row’s field values together determine how the record is interpreted.

A common analysis-ready layout uses one row per event and includes fields such as subject identifier, time, event code, dose amount, compartment, observed value, and a missing-dependent-variable indicator. The exact field names and code meanings depend on the software and the data specification. They must be documented and applied consistently; a number in an event-code column has no universal meaning unless the analysis conventions define it.

Event Types and Record Fields

In a widely used NONMEM-style convention, EVID records the event type: EVID=0 denotes an observation record, EVID=1 a dose record, and EVID=2 another event. That convention also defines reset-related codes, but their use is outside this tutorial’s focus. Other software or project-specific formats may use different codes, so an analyst should verify the data dictionary and the model’s interpretation rather than assume that a code is self-explanatory.

The event code is not a substitute for the other fields. In a typical record, AMT stores an administered amount, DV stores an observed dependent variable such as concentration, and CMT identifies the relevant model compartment when the model uses compartments. A dose row and an observation row generally populate different fields. For example, an observation row may have a concentration in DV and no administered amount, whereas a dose row records the administered amount and has no observed concentration.

In some analysis formats, MDV indicates whether a dependent-variable value is available for the likelihood contribution: commonly, MDV=0 marks an observation to be analyzed, while MDV=1 marks a record with no dependent-variable observation. It is a separate concept from the event type. A dose row is not made a dose by setting MDV=1; its event code and dose fields must identify it as a dose. Likewise, an observation row needs a valid observation value and the appropriate observation status.

Record purposeTypical event codeFields that carry its meaningBasic interpretation
Pharmacokinetic sampleObservation, often EVID=0TIME, DV, observation statusA measured value is available at this time
Dose administrationDose, often EVID=1TIME, AMT, and applicable compartment fieldAn input is applied to the model at this time
Other model-relevant eventOther, often EVID=2TIME and the explicitly specified event fieldsA defined non-observation event affects interpretation or model state

A visit, phone call, or administrative note does not automatically need its own model event row. Include a row when the event is needed to represent the analysis timeline—for example, if it marks a model-relevant change—and ensure that the analysis knows what the row means. A calendar entry with no defined model use can remain in a separate operational data source. Conversely, if a relevant change is represented only in a note and omitted from the analysis data, the model cannot use it as an event.

Worked Example: Building Dose and Sample Records

Suppose a hypothetical subject receives two oral administrations, each recorded as 100 mg, at elapsed times 0 and 8 hours. Concentration samples are collected at 2 and 10 hours, with hypothetical measured values of 1.8 and 3.1 mg/L. Use the event-code convention described above, and assume a single applicable model compartment coded as 1.

IDTIME (h)EVIDAMT (mg)CMTDV (mg/L)MDV
501011001—1
50120011.80
501811001—1
501100013.10

The first and third rows are administrations because EVID=1; their AMT values are 100 mg. Their DV entries are absent, and MDV=1 marks that there is no observation on those rows. The second and fourth rows are observations because EVID=0; each has a concentration in DV and MDV=0. Here, zero in AMT is the chosen convention for a non-dose row. A project may instead permit a blank, but the choice must be compatible with the analysis software and used consistently.

Reading the records in time order gives the sequence: dose at 0 h, sample at 2 h, dose at 8 h, sample at 10 h. The event code answers what happened; the time and other fields supply the information needed to place and interpret it. The table does not by itself settle questions about the internal ordering of events recorded at an identical time.

How Coding Reconstructs a Timeline

An analysis program typically uses dose records to update the model’s input history and observation records to compare model predictions with measured values. This distinction gives a direct justification for separate event types: the two kinds of rows have different computational roles. A dose record supplies an input at a time; an observation record supplies a value against which the model is evaluated. Treating them as interchangeable would not preserve those roles.

$$ \text{subject record sequence} \longrightarrow \text{event type and time} \longrightarrow \begin{cases} \text{update model input history}, & \text{dose event},\\ \text{evaluate an observation}, & \text{sample event}. \end{cases} $$

This is a conceptual mapping, not a pharmacokinetic equation. Its practical consequence is that a record must be checked as a whole. For example, a row with a dose event code but no usable dose amount is not a complete dose record. A row coded as an observation but lacking an observation value cannot supply the intended measured response. A timeline sorted by time can reveal the sequence, but it cannot repair an incorrect event type or missing field.

Worked Example: Finding the Effect of a Misclassified Event

Consider a hypothetical record set for one subject. The true records are a 60 mg dose at 0 h and a concentration of 2.4 mg/L at 3 h. Suppose the sample row is accidentally assigned the dose code, while the dose row is correctly coded.

TIME (h)Intended eventIntended EVIDAccidental EVIDRelevant value
0Dose11AMT = 60 mg
3Sample01DV = 2.4 mg/L

With the intended coding, the model receives one dose input, \(60\) mg at \(0\) h, and one observation, \(2.4\) mg/L at \(3\) h. Under the accidental coding, the second row is interpreted as another dose event. If its dose amount is blank or zero, it still does not function as the intended observed concentration; if its other fields are inconsistent, the software may reject it or process it incorrectly. In neither case should the analyst expect the \(2.4\) mg/L value to contribute as the intended observation merely because it appears in a column labelled DV.

The error changes the analysis timeline’s meaning, even though the time values and the concentration text remain visible in the table. Correcting the event code and validating the fields restores the intended sequence. This example also shows why automated checks should examine event codes together with the fields that each event type requires.

Checks, Failure Modes, and Alternatives

A practical quality-control pass should test both the coding rules and the sequence they imply. Useful checks include:

  • Confirm that each subject’s records use only event codes allowed by the study’s data specification.
  • Check that dose records have the required dose fields and that observation records have the required measured-value and observation-status fields.
  • Check that nonapplicable fields follow one documented convention, rather than alternating unpredictably between blank, zero, and other placeholders.
  • Review each subject’s records in time order and compare the resulting event sequence with the source records or dosing and sampling schedule.
  • Flag other-event records for which the code is present but the event’s meaning or associated fields are not defined.

These checks detect different kinds of problems. A code-frequency summary can reveal an unexpected event code, but it cannot show whether the codes were assigned to the right rows. A field-consistency check can identify a dose row with no amount, but cannot establish whether the recorded amount matches the source. Timeline review helps assess sequence, but source-data comparison is still needed to confirm that the sequence represents what happened.

An alternative is to keep doses and samples in separate files and combine them during analysis. Separate source files can be useful for data capture, but the analysis still needs a consistent way to merge them into one interpretable event history. A single event-level table makes the sequence explicit and is convenient for many modeling workflows; it also creates a risk that inconsistent row conventions will be propagated unless validated. Neither storage arrangement removes the need for a data dictionary and checks.

Event coding has limits. A well-coded row cannot recover an event that was never recorded, determine whether source documentation is correct, or resolve ambiguous timing on its own. It also does not specify every modeling choice associated with a dose. Keep the coding scheme focused on identifying event type and linking it to the correct fields; represent additional details only according to the project’s defined data conventions.

Common Mistakes

  • Using a missing-value indicator as an event code. Setting MDV=1 does not declare that a row is a dose. The event-type field must do that.
  • Assuming the column name guarantees interpretation. A concentration stored in DV is not necessarily analyzed as an observation if the event code says otherwise.
  • Putting every visit or administrative contact in the model event table. Include a record only when its role in the analysis is defined; otherwise it can add rows without useful model information.
  • Allowing undocumented placeholders. If zero, blank, and missing all appear in a field, the analyst may be unable to distinguish a meaningful zero from a nonapplicable or unavailable value.
  • Checking codes without checking fields. A valid event code paired with incompatible or incomplete fields still produces an invalid or misleading record.
Key takeaway: A longitudinal record is interpreted through its event type, time, and event-appropriate fields. Define the codes and field rules, apply them consistently, and validate the resulting subject-level sequence against the source data.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. In a convention where EVID=0 denotes an observation and EVID=1 a dose, what event does a row with EVID=1, AMT=40 mg, and no measured value represent?
  2. Why is MDV=1 not enough to identify a dose record?
  3. A sample row contains a concentration in DV but has the dose event code. What is wrong, and what is the likely consequence?
  4. For a hypothetical subject, a dose occurs at 0 h, a sample at 1 h, and another dose at 12 h. State the event sequence and the appropriate event code for each record using the convention described here.

Solutions. (1) It represents a dose event at the row’s recorded time, with a 40 mg amount; the absence of a measured value is consistent with a dose row. (2) MDV describes whether a dependent-variable observation is available, not what event occurred. The event code and dose fields identify the dose. (3) The event code conflicts with the row’s intended meaning. The analysis may process it as a dose rather than evaluate the concentration as an observation, so the event code and associated fields should be corrected and checked. (4) The sequence is dose at 0 h (EVID=1), observation at 1 h (EVID=0), and dose at 12 h (EVID=1); the dose rows carry their applicable amounts, and the sample row carries its measured value.

Clinical Biostats