Tutorials › Pharmacometric Workflows and Reproducible Modeling › Units and Unit Harmonization

Data Specification and Dataset Preparation · Tutorial 7 of 399

Units and Unit Harmonization

Build an auditable unit-harmonization workflow that standardizes compatible values without confusing distinct quantities or losing their source information.

Intermediate 11 min read

What You'll Learn

  • Inventory units by variable and identify where units are recorded or assumed.
  • Choose project-standard units and convert values using explicit factors.
  • Check dimensional compatibility before converting concentrations, doses, times, or covariates.
  • Preserve source values, source units, conversion factors, and provenance for auditability.
  • Detect common conversion errors with dimensional checks, range checks, and round-trip calculations.

Why Unit Harmonization Matters

A pharmacometric data set can contain valid observations that cannot safely be analyzed together until their units are made consistent. One laboratory result may be reported in micrograms per litre and another in nanograms per millilitre; one visit time may be recorded in minutes and another in hours. The numerical values alone do not reveal whether they are comparable. A value of 60 could mean 60 minutes, 60 hours, or 60 days.

Unit harmonization is the controlled conversion of values that represent the same physical quantity into a consistent, project-defined unit. It is not simply changing a unit label, and it does not make different quantities interchangeable. A concentration cannot be converted to a dose by a unit multiplier, for example. Reliable harmonization begins with an inventory: identify the quantity, its source unit, and the unit expected in the analysis data.

Definition: A source unit is the unit in which a value was supplied or recorded. A target unit is the unit selected for consistent use in a project. A conversion factor is a numerical multiplier, with units, that maps a value from its source unit to a compatible target unit. A conversion is valid only when both units describe the same quantity and the factor is appropriate for that quantity.

The target units are project conventions, not universal requirements. A project might choose hours for time, milligrams per litre for concentration, milligrams for dose amount, kilograms for body weight, and centimetres for height. State those choices in the data specification before conversion. The earlier material on time origins and study-day conventions concerns the meaning and reference point of time variables; converting minutes to hours changes the scale, not the time origin or the definition of study day.

Inventory Before Converting

For each variable intended for quantitative use, record its meaning, source unit or units, target unit, and how the source unit is known. Units may be declared in a data dictionary, supplied in a file header, documented by a laboratory, or provided for individual records. Do not infer a unit from the apparent size of a number when documentation is missing. Resolve ambiguity with the data source or preserve the value as unresolved rather than silently guessing.

An inventory is particularly important when units vary across files or records. A column called “time” may contain hours in one file and minutes in another; a concentration column may mix results from different laboratories. If one unit applies to an entire file, document that scope. If units can vary record by record, the unit information must be linked to each value before conversion.

  • Time: distinguish seconds, minutes, hours, and days. Confirm the quantity is a duration or elapsed time, rather than a calendar date or timestamp.
  • Concentration: record both the mass or amount unit and the volume unit, such as ng/mL or mg/L. Confirm the analyte and reporting basis are the same.
  • Dose amount: distinguish an amount such as mg from a normalized amount such as mg/kg. They are not directly convertible without the relevant body weight and a defined calculation.
  • Covariates: specify units for measurements such as body weight, height, or age. A numerical code or category is not made quantitative by assigning it a unit.

Conversion as Dimensional Arithmetic

Write the conversion factor so that the source unit cancels and the target unit remains. This makes the direction of the conversion visible and is a simple safeguard against multiplying by the wrong factor. If the source value is \(x\), and the factor is \(c\) target units per source unit, then the converted value is \(x c\), expressed in the target unit.

$$ x_{\text{target}} = x_{\text{source}} \times \frac{\text{target unit}}{\text{source unit}} $$

For example, the exact relationship \(1\ \mathrm{h}=60\ \mathrm{min}\) gives \(1\ \mathrm{h}/60\ \mathrm{min}\) as the factor for converting minutes to hours. Multiplying a minute value by this factor cancels minutes. Reversing the factor converts hours to minutes. More complicated conversions follow the same rule by composing documented equalities.

Conversion check: Before applying a factor, write the units on both sides of the multiplication. The source unit must cancel, leaving the intended target unit. If the units do not cancel to the intended quantity, the calculation is not a valid conversion.

