Tutorials › Population Pharmacokinetics › Harmonizing External PK Datasets

Bootstrap and External Validation · Tutorial 423 of 599

Harmonizing External PK Datasets

Learn to build and audit a documented mapping from external PK records to the exact inputs expected by a locked model.

Advanced 9 min read

What You'll Learn

  • Define a model-input contract before transforming external records.
  • Reconstruct elapsed time from explicit, consistent time origins.
  • Convert dose and concentration units without changing their physical meaning.
  • Map analyte definitions and covariate encodings to model conventions.
  • Diagnose inconsistent records, ambiguous mappings, and transformations that need to remain unresolved.
  • Distinguish data harmonization from model updating or performance evaluation.

Harmonization as a Data-Meaning Check

A locked population PK model can only be applied meaningfully when its inputs represent the same things in the development and external datasets. Matching column names is not enough. A column called “time” might mean clock time, time since admission, or time since the most recent dose; “concentration” might refer to different analytes or units. Harmonization makes those meanings explicit and maps external records to the definitions the locked model expects.

The task is not to make two datasets look identical or to improve the model’s fit to the external data. It is to use prespecified, scientifically justified transformations that preserve the meaning of each record. If a difference cannot be resolved without guessing, the appropriate outcome is to flag the record or the dataset, not to invent a conversion. The model’s input definitions serve as the reference contract: they specify which events, units, analytes, covariate definitions, and time conventions the model uses.

Definition: Dataset harmonization is the documented process of mapping external PK records to the locked model’s input definitions using transformations that preserve their scientific meaning. It includes identifying incompatible or ambiguous fields; it does not mean changing model parameters, model structure, or the external observations to make predictions appear more favorable.

Before transforming data, write down the model-input contract. For each field, specify its definition, units, allowed values, time reference, and any encoding rules. Keep the external source value as well as the harmonized value, and record the transformation and its rationale. This lets a reviewer trace a model input back to its original record.

Time and Dosing Records

PK models use times in relation to events, not merely dates or clock readings. The relevant origin might be the first dose, a particular dose, or another specified study event. External records must be mapped to the same origin and time unit. If the model uses elapsed time in hours since the first dose, then both sample times and dosing-event times must be expressed on that scale. A sample without a reliable event history may not have a defensible model time.

For timestamps in the same time zone and on an unambiguous clock, elapsed time can be calculated as the difference between timestamps. If \(T\) denotes a timestamp and \(T_0\) the agreed origin, then elapsed time in hours is the timestamp difference converted to hours. The conversion must account for the date, not just the clock face: a sample at 08:00 on the following day is 24 hours after an 08:00 origin, not at time zero. Daylight-saving transitions, time-zone differences, and local versus standard time can make a simple clock subtraction wrong; resolve these using documented timestamp conventions before calculating elapsed times.

$$ t_{\mathrm{h}} = \frac{T_{\mathrm{sample}}-T_0}{3600\ \mathrm{s/h}} $$

This expression assumes the timestamp difference is represented in seconds on a consistent, unambiguous time scale. Each dose event also needs a consistent time and amount. Check for duplicate or impossible event times, missing dose amounts, implausible intervals, and sample times that precede the stated origin. A valid-looking numerical time does not establish that the event history is correct.

Worked Example: Converting Sample Times to Hours Since First Dose

Suppose the locked model expects time in hours since the first dose. In a hypothetical external dataset, the first dose is recorded at 08:00 on 12 March, a sample at 08:30 that day, another at 10:00, and a third at 08:00 on 13 March. Assume all timestamps are in the same time zone, the dates are correct, and no clock change occurs across this interval.

For the 08:30 sample, the difference from the origin is 30 minutes: \(30\ \mathrm{min}\times(1\ \mathrm{h}/60\ \mathrm{min})=0.500\ \mathrm{h}\). For the 10:00 sample, it is 2 hours after the origin, so \(t=2.00\ \mathrm{h}\). For the next-day 08:00 sample, one full day has elapsed: \(24\ \mathrm{h/day}\times1\ \mathrm{day}=24.0\ \mathrm{h}\).

The harmonized times are therefore 0.500, 2.00, and 24.0 hours. The conversion is justified by the stated timestamp assumptions. If the records instead contained local clock times spanning a daylight-saving change with no time-zone information, the elapsed times could not be safely inferred by this arithmetic alone.

