A check tests one requirement
A data quality check, sometimes called a data quality rule, tests whether data conform to a given requirement. A script that flags a patient whose recorded age is 141 is a check. The age may come from a wrong birth year or from a death that was never recorded.
The frameworks earlier in this module say what good data look like. Checks measure it. The Observational Health Data Sciences and Informatics (OHDSI) community files each check under one of Kahn's three categories, conformance, completeness and plausibility, so results can be counted by category.
Checks serve two kinds of assessment. A general assessment asks whether the data are fit for observational research at all. A study-specific assessment asks whether they are fit for one study. General checks should run before the data are used for research. Because they are run whatever the research question, OHDSI also recommends study-specific checks.
| Category | What the check asks | Example |
|---|---|---|
| Conformance: value | Do recorded values match the specified format? | Is every provider's medical specialty a valid specialty? |
| Conformance: relational | Do records meet relational constraints? | Does each provider ID on a drug exposure record have a matching record in the provider table? |
| Conformance: computation | Do computations on the data give the intended result? | Does body mass index (BMI) computed from height and weight equal the BMI recorded? |
| Completeness | Is the variable present, and does it hold all its values? | Is weight measured in the office recorded? Does every person have a known gender? |
| Plausibility: uniqueness | Does each thing appear once? | Does each person ID occur only once in the person table? |
| Plausibility: atemporal | Do values and distributions agree with what is expected? | Is the diabetes prevalence the data imply in line with the known prevalence? |
| Plausibility: temporal | Do values change over time as expected? | Are immunization sequences in line with recommendations? |
Each category can be evaluated by verification, against local knowledge and constraints, or by validation, against an external benchmark.
Automated checks run against a threshold
OHDSI's Data Quality Dashboard (DQD) goes table by table and field by field through data converted to OHDSI's Common Data Model (CDM). It counts the records that fail to conform to the specifications. It runs over 1,500 checks, each filed under a Kahn category.
Each check's result is compared to a threshold. The check fails when the percentage of violating rows is above that threshold. A check with a 5% threshold passes with 4% of rows violating and fails with 6%.
The checks work at three levels. Table checks ask whether all required tables are present. Field checks test every field of every table, for example that each primary key is unique. Concept checks look at individual codes, for example that a gender-specific concept such as prostate cancer is not recorded for a female patient.
A second OHDSI tool, ACHILLES (Automated Characterization of Health Information at Large-scale Longitudinal Evidence Systems), describes and charts the database instead of counting rule violations. It precomputes more than 170 characterization analyses, such as the distribution of age at death by gender.
Worked example
Three checks on a visit table
A team runs three checks on a converted visit table of 20,000 rows. A check fails when the percentage of violating rows is above its threshold. Check A finds 1,200 rows whose visit end date falls before the start date, threshold 5%. Check B finds 900 rows whose provider ID has no record in the provider table, threshold 5%. Check C finds no duplicate visit IDs, threshold 0%. Give each percentage to one decimal place.
- 1
Formula
Percentage of violating rows = violating rows ÷ rows checked × 100.
- 2
Check A
1,200 ÷ 20,000 × 100 = 6.0%. That is above 5%, so the check fails.
- 3
Check B
900 ÷ 20,000 × 100 = 4.5%. That is not above 5%, so the check passes, with 900 rows still worth a look.
- 4
Check C
0 ÷ 20,000 × 100 = 0.0%. That is not above 0%, so the check passes.
Result: Check A fails and checks B and C pass. Check B passes with 900 violating rows, so a pass can still leave rows to fix.
A failure can come from the conversion or the source
A problem found in converted data may come from the conversion itself or may already be in the source data. If the conversion is at fault, the team can usually fix it. If the source data are at fault, the only course left may be to delete the offending records.
OHDSI reports that a properly executed conversion to its CDM adds little to no error. A failed check can still point to either one.
Look at the data over time
Charts of the data over time show problems that a check on single rows will miss. In one OHDSI example, a data density plot shows that the bulk of the data starts in 2005, with a few records from around 1961. Those few records are likely an error.
In another, the monthly rate of a diabetes diagnosis code jumps in the month the country's reimbursement rules changed. The new rules led to more diagnoses, probably without a true rise in prevalence. A sudden change in how often a code appears may hint at a data quality problem or at a change in how the data are made.
Study-specific checks
General checks run whatever the question. These checks are written for one study.
A rule the study needs
A study can impose its own rule, such as requiring that at least 90% of the records for the exposure of interest give the length of exposure.
The study's codes over time
Review the concepts the study's cohort definitions use. A sudden change in the rate at which a code appears may hint at a problem.
Cohorts against clinical knowledge
A new drug should be absent before it reached the market and will likely rise after. An outcome's prevalence should be in line with what is known of the condition in the population.
Databases against each other
A cohort that is common in one database and missing in another may point to a data quality problem. It may also mean the cohort definition misses the health state, or that the populations really differ.
HCUP reviews each source with summary statistics
The Healthcare Cost and Utilization Project (HCUP) assesses the quality of the annual and quarterly data from each data source that takes part in it. Its quality control procedures are one data steward's practice; other data sets set their own rules.
For each year and data source, an independent contractor calculates and reviews a set of statistics. For every year or quarter and every HCUP database, HCUP also counts the edit failures and their percentages, and uses them to judge each source's data quality.
HCUP's quality review statistics
All numeric data elements
Means, the number of missing and nonmissing values, the minimum and the maximum.
Continuous variables
For variables such as length of stay and charges: mean, median and extreme values.
Categorical data elements
Frequency distributions, for all categorical and some continuous data elements.
Closely related data elements
Cross frequencies, such as point of origin compared with admission type.
Data element arrays
The number of elements provided in the array, such as the diagnosis fields, and the frequency distribution of how many are filled.
HCUP's automated checks on each discharge record
HCUP applies these procedures to every discharge record. What it does with a value that fails is a cleaning question.
Validity
Numeric data must be numeric and fall within the legal values the data source documents and within standard norms: length of stay is not negative, and age in years is between 0 and 124, the maximum the Medicare Severity Diagnosis Related Group (MS-DRG) grouper allows. Diagnosis and procedure codes are checked against norms.
Internal consistency
Related data elements must agree. The admission date should come before the discharge date.
Consistency with norms
Values are compared with an established norm. A neonatal diagnosis should not appear with an age above zero years.
Longitudinal consistency
Distributions in the current data year are compared with the prior two data years. Distributions in the current quarter are compared with the latest available quarter and the same quarter of the prior year.
Hospital-level reporting
HCUP identifies new hospitals and hospitals not submitting data, and compares the volume of hospitals between years or quarters.
Screen numeric variables for outliers
The National Institute of Standards and Technology (NIST) e-Handbook of Statistical Methods defines an outlier as an observation that lies an abnormal distance from other values in a random sample from a population. The analyst decides what counts as abnormal, so normal observations must be described first.
Two activities describe a data set. Look at the overall shape of the graphed data, including symmetry and departures from assumptions. Then look for unusual observations far from the mass of the data. Scatter plots and box plots show them.
Box-plot fences
Q1 is the lower quartile (25th percentile) and Q3 the upper quartile (75th percentile). The interquartile range, IQ, is Q3 − Q1.
Inner fences
Lower: Q1 − 1.5 × IQ. Upper: Q3 + 1.5 × IQ. A point beyond an inner fence is a mild outlier.
Outer fences
Lower: Q1 − 3 × IQ. Upper: Q3 + 3 × IQ. A point beyond an outer fence is an extreme outlier.
Worked example
Fences on eleven lengths of stay
Eleven discharges in one diagnosis group had lengths of stay of 1, 2, 2, 3, 3, 4, 4, 5, 6, 14 and 30 days, already in order. Find the quartiles by NIST's rule, then the fences, and classify the two longest stays.
- 1
Quartiles
NIST takes the lower quartile as the 0.25 × (N + 1)th ordered value and the upper quartile as the 0.75 × (N + 1)th. With N = 11, those are the 3rd and 9th values: Q1 = 2 days and Q3 = 6 days.
- 2
Interquartile range
IQ = 6 − 2 = 4 days.
- 3
Inner fences
Lower: 2 − 1.5 × 4 = −4 days. Upper: 6 + 1.5 × 4 = 12 days.
- 4
Outer fences
Lower: 2 − 3 × 4 = −10 days. Upper: 6 + 3 × 4 = 18 days.
- 5
Classify
14 days is beyond the upper inner fence of 12 but not the outer fence of 18, so it is a mild outlier. 30 days is beyond 18, so it is an extreme outlier. No stay is below the lower fences.
Result: The 14-day stay is a mild outlier and the 30-day stay an extreme outlier. Both are flags to investigate.
Z-scores and modified z-scores
Z-score
- The z-score is (value − sample mean) ÷ sample standard deviation: how many standard deviations a value lies from the mean.
- It can mislead, especially in small samples, because the largest possible z-score is (n − 1) ÷ √n.
- With 9 values, no z-score can exceed 8 ÷ 3 = 2.67, so a rule that flags z-scores above 3 can never flag anything.
Modified z-score
- The modified z-score is 0.6745 × (value − median) ÷ MAD, where MAD is the median absolute deviation.
- Iglewicz and Hoaglin recommend labeling values with a modified z-score above 3.5 in absolute value as potential outliers.
Formal outlier tests
The tests NIST describes assume the data follow an approximately normal distribution. Check that first with a normal probability plot. Data that are approximately lognormal can be log-transformed and then tested.
Grubbs' test
For univariate data with an approximately normal distribution, the recommended test for a single outlier. Running it again after each outlier it finds is not appropriate, because masking by a second outlier can make the first test find none.
Tietjen-Moore test
For univariate data with an approximately normal distribution, it extends Grubbs' test to more than one outlier, but the number of outliers must be specified exactly.
Generalized extreme studentized deviate (ESD) test
For univariate data with an approximately normal distribution, it needs only an upper bound on the number of suspected outliers. It is the recommended test when the exact number is not known.
Try it
Pick the checks
A health system loads one year of outpatient visits from 12 clinics into a new analytics table. Name a check for each of these requirements: the visit type must be one of the allowed values; each visit's provider must exist in the provider table; each visit ID must appear once; and each clinic must keep sending its usual volume. For the last, say what you would compare.
Hint: Match each requirement to the OHDSI category it tests, then borrow HCUP's reporting check for the volumes.
Visit type: a value conformance check that counts rows whose visit type is not in the allowed list. Provider: a relational conformance check that counts visits whose provider ID has no record in the provider table. Visit ID: a uniqueness check that counts visit IDs appearing more than once. Volume: like HCUP's hospital-level reporting check, list clinics that are new or sent nothing, and compare each clinic's volume with earlier periods. Set a threshold for each of the first three and report the percentage of violating rows.