Worked Conversions

Worked Example: Harmonizing Elapsed Times

A hypothetical data extract contains three elapsed times from the same defined time origin: 2.0 h, 30 min, and 1.5 d. The project target is hours. Convert all three, assuming the documented source units are correct and a day in this variable means 24 hours.

The first value is already in hours: \(2.0\ \mathrm{h}\). For the second value, use \(1\ \mathrm{h}=60\ \mathrm{min}\):

$$ 30\ \mathrm{min} \times \frac{1\ \mathrm{h}}{60\ \mathrm{min}} = 0.500\ \mathrm{h} $$

For the third, use \(1\ \mathrm{d}=24\ \mathrm{h}\):

$$ 1.5\ \mathrm{d} \times \frac{24\ \mathrm{h}}{1\ \mathrm{d}} = 36\ \mathrm{h} $$

The harmonized values are therefore 2.0 h, 0.500 h, and 36 h. The calculation standardizes their scale; it does not establish that the values share the same time origin or represent the same type of time variable. Those meanings must already be specified.

Worked Example: Converting Concentration Units

A hypothetical assay result is 850 ng/mL. The analysis data use mg/L. Convert the result using the mass and volume relationships \(1\ \mathrm{mg}=10^6\ \mathrm{ng}\) and \(1\ \mathrm{L}=1000\ \mathrm{mL}\). Assume the result refers to the same analyte and reporting basis in both units.

Construct a factor with ng and mL in the denominator so both source units cancel:

$$ 850\ \frac{\mathrm{ng}}{\mathrm{mL}} \times \frac{1\ \mathrm{mg}}{10^6\ \mathrm{ng}} \times \frac{1000\ \mathrm{mL}}{1\ \mathrm{L}} = 0.850\ \frac{\mathrm{mg}}{\mathrm{L}} $$

Thus \(850\ \mathrm{ng/mL}=0.850\ \mathrm{mg/L}\). Equivalently, \(1\ \mathrm{ng/mL}=0.001\ \mathrm{mg/L}\). The result is not 0.000850 mg/L: that would omit the factor of 1000 arising from converting millilitres to litres.

Worked Example: Harmonizing a Dose Amount and a Covariate

In a hypothetical file, a dose amount is recorded as 0.25 g and body weight as 154 lb. The project uses mg for dose amount and kg for body weight. Use \(1\ \mathrm{g}=1000\ \mathrm{mg}\) and \(1\ \mathrm{lb}=0.45359237\ \mathrm{kg}\).

For the dose amount:

$$ 0.25\ \mathrm{g} \times \frac{1000\ \mathrm{mg}}{1\ \mathrm{g}} = 250\ \mathrm{mg} $$

For body weight:

$$ 154\ \mathrm{lb} \times \frac{0.45359237\ \mathrm{kg}}{1\ \mathrm{lb}} = 69.8532\ \mathrm{kg} \approx 69.85\ \mathrm{kg} $$

These are two independent conversions: one changes a mass amount, and the other changes a body-weight measurement. They do not, by themselves, convert the dose to mg/kg. That normalized quantity would require an explicit calculation using the dose and the appropriate weight, and it has a different unit and meaning from dose amount alone.

Why the Conversion Factor Works

A conversion factor is a ratio of equal quantities expressed in different units, so its numerical value changes the representation without changing the underlying quantity. For example, \(1\ \mathrm{h}\) and \(60\ \mathrm{min}\) denote the same duration. Their ratio is one as a physical quantity, even though its written numerical multiplier is useful for changing units.

The inverse factor reverses the conversion. If \(1\ \mathrm{h}=60\ \mathrm{min}\), then the factor for minutes to hours is \(1\ \mathrm{h}/60\ \mathrm{min}\), while the factor for hours to minutes is \(60\ \mathrm{min}/1\ \mathrm{h}\). Multiplying them cancels both units and gives one:

$$ \left(\frac{1\ \mathrm{h}}{60\ \mathrm{min}}\right) \left(\frac{60\ \mathrm{min}}{1\ \mathrm{h}}\right) =1 $$

