Why Derived Variables Need Clear Definitions
A data set may record height and weight but not body-mass index, or a date of birth but not age at enrollment. A value calculated from one or more recorded fields is a derived variable. Creating one can make a data set useful for a specific question, but only if another person can tell exactly how it was calculated and can reproduce the result.
The central task is not merely to perform arithmetic. It is to specify the source fields, the formula, the units, the time reference when relevant, and what happens if an input is missing or unusable. A transparent definition makes it possible to check whether the calculation matches the intended quantity rather than just whether the software returned a number.
A Reliable Construction Process
Before calculating a derived variable, write down what it is meant to represent. Then specify each ingredient in the calculation. If inputs have units, check that they are compatible with the formula and state the result's units. If the value depends on time, define the date or time at which it is meant to apply. Finally, test the rule on hand-calculated records and inspect the resulting values for errors.
State in plain language what the new field represents, such as body-mass index in kilograms per square metre or age in completed years on a particular date.
Name the source fields and write the formula or calculation rule. Do not leave important details to an undocumented software default.
Confirm that the units agree with the formula and decide how missing, impossible, or incompatible inputs affect the result.
Calculate selected cases by hand, compare them with the computed values, and record the formula, units, rounding rule, and checks performed.
These steps are useful whether the calculation is done by hand or with statistical software. A correct-looking result is not enough: a formula can be implemented consistently and still use the wrong units, the wrong date, or the wrong input fields.
Worked Examples
Worked Example: Calculating Body-Mass Index
Suppose a hypothetical record contains a mass of 63 kilograms and a height of 168 centimetres. Define body-mass index (BMI) as mass in kilograms divided by height in metres squared. Calculate it and verify the result.
State the rule and units. Let \(m\) be mass in kilograms and \(h\) be height in metres. Then BMI is \(m/h^2\), with units of kilograms per square metre (\(\mathrm{kg/m^2}\)). The recorded height must be converted from centimetres to metres before using this formula.
Convert and calculate. Since 100 centimetres equal 1 metre, \(168\text{ cm}\div100=1.68\text{ m}\). Therefore,
Hand-check the calculation. Multiplying the rounded BMI by the squared height gives \(22.32\times2.8224=62.995968\approx63.00\) kilograms, consistent with the recorded mass of 63 kilograms after rounding. The reverse check is approximate because the BMI used in it was rounded; the unrounded quotient gives the exact mass when multiplied by \(2.8224\).
This check also makes the unit conversion visible. Using 168 directly as though it were metres would give a result on the wrong scale and with the wrong units. The calculation assumes the mass and height refer to the same person and that both source values are recorded in the stated units.
Worked Example: Age in Completed Years on a Reference Date
Suppose a hypothetical participant's date of birth is November 20, 2004, and the analysis requires age in completed years on March 8, 2025. Define the reference date explicitly; age changes over time, so a date of birth alone does not specify a unique age value.
For age in completed years, subtract the birth year from the reference year, then subtract 1 if the birthday has not yet occurred in the reference year. Here the year difference is \(2025-2004=21\). The birthday, November 20, has not occurred by March 8, so subtract 1:
Check the result. The participant turned 20 on November 20, 2024, and will turn 21 on November 20, 2025. March 8, 2025 falls between those birthdays, so age in completed years is 20. Simply subtracting the birth year from the reference year would give 21 and would be incorrect for this date.
The rule must also specify how dates are recorded and how incomplete or invalid dates are handled. If the date of birth is missing or cannot be interpreted, the age cannot be calculated reliably from this rule; a value should not be guessed.
Worked Example: Creating a Total Score
A hypothetical form has three quiz items, each scored from 0 to 10 points. One record has item scores of 8, 7, and 9. Define the total score as the sum of these three item fields, in points.
Verify the range. If all three item scores are present and each is between 0 and 10, the total must be between 0 and 30 points. The calculated value, 24, is within that range. The source fields all use the same unit and scale, so adding them is meaningful under the stated definition.
If one item score is missing, the three-item total is not available under this definition. Reporting the sum of only the observed items as though it were a complete total would change what the variable means. Any alternative rule for incomplete forms would need to be specified separately and applied consistently.
Why the Units and Formula Must Travel Together
Units are part of a derived variable's definition, not a decorative label. For BMI, squaring height means the denominator has squared units. If height is entered in metres, the result is in \(\mathrm{kg/m^2}\); entering height in centimetres without converting it changes the numerical value by a factor of 10,000. More generally, a formula should be checked to ensure its arithmetic and units match the quantity being defined.
For the BMI calculation, the dimensional reasoning is:
This check does not establish that the chosen measure is appropriate for every purpose. It verifies that the stated calculation has the units implied by its formula. The substantive choice of measure still depends on the question being asked.
Missing Inputs, Rounding, and Verification
A calculated field inherits limitations from its source fields. If a required input is missing, the derived value is usually missing too unless a documented rule says otherwise. If a source value is impossible or recorded in an unexpected unit, calculating anyway can produce a precise-looking but meaningless result. Earlier checks of plausible ranges, missing-value codes, and measurement units are therefore relevant before applying a formula.
Rounding should be handled deliberately. Keep adequate precision during calculation, then round the final value to a stated number of decimal places or significant figures. Rounding intermediate values can introduce avoidable discrepancies, especially when a later check uses the rounded result. In the BMI example, the unrounded quotient is approximately \(22.321\), while the displayed value is \(22.32\). The reverse calculation using \(22.32\) is consequently close to, rather than exactly equal to, the recorded mass.
Hand checks should include more than one ordinary record when practical. Choose cases that test the important details of the rule: a unit conversion, a birthday that has and has not occurred, a value at a score boundary, or an input that is missing. Compare the hand result with the derived value and investigate any difference rather than assuming it is harmless.
Documentation and Common Pitfalls
A useful record of a derived variable lets another analyst reconstruct it without guessing. For example, documentation for the BMI field should identify mass in kilograms and height in centimetres as the recorded inputs, state that height is divided by 100 to convert it to metres, give the BMI formula and output units, and describe the rounding and missing-input rules. For age, the reference date and the meaning of “age” (such as completed years) are essential parts of the definition.
- Wrong reasoning: “The height column contains numbers, so I can use those numbers directly in the BMI formula.” Correction: Check and convert the recorded units first; the formula requires height in metres if the result is to be in \(\mathrm{kg/m^2}\).
- Wrong reasoning: “Age is the reference year minus the birth year.” Correction: For age in completed years, also check whether the birthday has occurred by the reference date.
- Wrong reasoning: “A total score is still comparable if I add whichever item scores are available.” Correction: That rule produces a different quantity when items are missing. Define and document a separate incomplete-score rule if one is needed.
- Wrong reasoning: “The calculation ran without an error, so the result is verified.” Correction: Check the formula, units, input status, expected range, and at least a few hand-calculated cases.
- Wrong reasoning: “Rounding early is harmless.” Correction: Retain precision during the calculation and round the reported result at the end; use the same precision when explaining any reverse check.
Check Your Understanding
Answer each question by naming the relevant inputs and explaining the calculation or check.
- A record gives a mass of 72 kilograms and a height of 180 centimetres. What conversion is needed before calculating BMI, and what are the resulting BMI value and units?
- A person was born on September 12, 2001. What is their age in completed years on June 1, 2024? Show why subtracting the years alone is or is not sufficient.
- Four items each have scores from 0 to 5 points. State the possible range for their complete summed score and name one check you could make on a calculated total.
- Why should a missing input generally not be treated as zero when calculating a sum, unless the data definition explicitly says to do so?
- What information must be documented for an age variable to be reproducible by another analyst?