# Missing value imputation for electronic health records

Learn why electronic health records have gaps, how simple and model-based imputation methods differ, and how to choose and check a method for clinical data.

Missing value imputation for electronic health records replaces gaps in clinical data with estimated values. The right method depends on why values are missing and what the analysis must answer. Simple fills, model-based methods and time-aware approaches each suit different gaps in patient records. 

- Find out why each value is missing before you pick an imputation method.
- Mean or median fills are quick but shrink variation and can bias results.
- Multiple imputation keeps uncertainty visible by creating several completed datasets and pooling the results.
- Time-ordered clinical measurements need methods that respect the sequence of patient visits.
- Test any method by hiding known values and checking how well it recovers them.
 

## Why clinical data in health records has gaps 

Electronic health records have missing values because they are built for patient care, not for research. A clinician orders a test only when the patient's condition calls for it. Many fields therefore stay empty for patients who never needed that measurement. 

Gaps in clinical data also come from workflow and system issues. Free-text notes may hold a value that never reaches a structured field. Records from different clinics or software systems may use separate codes for the same item. Data can also drop out when a patient moves between care providers. 

The pattern of missing data in health records often carries clinical meaning. An absent lab result may signal that a doctor saw no reason to order it. Treating that gap as random can hide real information about patient health. Health data imputation therefore starts with understanding the care process behind each field. 

## Three types of missingness to identify first 

Statisticians sort missing data into three types, and each type points to different imputation methods. Missing completely at random, or MCAR, means the gap has no link to any data. A lost sample from a broken lab tube is a typical example. Under MCAR, simple methods introduce less bias, though they still waste information. 

Missing at random, or MAR, means the gap depends on other recorded values. Older patients might get a test more often, for example, and age is in the record. Model-based methods can use those recorded values to estimate what is missing. Multiple imputation and regression methods rely on the MAR assumption for unbiased estimates. 

Missing not at random, or MNAR, means the gap depends on the missing value itself. A patient with very high blood sugar might skip a follow-up visit. No standard imputation method fully corrects MNAR data without extra assumptions. Sensitivity analysis, which tests how results change under different assumptions, helps show the risk. 

## Simple imputation methods and their limits 

Simple imputation methods fill each gap with one fixed value drawn from the observed data. Mean or median imputation uses the average or middle value of a variable. Mode imputation does the same for categories, such as smoking status. These fills are fast and easy to explain to clinical teams. 

Single-value fills distort clinical data in ways that matter for analysis. Every filled patient gets the same value, so the spread of the variable shrinks. Links between variables also weaken, because the fill ignores everything else about the patient. Confidence intervals then look narrower than the data can support. 

Complete case analysis, which drops any record with a gap, is the other simple option. Dropping records can remove a large share of patients from electronic health records. The remaining patients may also differ from the full group in health status. Results then describe a narrower population than the analysis intended. 

## Model-based and multiple imputation methods 

Regression imputation predicts each missing value from the other variables recorded for that patient. A model trained on complete records estimates, for instance, a missing weight from height and age. Predictions keep relationships between variables better than a mean fill does. Single regression fills still understate uncertainty, because every estimate looks exact. 

Multiple imputation creates several completed datasets, each with slightly different plausible values for the gaps. The analysis runs on every dataset, and the results are pooled into one answer. Pooling reflects the uncertainty that comes from not knowing the true values. MICE, short for multiple imputation by chained equations, models each variable in turn from the others. 

Machine learning methods can capture nonlinear patterns in health data imputation. K-nearest neighbors fills a gap using values from patients with similar recorded features. Random forest imputation, such as the missForest approach, builds tree models for each incomplete variable. These methods handle mixed numeric and categorical data but need careful tuning on large records. 

## Time-aware methods for repeated measurements 

Repeated measurements in electronic health records need imputation methods that respect time order. Vital signs and lab results form sequences with irregular gaps between readings. Ignoring the order treats a value from months ago like one from yesterday. Time-aware methods use the timing of each reading as part of the estimate. 

Last observation carried forward, or LOCF, repeats the latest known value until a new one appears. The approach is simple but assumes the patient's condition stayed the same. Linear interpolation instead draws a straight line between two known readings. Interpolation suits slowly changing values better than sudden clinical events. 

Deep learning models can learn patterns of missingness directly from long clinical time series. Recurrent networks such as GRU-D, a gated recurrent unit with decay, use the time since the last reading. Autoencoders, which learn to rebuild data from compressed patterns, can also fill gaps. Such models need large datasets, and their inputs must exclude information from later time points. 

## Comparing imputation methods side by side 