Dose records need the same care. Confirm that amount, route, formulation, and event time are interpretable under the model’s conventions. A dose recorded as administered must not be silently treated as prescribed if administration is uncertain. Nor should a dose be assigned to a sample solely because it is the nearest recorded event. Where the event history is incomplete or internally inconsistent, retain the discrepancy for review.

Units, Analytes, and Concentration Records

A numerical concentration is not interpretable without its unit and analyte definition. Unit conversion is appropriate when two records measure the same quantity on compatible scales. For example, a mass concentration in mg/L can be expressed in ng/mL using a fixed conversion: \(1\ \mathrm{mg/L}=1000\ \mathrm{ng/mL}\). The conversion changes the numerical value, not the underlying concentration.

Worked Example: Converting Concentration Units

A locked model expects plasma concentration in ng/mL. A hypothetical external record reports \(0.075\ \mathrm{mg/L}\). Since \(1\ \mathrm{mg}=10^6\ \mathrm{ng}\) and \(1\ \mathrm{L}=10^3\ \mathrm{mL}\),

$$ 0.075\ \frac{\mathrm{mg}}{\mathrm{L}} \times \frac{10^6\ \mathrm{ng}}{1\ \mathrm{mg}} \times \frac{1\ \mathrm{L}}{10^3\ \mathrm{mL}} = 75\ \mathrm{ng/mL}. $$

Thus the model input is \(75\ \mathrm{ng/mL}\), provided the original field is indeed a concentration in mg/L for the same analyte and the same type of biological matrix that the model expects. If any of those conditions is unknown, the arithmetic alone does not establish equivalence.

Analyte identity is a scientific definition, not a label to normalize casually. Parent drug, metabolite, total drug, and unbound drug are not interchangeable measurements. Even when two reported concentrations use the same units, they may differ in what chemical species or fraction was measured. Molecular-weight conversions may sometimes express the same substance on a different mass basis, but they do not turn a metabolite concentration into a parent-drug concentration, or total concentration into unbound concentration. Document the analyte and matrix definitions and flag unresolved differences.

Check whether values are raw, dilution-corrected, or otherwise transformed according to their data dictionary. Applying a correction twice can create a systematic error while leaving the results numerically plausible. Also distinguish a true zero from a missing result, a below-quantification result, or a value recorded using a special code. Do not replace these states with one another as a convenience. Their treatment depends on the model and analysis plan; a conversion step should preserve the original status and make any recoding explicit.

Covariates and Categorical Encodings

Covariates require harmonization of both units and meaning. A model using weight in kilograms cannot be supplied a weight in pounds simply because both columns are numeric. A model using a particular clinical definition of renal function cannot necessarily accept a differently calculated value with a similar label. Confirm the measurement definition, units, timing, and any categorization or coding rule used by the locked model.

Worked Example: Mapping Weight and a Binary Covariate

Suppose the locked model expects weight in kg and a binary indicator coded 1 for male and 0 for female. In a hypothetical external record, weight is 154 lb and sex is recorded as “M.” Assume the model’s definition of this covariate matches the meaning of the external field, and the external weight is a measured body weight rather than a different weight definition.

Use \(1\ \mathrm{lb}=0.45359237\ \mathrm{kg}\): \(154\ \mathrm{lb}\times0.45359237\ \mathrm{kg/lb}=69.8532\ \mathrm{kg}\). To three significant figures, enter \(69.9\ \mathrm{kg}\). The category “M” maps to 1 under the specified encoding, so the harmonized indicator is 1. The original “154” and “M” should remain available in the source record; the converted values and the mapping rule should be recorded separately.

This mapping would not be justified if “M” had an ambiguous meaning, if the model used a different covariate definition, or if the weight units were undocumented. Unknown, missing, and not-applicable categories should remain distinguishable unless the model’s prespecified input rules say otherwise. Treating an unknown category as 0, for example, would assert that the record belongs to a known reference category.

Continuous covariates may also require checking the date on which they were measured. A weight measured long before the relevant dosing period may not represent the model-defined covariate. For categorical covariates, create an explicit mapping table and check every source category, including uncommon values. A category absent from the mapping is a review issue, not a reason to assign the most convenient code.

A Practical Audit Before Model Application