This also gives a useful audit check: converting a value to a target unit and back with the exact inverse factor should recover the original value, apart from expected rounding. A failed round trip suggests a wrong factor, an incorrect unit label, or unintended rounding.

Making Harmonization Auditable

Keep enough information to reconstruct what happened to each converted value. A practical audit trail records the original value and unit, the harmonized value and unit, the factor or conversion rule applied, and the source of the unit information. For record-level variation, retain the source unit with the individual record or in a reliably linked field. Do not overwrite the only copy of the source value during data preparation.

The factor itself should be stored or clearly specified with its direction. “Converted to hours” is not enough to reproduce a transformation if the original unit could have been minutes or days. Preserve sufficient precision during computation; round for display or reporting only when the specification requires it. If the source value is already rounded, conversion cannot restore precision that was never recorded.

A clear workflow separates the stages: inspect and document source units, define target units, apply conversions, then check results. This separation makes it easier to identify whether a problem came from source metadata, the chosen factor, or a later transformation.

1
Inventory.
List each quantitative variable, its physical meaning, possible source units, and where those units are documented.
2
Specify targets.
Choose one target unit per quantity for the project and document the choice and conversion rules.
3
Convert and retain provenance.
Apply dimensionally correct factors while retaining the source value, source unit, and rule used.
4
Validate.
Check units, arithmetic, plausible ranges, and round trips before using the harmonized values.

Diagnostics, Alternatives, and Limits

Several checks can reveal unit errors. First, inspect the distinct unit labels and their frequencies; unexpected labels or missing units need resolution. Second, compare source and converted values with the expected scale: converting minutes to hours should divide the numerical value by 60. Third, check plausible ranges in the target units and investigate extreme values rather than automatically deleting them. Finally, recalculate a sample of records independently and perform round-trip checks.

A common mistake is to change a unit label without changing the number. Relabelling 30 min as 30 h makes the duration 60 times larger; the correct conversion is \(30/60=0.5\) h. Another mistake is applying the right factor in the wrong direction. Dimensional cancellation exposes that error before it enters the analysis.

Not every pair of units can be handled by a single multiplicative factor. Converting a concentration from mass per volume to amount per volume requires the analyte's molecular weight and a clearly defined chemical form. A mass amount and a mass-per-weight dose are different quantities; conversion between them requires a specified weight. Likewise, values with different reporting bases or analyte definitions should not be made comparable merely by changing units. Resolve these cases with domain documentation and an explicit calculation, not an assumed multiplier.

The main alternative to converting all values during data preparation is to retain mixed source units and convert only when a value is read for analysis. That can preserve raw inputs, but it requires every downstream analysis to apply the correct conversion consistently. A standardized analysis variable with a retained source record is often easier to validate and reuse. Whichever approach is chosen, the target convention and conversion process must be explicit; neither approach compensates for undocumented units.

Key takeaway: Harmonization preserves meaning while changing representation. Confirm that quantities are compatible, cancel units through explicit factors, and retain the source information needed to reproduce and audit each conversion.

Check Your Understanding

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

  1. Convert 90 min to hours. Show the factor and state the result with units.
  2. A hypothetical concentration is 2.4 mg/L. Convert it to ng/mL, showing how both units are handled.
  3. A source file contains 70 as a body-weight value but gives no unit. Why is it not safe to convert it to kg based only on the number?
  4. Explain why 120 mg cannot be converted directly to 2 mg/kg without additional information.

Solutions. (1) \(90\ \mathrm{min}\times(1\ \mathrm{h}/60\ \mathrm{min})=1.5\ \mathrm{h}\). (2) \(2.4\ \mathrm{mg/L}\times(10^6\ \mathrm{ng}/1\ \mathrm{mg})\times(1\ \mathrm{L}/1000\ \mathrm{mL})=2400\ \mathrm{ng/mL}\). (3) The value could be in kilograms, pounds, or another unit; without source metadata the appropriate factor and resulting value are unknown, so the unit must be resolved rather than guessed. (4) mg is a mass amount, while mg/kg is mass per body weight. Calculating a normalized amount requires the relevant weight and a specified calculation; the units cannot be equated by a conversion factor alone.

Clinical Biostats