Comparing imputation methods side by side makes the trade-offs in clinical data easier to see. Each method balances speed, bias, handling of uncertainty and the skills needed to run it. A short table of candidate methods keeps those trade-offs visible for the whole team. 

The question the analysis answers should narrow the list of imputation methods first. Estimating a treatment effect calls for methods that keep uncertainty, such as multiple imputation. Building a prediction model may favor methods that run the same way on new patients. Descriptive reports may accept simpler fills if the gaps are small and random. 

Practical limits also shape which health data imputation method fits a project. Large records with many variables can make chained equations slow to run. Small datasets give deep learning models too little to learn from. Clinical staff should be able to follow the logic of whatever method ends up in use. 
| Method | How it fills gaps | Strength | Main limitation | 
| Mean or median | One average value per variable | Fast and transparent | Shrinks variation and weakens links | 
| Complete case analysis | Drops incomplete records | No modeling needed | Loses patients and may bias results | 
| Regression | Predicts from other variables | Keeps variable relationships | Understates uncertainty | 
| Multiple imputation (MICE) | Several plausible datasets, pooled | Reflects uncertainty | Slower and needs careful model setup | 
| K-nearest neighbors | Values from similar patients | Handles mixed data types | Sensitive to distance choice and scaling | 
| LOCF or interpolation | Uses neighboring time points | Respects time order | Assumes stable or smooth change | 
| Deep learning | Learns patterns from sequences | Captures complex patterns | Needs large data and is hard to explain |  

## How to check whether imputation worked 

Imputation quality can be checked by hiding values you already know and filling them again. The masked values are then compared with the true ones using an error measure. Root mean squared error, a measure of the typical size of errors, suits numeric variables. Masking should copy the real pattern of gaps rather than removing values at random. 

Recovery error alone does not show whether imputed clinical data supports sound conclusions. Distributions of imputed and observed values should be compared with plots or summary statistics. Downstream checks run the final analysis or model with each method and compare results. Large differences between methods point to results that depend on the imputation choice. 

Prediction projects need extra care to avoid data leakage during imputation. Leakage happens when the imputation model learns from test patients or future measurements. Fitting the imputation step on training data only keeps the evaluation honest. Clinical reviewers can also flag imputed values that look implausible for real patients. 

- Record the share of missing values for each variable
- Mask known values in a pattern that mirrors real gaps
- Measure recovery error for each candidate method
- Compare imputed and observed distributions
- Fit the imputation step on training data only
- Run a sensitivity analysis for possible MNAR gaps
 

## Missingness indicators and transparent reporting 

A missingness indicator is an extra yes-or-no variable that marks whether a value was imputed. Indicators let a model learn from the fact that a test was not ordered. Clinical prediction models can gain useful signal from these flags. Indicators can also reflect local ordering habits that differ between hospitals. 

Transparent reporting of health data imputation helps others judge and repeat the work. A report should name the method, the variables imputed and the assumed type of missingness. The share of missing values for each variable belongs in the report as well. Sensitivity results show readers how much conclusions depend on the chosen method. 

Imputed values are statistical estimates and do not belong in the chart as patient measurements. Analysts should keep imputed data separate from the source record and label it clearly. Decisions about an individual patient rest with clinicians who can order the missing test. 

## Questions about imputing health record data 

### Which imputation method should I use for electronic health records? 

No single imputation method fits every electronic health record dataset. Multiple imputation suits many analyses when data is missing at random. Time series need time-aware methods, and prediction models need imputation fitted on training data only. 

### Is mean imputation acceptable for clinical data? 

Mean imputation is acceptable for clinical data only when gaps are few and likely random. The method shrinks the spread of values and weakens relationships between variables. For effect estimates, multiple imputation or regression-based methods give a more honest picture. 

### Can I tell whether health data is missing at random? 

No, observed data alone cannot prove that health record values are missing at random. Little's test, a statistical check, can assess the MCAR assumption but cannot separate MAR from MNAR. Clinical knowledge of how values were recorded, plus sensitivity analysis, guides the judgment. 

### How many imputed datasets does multiple imputation need? 

The number of imputed datasets depends on the amount of missing data and the precision needed. More missing data generally calls for more datasets to keep pooled results stable. Checking whether results change when you add datasets shows whether you have enough. 

### Should I add missingness indicators to a prediction model? 

Yes, missingness indicators often help prediction models built on electronic health records. The flags capture information carried by whether a test was ordered. Indicators can reduce portability, because ordering habits differ between care settings. 

### Does deep learning outperform statistical imputation for clinical time series? 

Not always, because deep learning imputation needs large datasets to learn reliable patterns. Statistical methods such as MICE remain easier to explain and check on smaller data. Comparing both on masked values from your own records shows which fits the project.