A harmonization workflow should make its decisions reproducible and expose records that cannot safely be mapped. The following sequence separates definition, transformation, and quality checks.

1
Specify the model inputs.
List required fields, definitions, units, time origin, event conventions, analytes, and category encodings from the locked model and its analysis specification.
2
Inventory external fields.
For each field, identify the source definition, units, coding, timing, and known limitations. Do not infer these from a column name alone.
3
Apply explicit mappings.
Convert only where equivalence is justified. Preserve raw values, create harmonized fields, and log the mapping or conversion applied.
4
Run record-level checks.
Check ranges, units, time ordering, dose-to-sample relationships, category coverage, duplicates, missingness, and consistency between linked records.
5
Resolve or flag discrepancies.
Use documented source clarification where available. Retain unresolved records as flagged or exclude them according to prespecified rules; do not guess silently.

A useful audit table reports, for each variable, the source definition, target definition, transformation, assumptions, and unresolved issues. Automated checks can identify impossible values or unrecognized codes, but they cannot establish scientific equivalence by themselves. For example, a concentration range check might find a unit error, but a plausible value does not prove that the sample measured the right analyte.

Harmonization is distinct from several tempting alternatives. A prespecified conversion is preferable to ad hoc adjustment because it is reproducible and does not use external outcomes to tune the model. Dropping every record with a discrepancy may avoid some input errors but can discard usable data and change which population remains represented; exclusions need transparent rules. Conversely, forcing every field into a target format can conceal a genuine incompatibility. Harmonization does not resolve differences in study design, measurement practice, or population. It prepares inputs; it does not establish that the model is suitable for the external setting or determine how its predictions perform.

Common Pitfalls and Limits

The most common mistake is to treat a field as harmonized once its units or label match. A time column in hours is still wrong if its origin differs. A concentration in ng/mL is still wrong if it measures a metabolite while the model expects parent drug. A binary covariate coded 0 and 1 is still wrong if the reference category is reversed. Each mapping must be checked against the underlying definition.

  • Converting units without checking the quantity. Verify both the units and the analyte, matrix, and concentration basis before applying a numerical conversion.
  • Using clock time as elapsed time. Calculate elapsed time from an explicit origin, using dates and consistent time-zone information.
  • Collapsing missing and unknown values. Preserve distinct data states rather than assigning an unsupported category or numerical value.
  • Silently repairing event histories. Record the source, rule, and reason for any correction; flag ambiguities that cannot be resolved from available evidence.

Some discrepancies cannot be repaired through data transformation. The external study may not have recorded a required covariate, may use an incompatible analyte definition, or may lack sufficiently precise dose times. In such cases, document the limitation and determine whether the locked model can accept the available information under its established input rules. Any decision to change the model or its assumptions is not merely harmonization and should be treated separately.

Key takeaway: A valid harmonized input has the same scientific meaning the locked model expects, not merely the same column name, unit label, or data type. Preserve the source record, make each justified mapping auditable, and flag what cannot be established.

Check Your Understanding

Answer each question, then compare with the concise solutions.

  1. A model uses hours since the first dose. An external sample is taken at 06:00 one day after a 06:00 first dose. What is the harmonized time, assuming timestamps are unambiguous?
  2. A concentration is reported as \(0.020\ \mathrm{mg/L}\). Convert it to ng/mL, assuming it measures the model’s required analyte in the required matrix.
  3. Why is an external value coded “unknown” not automatically mapped to 0 when the model uses a binary indicator?
  4. Two datasets report concentration in ng/mL, but one measures total drug and the model expects unbound drug. Is a unit conversion sufficient? Explain.
  5. Name two checks that can reveal a time-harmonization problem and one limitation of those checks.

Solutions. (1) \(24.0\ \mathrm{h}\), because one full day elapsed from the first-dose origin. (2) \(0.020\times1000=20.0\ \mathrm{ng/mL}\). (3) Zero represents a particular defined category; “unknown” does not establish membership in that category, so mapping it would invent information. (4) No. The units match, but total and unbound concentrations are different quantities; a justified mapping would require more than a unit conversion. (5) Checks include verifying that sample times follow the stated origin and reviewing dose-to-sample intervals or date ordering. They can flag implausible records, but plausible times do not prove that the origin or timestamp metadata were recorded correctly.

Clinical Biostats