Why Check Ranges?
A recorded number can look unusual without being wrong, and a value can be plainly incompatible with a variable’s definition. Checking plausible ranges helps identify values that deserve attention before analysis. For regression, this matters because a data-entry error in a predictor or response can distort summaries and fitted relationships.
A range check is a screening rule, not a verdict. It compares a value with limits justified by the variable’s definition, the study context, and—when relevant—the measurement process. A value outside those limits is flagged for investigation. The check alone does not establish what happened or authorize changing the value.
Set the Rule Before Checking the Values
The bounds should come from what the variable records, not from the values that happen to appear in the data. Ask what one unit of the variable means, which population or period the record describes, and whether the definition implies limits. Then write the rule precisely enough that two people checking the same value would reach the same result.
Some bounds follow directly from a definition. A proportion recorded on the zero-to-one scale cannot be below 0 or above 1; the corresponding percentage cannot be below 0% or above 100%. A count cannot be negative, and it must be an integer if it counts whole events. Other limits depend on context. If a program enrolls only adults aged 18 through 100, that documented eligibility rule gives a range for age in that program. It would not be a universal range for every age variable.
Keep different kinds of limits distinct. A physical or definitional limit describes values the variable can take. A study-specific rule can restrict the eligible records, and an instrument’s operating range can restrict what it can measure reliably. These may overlap, but they answer different questions. State which kind of rule you are applying and why.
Do not use the sample’s minimum and maximum as if they defined the possible values. Nor should a value be rejected just because it is far from the average or unlike most other records. Those are reasons to look more closely, not definitions of impossibility. A rare observation can still be correct.
How a Range Flag Works
For a variable whose allowable interval is \(L \leq x \leq U\), a value is outside the range if it is less than \(L\) or greater than \(U\). The endpoints are allowed under an inclusive rule. The flag can be represented by an indicator that equals 1 when the rule is violated and 0 otherwise:
This rule follows directly from the definition of the interval: its members are exactly the values at least \(L\) and at most \(U\). Therefore, a value fails membership precisely when it lies below \(L\) or above \(U\). For variables with additional restrictions, such as integer counts, use a rule that checks those restrictions too.
A practical check has three parts: specify the variable and its rule, compare the recorded value with every required condition, and record the result as a flag for review. Keep the observed value available while checking it. Do not silently replace, round, or delete a flagged value.
Include its unit, population or period, and any documented limits that apply.
Specify the bounds, whether endpoints are allowed, and any constraints such as being a whole-number count.
Check each recorded value against the rule. A failing value needs review; it is not automatically an error.
Consult the original record or data-collection documentation where available. Preserve the value and make any correction traceable.
Worked Example: Ages in an Adult Program
Suppose a hypothetical program enrolls adults aged 18 through 100, inclusive, and records age in completed years at enrollment. Five recorded ages are 24, 31, 180, 47, and 19. Apply the program’s documented age rule.
Rule. For this program, the allowable range is \(18 \leq \text{age} \leq 100\). The lower and upper endpoints are allowed because the rule says ages 18 through 100.
Check. The values 24, 31, 47, and 19 each satisfy \(18 \leq \text{age} \leq 100\), so none is flagged by this rule. For 180, \(180>100\), so the value is flagged.
The check does not establish whether 180 is a typing mistake, a unit problem, or some other recording issue. The next step is to compare it with the original enrollment record and the data definition. Do not change it to a guessed value such as 18 or 80 without evidence. Also, this program-specific range should not be presented as a universal allowable age range.
Ranges Can Include More Than Two Bounds
Some variables need both numeric bounds and a form constraint. For example, “number of events” ordinarily means a nonnegative whole-number count. A value of 2.5 may lie between zero and a context-specific maximum, but it is not a valid count of whole events. A complete rule should test every property implied by the definition.
Percentages also need their scale stated clearly. A percentage from 0% to 100% is not recorded on the same scale as a proportion from 0 to 1. Confusing these representations can make a valid value look far too large or too small. Check the recorded unit and the variable definition before deciding that a number violates the range.
Worked Example: A Percentage Recorded on a Zero-to-100 Scale
Imagine a hypothetical data file that records the percentage of scheduled sessions attended by each participant, using values from 0 to 100. Four entries are 0, 64.5, 100, and 103.2. Check them using the variable’s stated scale.
Rule. A percentage on this scale must satisfy \(0 \leq \text{percentage} \leq 100\). Both 0 and 100 are allowed: they represent no sessions attended and all scheduled sessions attended.
Check. The first three entries satisfy the rule: \(0 \geq 0\), \(64.5 \leq 100\), and \(100 \leq 100\). The last entry fails because \(103.2>100\), so 103.2 is flagged.
The flag says that 103.2 is incompatible with this variable’s stated percentage scale. It does not say what the intended value was. Check the source record and confirm that the field was meant to store a percentage, rather than a different measure or a different scale. If the value was actually recorded as a proportion, the data definition would need to say so, and the range check would use that representation instead.
Worked Example: Counts During a Fixed Period
Suppose a hypothetical file records the number of clinic visits made by each person during a specified 30-day period. The entries are 0, 2, 7, −1, and 3.5. Apply a rule that reflects both the count definition and the period.
Rule. The number of visits must be a nonnegative integer: it must satisfy \(\text{visits} \geq 0\) and be a whole number. There is no supplied maximum number of visits, so this check does not invent one.
Check. The values 0, 2, and 7 are nonnegative whole numbers, so they pass. The value −1 fails because \(-1<0\). The value 3.5 is nonnegative but is not a whole number, so it fails the count constraint. Both −1 and 3.5 are flagged for review.
The result is limited to these rules. It does not tell us whether 7 visits is unusually high for this context, and it does not establish how either flagged value arose. Confirm the definition and check the source before deciding whether a correction is justified.
What a Flag Does—and Does Not—Mean
A value outside a well-defined range is incompatible with the rule as written. That makes it a priority for review. But a range check cannot diagnose the cause. The recorded value might reflect a data-entry problem, a misunderstood unit, a mismatch between the field and the definition, or an incorrectly specified rule. Verification requires information beyond the comparison itself.
The reverse is important too: passing a range check does not certify that a value is accurate. A value can lie within the allowable range and still have been copied incorrectly. And an extreme value that passes the rule may be unusual but valid. Do not tighten bounds simply because an observation is surprising. Use the variable’s definition and relevant source information, rather than rarity alone, to decide what to review.
| Check result | What it supports | What it does not establish |
|---|---|---|
| Value is outside a justified range | The recorded value violates the stated rule and should be reviewed. | The cause of the violation or the correct replacement value. |
| Value is within the stated range | The value passes that particular range check. | That the value is accurate, typical, or error-free. |
| Value is rare but within the range | The observation may deserve a closer look in context. | That the observation is impossible or should be removed. |
Common Mistakes
- Using a typical range as an allowable range. “Most people are younger than 90” does not make an age of 95 impossible. Use a documented rule, not a guess based on what is common.
- Treating every flag as a confirmed error. A flag identifies a rule violation. Verify the record before editing or excluding anything.
- Ignoring the units or scale. A percentage and a proportion use different numeric scales. Check which one the field is defined to contain.
- Applying a universal limit to a context-specific variable. A program’s eligibility bounds apply to that program when documented; they need not apply to another population.
- Assuming a passed check proves correctness. A value can be wrong and still fall inside the allowed interval.
Check Your Understanding
For each situation, identify the range rule and explain what a flagged value would mean.
- A variable records body temperature in degrees Celsius. Why should you define the context and measurement process before choosing a numeric range?
- A completion percentage is recorded on a scale from 0 to 100. Which of the values 0, 88.4, and 100.1 fails an inclusive range check?
- A field records the number of books borrowed during one month. State two constraints a valid count must satisfy.
- A recorded age is unusual but falls within the documented bounds for the study. Does it pass the range check, and does that prove it is correct?
- A percentage value is flagged as greater than 100. What should be checked before deciding how to handle it?