Tutorials › Biostatistics › Outlier Detection Methods in Clinical Datasets

Data Quality & Exploratory Analysis

Outlier Detection Methods in Clinical Datasets

A practical guide to identifying, investigating, and appropriately handling outliers in clinical data using graphical methods, IQR rules, z-scores, modified z-scores, robust statistics, clinical reference ranges, regression diagnostics, Mahalanobis distance, and reproducible R workflows.

Intermediate 15 min read

What You'll Learn

  • What an outlier is—and why a statistical outlier is not automatically a data error
  • How boxplots, histograms, scatterplots, and clinical ranges reveal unusual observations
  • How the IQR rule, z-scores, and modified z-scores identify extreme observations
  • Why robust methods are often preferable for skewed clinical variables
  • How multivariate and regression-based methods detect unusual observations
  • How to investigate and document outliers without automatically deleting them

Introduction

Clinical datasets frequently contain observations that look unusual. A laboratory measurement may be substantially higher than the rest of the sample, a body weight may be unexpectedly low, a biomarker concentration may be several orders of magnitude larger than most observations, or a patient may have a combination of measurements that is unusual even though none of the individual measurements is extreme.

These observations are commonly called outliers.

Outlier detection is an important part of exploratory data analysis and clinical data review. It can identify transcription errors, unit-conversion problems, data-processing defects, unusual patient characteristics, genuine treatment effects, or rare biological responses.

However, one of the most important principles in clinical statistics is: an outlier is not automatically an error.

Key idea: Outlier detection is primarily a process for identifying observations that deserve investigation. It is not, by itself, a justification for deleting observations from the analysis.

What Is an Outlier?

An outlier is an observation that is unusually distant from the main pattern of the data.

For a single continuous variable, an observation may be considered unusual because it is far from the center of the distribution.

For example, suppose systolic blood pressure is:

Patient Systolic BP
001118
002121
003125
004119
005123
006127
007121
008124
009122
010198

The value of 198 mmHg is obviously unusual relative to the other observations.

But there are several possible explanations:

  • The patient genuinely had severe hypertension.
  • The measurement was taken during an acute clinical event.
  • The value was transcribed incorrectly.
  • The value was entered in the wrong unit or field.
  • The observation may correspond to a different visit.
  • A data-processing transformation may have been applied incorrectly.

The statistical method identifies the observation as unusual. Clinical and data review determines what the observation actually means.

Outliers Are Context-Dependent

There is no universal numerical definition of an outlier.

An observation can be unusual in one context but completely appropriate in another.

For example, a creatinine value that is extreme relative to a healthy volunteer population may be entirely plausible in a population with advanced renal disease.

Likewise, a tumor measurement that is extreme at baseline may reflect genuine disease burden rather than an error.

Clinical principle: Statistical unusualness should be interpreted alongside treatment group, disease population, visit, laboratory reference range, measurement method, and other relevant clinical information.

Types of Outliers in Clinical Data

Outliers can arise in several different ways.

Type Description Example
Univariate outlier Extreme value for one variable Very high ALT
Multivariate outlier Unusual combination of otherwise plausible measurements Unusual combination of age, weight, and creatinine
Regression outlier Observation poorly predicted by a fitted model Unexpected treatment response
High-leverage observation Unusual predictor values Extremely high baseline biomarker
Influential observation Observation that materially changes model estimates One patient substantially changing a treatment effect estimate
Data-quality outlier Unusual value caused by a data problem Height entered as 1800 cm

Outlier Detection Is Not the Same as Data Cleaning

These concepts are related but different.

Outlier detection asks:

Which observations appear unusual?

Data cleaning asks:

Is the unusual observation incorrect, and if so, what should be done?

A statistical outlier can be:

  • Correct and clinically meaningful.
  • Correct but rare.
  • Incorrect because of a data-entry error.
  • Incorrect because of a unit error.
  • Incorrect because of a programming or derivation error.
  • Uncertain and requiring clarification.

The First Step: Visual Inspection

Before applying a formal statistical rule, inspect the data graphically.

Useful plots include:

  • Histograms
  • Boxplots
  • Dot plots
  • Scatterplots
  • Time-series plots
  • Spaghetti plots for repeated measurements
  • Subject-level profile plots

Graphical inspection is especially valuable because an algorithm can identify an extreme observation without showing why the observation is unusual.

1
Plot the variable. Look at its overall distribution.
2
Identify unusual observations. Look for isolated points or tails.
3
Check subject and visit. Determine whether the observation belongs to a specific patient or time point.
4
Review source data. Determine whether the value is plausible and correctly recorded.
5
Apply an appropriate statistical method. Use the method as an investigation tool, not as an automatic deletion rule.

Boxplots and the IQR Rule

The interquartile range, or IQR, is one of the most widely used approaches for identifying potential univariate outliers.

Define:

$$ IQR=Q_3-Q_1 $$

where \(Q_1\) is the first quartile and \(Q_3\) is the third quartile.

The conventional Tukey fences are:

$$ L=Q_1-1.5(IQR) $$
$$ U=Q_3+1.5(IQR) $$

Observations below \(L\) or above \(U\) are commonly flagged as potential outliers.

Worked IQR Example

Suppose a clinical chemistry variable has:

$$ Q_1=12 \qquad Q_3=20 $$

Then:

$$ IQR=20-12=8 $$

The lower fence is:

$$ 12-1.5(8)=0 $$

and the upper fence is:

$$ 20+1.5(8)=32 $$

Therefore, observations above 32 or below 0 would be flagged by the conventional 1.5-IQR rule.

Important: The IQR rule is a screening rule. An observation beyond a Tukey fence is not necessarily erroneous, clinically implausible, or inappropriate for analysis.

Why the IQR Method Is Useful

The IQR method has an important advantage: it is relatively robust to extreme observations.

The quartiles are much less affected by a few extreme values than the mean and standard deviation.

This makes the IQR rule particularly useful when clinical variables are skewed or contain a small number of very large observations.

Modified IQR Rules

Some analyses use more conservative or more liberal multipliers.

For example, the 3-IQR outer fence is:

$$ Q_3+3(IQR) $$

and similarly:

$$ Q_1-3(IQR) $$

The 1.5-IQR rule is generally useful for identifying potential outliers, while 3-IQR fences are sometimes used to identify more extreme observations.

Z-Scores

A z-score measures how far an observation is from the sample mean in standard deviation units.

$$ z_i=\frac{x_i-\bar{x}}{s} $$

where:

  • \(x_i\) is the observation.
  • \(\bar{x}\) is the sample mean.
  • \(s\) is the sample standard deviation.

A commonly used screening threshold is:

$$ |z_i|>3 $$

although the appropriate threshold depends on the purpose and distribution.

Worked Z-Score Example

Suppose a biomarker has:

$$ \bar{x}=100 \qquad s=15 $$

A patient has a value of 151.

The z-score is:

$$ z=\frac{151-100}{15} = \frac{51}{15} = 3.40 $$

The observation is therefore more than three standard deviations above the sample mean.

It would commonly be flagged for investigation.

A Major Problem with Ordinary Z-Scores

The mean and standard deviation themselves can be strongly affected by outliers.

Consider a dataset in which nearly all observations are around 100 but one observation is 1,000.

The extreme observation increases the standard deviation, which can make the z-score appear less extreme than it would have been without the observation.

This is one reason robust alternatives can be useful.

Modified Z-Scores

A modified z-score replaces the mean and standard deviation with robust quantities based on the median and median absolute deviation.

The median absolute deviation, or MAD, is:

$$ MAD= \operatorname{median} \left( |x_i-\operatorname{median}(x)| \right) $$

A commonly used modified z-score is:

$$ M_i= \frac{0.6745(x_i-\operatorname{median}(x))} {MAD} $$

A common screening criterion is:

$$ |M_i|>3.5 $$

The modified z-score is particularly useful when the dataset is contaminated by extreme observations.

IQR vs. Z-Score vs. Modified Z-Score

Method Center Scale Robust to Outliers?
IQR Quartiles IQR Yes
Z-score Mean SD No
Modified z-score Median MAD Yes

Clinical Reference Ranges

Statistical outlier rules should not replace clinical knowledge.

For laboratory measurements, reference ranges can provide an important independent source of information.

For example, suppose a laboratory test has an upper reference limit of 40 U/L. A value of 500 U/L is clinically notable regardless of whether it is flagged by a particular statistical rule.

However, reference ranges and statistical outlier thresholds answer different questions.

Question Method
Is the value unusual relative to this study population? Statistical outlier method
Is the value outside a laboratory reference interval? Clinical reference range
Is the value clinically dangerous? Clinical interpretation
Is the value a data error? Source-data / data-quality investigation

Outliers in Skewed Clinical Variables

Many clinical variables are not normally distributed.

Examples include:

  • Biomarker concentrations
  • Pharmacokinetic exposure measures
  • Hospital length of stay
  • Healthcare costs
  • Time-to-event variables
  • Some laboratory measurements

A right-skewed variable can naturally contain large observations.

For example, consider:

$$ 5,\;6,\;7,\;8,\;9,\;10,\;12,\;14,\;18,\;45 $$

The value 45 is much larger than the other observations, but it may be a legitimate feature of the distribution rather than a data error.

Do not confuse skewness with bad data. A long right tail may be an inherent characteristic of the biological or clinical measurement.

Log Transformation Can Help Reveal Structure

For strongly right-skewed positive variables, a logarithmic transformation may make the distribution easier to inspect.

For a positive measurement \(x\), define:

$$ y=\log(x) $$

An observation that looks extreme on the original scale may be much less unusual on the log scale.

This is especially relevant for pharmacokinetic variables and biomarkers that approximately follow log-normal distributions.

Do Not Delete Outliers Just to Improve Normality

A common statistical mistake is:

  1. Plot the data.
  2. Find a few extreme observations.
  3. Delete them.
  4. Observe that the distribution now looks more normal.

This approach can produce biased estimates and invalid inference.

The correct question is not: "Does removing the outlier make the distribution look better?"

The correct question is: "Is there a defensible scientific or data-quality reason for excluding this observation from this analysis?"

Outliers and Missing Data Are Different

An outlier is an observed value.

A missing value is an absence of an observed value.

These require different handling strategies.

Situation Example Primary Issue
Valid extreme value Very high biomarker Influence / distribution
Missing value No laboratory measurement Missing-data mechanism
Invalid value Impossible height Data quality
Below quantification limit BLQ concentration Censoring / measurement process

Outlier Detection by Treatment Group

In randomized clinical trials, distributions should often be inspected by treatment group.

A value that appears unusual in the overall population may be common within one treatment group.

Conversely, a treatment-specific cluster of unusual observations may indicate a real treatment effect or a treatment-related data issue.

Useful displays include:

  • Side-by-side boxplots
  • Group-specific histograms
  • Strip plots
  • Baseline-versus-postbaseline scatterplots
  • Individual patient profiles

Baseline and Postbaseline Values

For longitudinal clinical data, an observation should not always be evaluated without considering baseline.

Suppose a patient has:

Visit Biomarker
Baseline5
Week 26
Week 47
Week 842

The Week 8 value may be an outlier relative to the patient's earlier measurements.

But it may be much more clinically informative to examine the change from baseline than to classify the raw value as an outlier.

Longitudinal principle: For repeated clinical measurements, investigate unusual observations in both the cross-sectional distribution and the patient's longitudinal trajectory.

Outliers in Change-from-Baseline Analyses

Let:

$$ \Delta_i=X_{i,\text{post}}-X_{i,\text{baseline}} $$

A patient may not have an unusual baseline measurement but may have an extreme change from baseline.

For example:

$$ X_{\text{baseline}}=100 \qquad X_{\text{post}}=20 $$

gives:

$$ \Delta=-80 $$

Whether that is an outlier depends on the clinical context and the distribution of changes among the other patients.

Multivariate Outliers

Univariate methods examine one variable at a time.

But clinical observations are often multivariate.

A patient may have:

  • Age within the usual range
  • Weight within the usual range
  • Creatinine within the usual range
  • Blood pressure within the usual range

yet the combination of those variables may be unusual.

This is a multivariate outlier.

Mahalanobis Distance

Mahalanobis distance accounts for the covariance among variables.

For observation vector \(x\), mean vector \(\mu\), and covariance matrix \(\Sigma\), the squared Mahalanobis distance is:

$$ D^2 = (x-\mu)^\top \Sigma^{-1} (x-\mu) $$

Unlike ordinary Euclidean distance, Mahalanobis distance recognizes that variables can be correlated.

For example, weight and body-surface area are related. A patient who is large on both measures may not be unusual even though both individual measurements are relatively high.

Interpreting Mahalanobis Distance

Under multivariate normal assumptions, squared Mahalanobis distance can be compared approximately with a chi-square distribution with \(p\) degrees of freedom:

$$ D^2\approx\chi^2_p $$

where \(p\) is the number of variables.

For example, with four variables, a high \(D^2\) relative to a \(\chi^2_4\) reference distribution may identify a potentially unusual multivariate observation.

Caution: Classical Mahalanobis distance depends on estimates of the mean vector and covariance matrix, which can themselves be distorted by outliers. Robust covariance methods may be preferable when contamination is suspected.

Regression-Based Outlier Detection

Outlier detection becomes more sophisticated when the data are analyzed using a statistical model.

In linear regression:

$$ Y_i=\beta_0+\beta_1X_i+\epsilon_i $$

an observation can be unusual because its outcome is far from the fitted regression line.

Such an observation has a large residual.

Residuals

The ordinary residual is:

$$ e_i=y_i-\hat{y}_i $$

A large absolute residual indicates that the model predicts the observation poorly.

However, a large residual alone does not establish that the observation is incorrect.

The observation may represent a genuine biological response that the model does not adequately describe.

Studentized Residuals

Studentized residuals scale residuals by an estimate of their appropriate standard deviation.

A commonly used diagnostic is the externally studentized residual:

$$ t_i= \frac{e_i} {s_{(i)}\sqrt{1-h_{ii}}} $$

where \(h_{ii}\) is the leverage of observation \(i\) and \(s_{(i)}\) is a residual scale estimate calculated with the observation removed.

Large absolute studentized residuals can identify observations deserving further investigation.

Leverage

An observation can be unusual because its predictor values are far from those of the other observations.

This is called high leverage.

Leverage is represented by the diagonal elements of the hat matrix:

$$ H=X(X^\top X)^{-1}X^\top $$

The diagonal element \(h_{ii}\) describes how unusual observation \(i\)'s predictor pattern is relative to the rest of the dataset.

High leverage does not necessarily mean that the observation is influential.

Influence

An observation is influential if removing it substantially changes the fitted model.

One common diagnostic is Cook's distance:

$$ D_i= \frac{ \sum_{j=1}^{n} (\hat{y}_j-\hat{y}_{j(i)})^2 }{ p\,MSE } $$

where \(\hat{y}_{j(i)}\) represents the fitted value when observation \(i\) is omitted.

Large Cook's distance indicates that the observation deserves investigation.

Three concepts to distinguish: A large residual means the outcome is unusual relative to the model. High leverage means the predictors are unusual. High influence means the fitted model changes substantially when the observation is removed.

Outliers in Logistic Regression

Binary clinical endpoints require different diagnostics.

For logistic regression:

$$ \log\left( \frac{p_i}{1-p_i} \right) = \beta_0+\beta_1X_{i1}+\cdots+\beta_kX_{ik} $$

Potentially unusual observations can be identified using:

  • Pearson residuals
  • Deviance residuals
  • Leverage
  • Cook's distance
  • DFBETAs

Again, the purpose is to identify observations that warrant investigation, not to automatically remove them.

Outliers in Survival Analysis

Time-to-event data have their own complications.

An unusually long or short observed survival time is not automatically an outlier because censoring is part of the data-generating process.

For example, a patient who remains event-free throughout follow-up may have a long censored observation.

That observation should not simply be deleted because its time exceeds a statistical threshold.

Survival-analysis principle: Outlier concepts must account for censoring, risk sets, event indicators, and the estimand of interest. A simple IQR rule on observed follow-up times can be misleading.

Outliers in Pharmacokinetic Data

Pharmacokinetic datasets frequently contain highly variable concentration measurements.

Potentially unusual observations can arise from:

  • True biological variability
  • Sampling-time deviations
  • Incorrect sample collection time
  • Assay problems
  • Concentration transcription errors
  • Below-quantification-limit handling
  • Incorrect dose information
  • Incorrect units

A concentration that is unusually high should therefore be investigated using both statistical and pharmacokinetic information.

For example, compare the concentration with:

  • Dose
  • Sampling time
  • Previous concentrations
  • Subject-level PK profile
  • Other subjects at comparable sampling times

Clinical Plausibility Checks

Some of the most effective outlier detection methods are simple validation rules based on clinical knowledge.

Variable Potential Validation Check
Age Check plausible study-population range
Height Check physiologically plausible values and units
Weight Check implausible extremes and unit conversions
Heart rate Check physiological plausibility
Laboratory values Compare with assay/reference limits
Visit dates Check chronological consistency
Dose Check against protocol-defined dose levels

Outlier Detection Should Combine Multiple Signals

A strong clinical data-review process rarely relies on one statistical rule.

Instead, consider multiple sources of evidence:

A
Statistical signal: Does the observation exceed an outlier threshold?
B
Graphical signal: Does the observation look unusual in a plot?
C
Clinical signal: Is the value clinically plausible?
D
Data-quality signal: Is there evidence of a transcription, unit, or derivation error?
E
Model signal: Does the observation have unusual residual, leverage, or influence?

A Worked Clinical Example

Suppose 20 patients have a baseline laboratory measurement:

$$ 98,\;101,\;103,\;99,\;105,\;102,\;100,\;104,\;97,\;106, $$ $$ 101,\;103,\;99,\;102,\;104,\;100,\;98,\;107,\;101,\;185 $$

The final observation, 185, is visually suspicious.

The first question is not whether to delete it.

The first question is: Why is it 185?

Step 1: Apply the IQR Rule

Suppose the quartiles calculated from the data are approximately:

$$ Q_1=99 \qquad Q_3=104 $$

Then:

$$ IQR=104-99=5 $$

The upper Tukey fence is:

$$ 104+1.5(5)=111.5 $$

The value 185 is therefore clearly flagged.

Step 2: Calculate a Z-Score

Suppose the sample mean and standard deviation are:

$$ \bar{x}=104.05 \qquad s=19.0 $$

Then:

$$ z= \frac{185-104.05}{19.0} \approx4.26 $$

The observation is also extreme according to a conventional \(|z|>3\) screening threshold.

Step 3: Investigate the Patient

Now suppose the clinical data review shows that the patient's actual result was 105, but 185 was entered during transcription.

This is not a biological outlier.

It is a data error.

The appropriate action is therefore to correct the data according to the study's predefined data-management procedures.

A Different Outcome

Suppose instead that source documentation confirms that the patient's actual measurement was 185.

The observation is still an outlier statistically, but it may be completely valid.

In that case, the appropriate approach may be to retain it and evaluate its effect on the planned analysis.

Same statistical flag, different decision. The statistical method cannot distinguish a true biological extreme from a transcription error. That requires clinical and data-quality investigation.

Should an Outlier Be Removed?

There are several legitimate reasons an observation may be excluded from a specific analysis.

Examples include:

  • The value is demonstrably erroneous.
  • The value violates a prespecified data-quality rule.
  • The measurement was obtained outside the protocol-defined assessment window when the analysis requires a valid window.
  • The observation is invalid according to a predefined endpoint algorithm.

However, the following is generally not sufficient:

"The value makes the treatment effect statistically significant when it is included."

or:

"The value makes the distribution non-normal."

Sensitivity Analysis for Potential Outliers

When a valid observation has unusually large influence, a sensitivity analysis can be informative.

For example, an analysis might compare:

  • The prespecified primary analysis including all valid observations.
  • A sensitivity analysis excluding a particular observation under a clearly defined diagnostic criterion.
  • A robust analysis less sensitive to extreme observations.

The primary analysis should remain tied to the prespecified estimand and analysis population.

Robust Statistical Methods

Sometimes the correct response to extreme observations is not removal but the use of a method that is less sensitive to them.

Examples include:

  • Median instead of mean
  • IQR instead of standard deviation
  • Median regression
  • Robust regression
  • Trimmed means in appropriate settings
  • Transformation of highly skewed variables
  • Robust covariance estimation

The appropriate method depends on the scientific question and estimand.

Mean vs. Median in the Presence of an Outlier

Consider:

$$ 10,\;11,\;12,\;13,\;14,\;15,\;100 $$

The median is 13.

The mean is:

$$ \bar{x} = \frac{10+11+12+13+14+15+100}{7} = 25 $$

The extreme observation pulls the mean from the center of the majority of the data.

This illustrates why robust summaries can be useful during exploratory analysis.

Winsorization and Trimming

Winsorization replaces extreme values with less extreme values according to prespecified quantiles.

Trimming removes observations from the tails before calculating a summary.

These approaches can be useful in some statistical applications, but they should not be introduced simply because a clinical dataset contains inconvenient observations.

Clinical-trial caution: If trimming or winsorization is part of an analysis, it should be justified, prespecified where appropriate, and aligned with the estimand. It should not be used as an ad hoc mechanism for making a result more favorable.

Outlier Detection in Repeated-Measures Data

Repeated observations from the same patient create an additional challenge.

Suppose one patient's measurements are:

$$ 12,\;13,\;13,\;14,\;15,\;42 $$

The final value is unusual both relative to the patient and relative to the population.

But suppose another patient's values are:

$$ 30,\;31,\;32,\;34,\;38,\;42 $$

The final value is high but is consistent with that patient's trajectory.

This is why subject-level plots are extremely valuable for longitudinal clinical datasets.

Outliers and Mixed Models

In longitudinal analyses using mixed-effects models, unusual observations can affect estimated fixed effects, variance components, and subject-specific random effects.

For example:

$$ Y_{ij} = \beta_0+\beta_1Time_{ij}+b_i+\epsilon_{ij} $$

where \(b_i\) is a patient-specific random effect.

A potentially unusual observation should therefore be evaluated in the context of:

  • The patient's overall trajectory
  • Within-patient residuals
  • Between-patient variation
  • Influence on fixed effects
  • Influence on variance components

R: Basic IQR Outlier Detection

The following R code identifies observations beyond the conventional 1.5-IQR fences.

x <- c(
  98, 101, 103, 99, 105,
  102, 100, 104, 97, 106,
  101, 103, 99, 102, 104,
  100, 98, 107, 101, 185
)

q1 <- quantile(x, 0.25)
q3 <- quantile(x, 0.75)

iqr_value <- IQR(x)

lower_fence <- q1 - 1.5 * iqr_value
upper_fence <- q3 + 1.5 * iqr_value

outliers <- x[
  x < lower_fence |
  x > upper_fence
]

outliers

The resulting vector contains observations identified by the IQR screening rule.

R: Creating an Outlier Flag

outlier_flag <- x < lower_fence |
                x > upper_fence

data.frame(
  value = x,
  outlier = outlier_flag
)

This is often preferable to immediately removing observations because it preserves the original dataset while creating an explicit diagnostic variable.

R: Z-Scores

z_score <- as.numeric(
  scale(x)
)

z_flag <- abs(z_score) > 3

data.frame(
  value = x,
  z_score = z_score,
  outlier = z_flag
)

The threshold of 3 is a common screening convention, not a universal rule.

R: Modified Z-Scores

med_x <- median(x)

mad_x <- mad(
  x,
  constant = 1
)

modified_z <- 0.6745 *
  (x - med_x) / mad_x

modified_flag <- abs(modified_z) > 3.5

data.frame(
  value = x,
  modified_z = modified_z,
  outlier = modified_flag
)

The modified z-score is more resistant to the influence of extreme observations than the ordinary z-score.

R: Boxplot Detection

boxplot(x)

boxplot.stats(x)$out

The second expression returns observations classified as outliers according to the boxplot rule used by R.

R: Detecting Outliers Within Treatment Groups

Suppose the dataset contains:

df <- data.frame(
  USUBJID = c("01","02","03","04","05","06"),
  TRT = c("Drug A","Drug A","Drug A",
          "Placebo","Placebo","Placebo"),
  VALUE = c(101, 103, 150, 99, 102, 104)
)

An important question is whether the value of 150 is unusual relative to the entire study population or specifically within the Drug A group.

by(
  df$VALUE,
  df$TRT,
  function(z) {
    q1 <- quantile(z, 0.25)
    q3 <- quantile(z, 0.75)
    iqr_value <- IQR(z)

    c(
      lower = q1 - 1.5 * iqr_value,
      upper = q3 + 1.5 * iqr_value
    )
  }
)

For small clinical trial groups, however, automated group-specific outlier rules can be unstable.

Small-sample caution: Quartiles, standard deviations, and outlier thresholds can be unstable when treatment groups contain only a small number of patients. In such settings, graphical and clinical review may be more informative than mechanically applying a threshold.

R: Regression Diagnostics

Suppose we fit a simple linear model:

fit <- lm(
  outcome ~ baseline + treatment,
  data = df
)

summary(fit)

Basic diagnostic plots can be obtained with:

par(mfrow = c(2, 2))
plot(fit)

These plots can reveal:

  • Large residuals
  • Nonconstant variance
  • Potential leverage points
  • Potentially influential observations

R: Cook's Distance

cook_d <- cooks.distance(fit)

plot(
  cook_d,
  type = "h",
  ylab = "Cook's distance",
  xlab = "Observation"
)

abline(
  h = 4 / nrow(model.frame(fit)),
  lty = 2
)

The commonly used \(4/n\) reference is a heuristic rather than a universal cutoff.

R: Leverage

hat_values <- hatvalues(fit)

plot(
  hat_values,
  type = "h",
  ylab = "Leverage",
  xlab = "Observation"
)

High leverage observations should be investigated alongside their residuals and influence diagnostics.

R: Studentized Residuals

student_resid <- rstudent(fit)

plot(
  student_resid,
  type = "h",
  ylab = "Studentized residual",
  xlab = "Observation"
)

abline(h = c(-3, 3), lty = 2)

Large absolute studentized residuals can identify observations that are poorly described by the fitted model.

R: Mahalanobis Distance

Suppose three baseline variables are being examined jointly.

X <- df[, c(
  "age",
  "weight",
  "creatinine"
)]

center <- colMeans(
  X,
  na.rm = TRUE
)

cov_matrix <- cov(
  X,
  use = "complete.obs"
)

mahalanobis_distance <- mahalanobis(
  X,
  center = center,
  cov = cov_matrix
)

df$mahalanobis_d2 <-
  mahalanobis_distance

Under multivariate normal assumptions, the squared distances can be compared with a chi-square reference distribution.

cutoff <- qchisq(
  0.975,
  df = ncol(X)
)

df$multivariate_outlier <-
  df$mahalanobis_d2 > cutoff

For small datasets or datasets already suspected of containing outliers, robust covariance estimation should be considered rather than relying blindly on classical Mahalanobis distance.

Robust Outlier Detection

Robust methods attempt to reduce the effect of extreme observations on the location and scale estimates used to identify other unusual observations.

Examples include:

  • Median and MAD
  • Robust regression
  • Robust covariance matrices
  • Minimum covariance determinant approaches
  • Other high-breakdown estimators

These methods can be particularly useful when the assumption that most of the data come from a clean approximately normal distribution is questionable.

Multiple Testing and Outlier Detection

Clinical datasets can contain hundreds or thousands of variables.

If an automated outlier rule is applied to every variable, some observations will be flagged simply by chance.

For example, if many independent variables are examined using a criterion that flags approximately 1% of observations under the null, numerous flags may occur even when the dataset contains no systematic errors.

Important: The number of statistical flags should be interpreted relative to the number of variables, patients, visits, and comparisons being screened.

Outlier Detection in Large Clinical Databases

Large clinical datasets require additional considerations.

An automated pipeline may need to process:

  • Hundreds of laboratory variables
  • Thousands of subjects
  • Multiple visits
  • Multiple treatment groups
  • Multiple analysis populations

In such settings, outlier detection is best implemented as a reproducible quality-control process rather than an ad hoc manual review.

A Reproducible Outlier Flagging Framework

1
Define the variables. Specify which continuous or categorical variables will be screened.
2
Define the population. Specify treatment, visit, safety population, FAS, ITT, or other relevant population.
3
Run statistical screening. Apply appropriate rules such as IQR or robust z-scores.
4
Generate diagnostic plots. Produce reproducible visualizations.
5
Cross-check clinical information. Compare against reference ranges, visit timing, dose, and subject history.
6
Investigate data quality. Determine whether the observation is a transcription, unit, timing, or derivation problem.
7
Document the conclusion. Record whether the value is valid, corrected, excluded, or retained.
8
Assess analytical impact. If appropriate, evaluate sensitivity to influential observations.

What an Outlier Review Dataset Should Contain

For clinical programming, an outlier review dataset can be structured to contain both the original value and diagnostic information.

Variable Purpose
USUBJID Patient identifier
VISIT Assessment visit
PARAMCD Parameter identifier
AVAL Original analysis value
FLAG_IQR IQR screening flag
FLAG_Z Z-score screening flag
FLAG_MODZ Modified z-score flag
CLINICAL_FLAG Clinical plausibility flag
REVIEW_STATUS Outcome of investigation
REVIEW_REASON Documented reason for decision

Potential Review Statuses

A standardized classification system can make the review process reproducible.

Status Meaning
Valid extreme Unusual but confirmed to be correct
Data error Incorrect source or entered value
Unit error Incorrect unit or conversion
Derivation error Incorrect calculated value
Protocol deviation Value affected by a relevant protocol issue
Pending review Investigation incomplete

Outlier Detection vs. Data Validation

These processes should work together.

Data validation rules can identify observations that violate known constraints.

Statistical outlier detection can identify observations that are unusual even when they do not violate any explicit constraint.

For example, a height of 1800 cm is easily identified through a validation rule.

A height of 205 cm may be statistically unusual but clinically plausible.

The first is likely a data-quality issue. The second may simply represent a tall patient.

Clinical Outliers vs. Statistical Outliers

Observation Statistical Status Clinical Status
Very high but plausible lab value Outlier Potentially valid
Impossible measurement Outlier Invalid
Common value in disease population Not necessarily an outlier Clinically important
Rare but documented adverse event Potential outlier Potentially meaningful

Outliers and the Analysis Population

Outlier status can depend on the analysis population.

For example, a value may appear unusual among all randomized patients but not within the treated population.

Likewise, an observation may be extreme at one visit but ordinary at another.

Therefore, the population and grouping used for outlier detection should be defined carefully.

Should Outliers Be Removed Before Summary Statistics?

Generally, not automatically.

If an observation is valid, descriptive statistics should generally reflect the observed data unless the analysis specification defines a different estimand or summary.

For skewed data, it may be appropriate to report both mean and median, or additional robust summaries such as quartiles.

Summary Useful Information
Mean Arithmetic average; sensitive to extremes
Median Central location; robust to extremes
SD Overall dispersion; sensitive to extremes
IQR Middle 50% spread; robust
Minimum / maximum Shows observed range

Outliers in Clinical Trial Tables

Outliers can affect common clinical-trial outputs such as:

  • Baseline descriptive statistics
  • Change-from-baseline summaries
  • Laboratory shift tables
  • Boxplots
  • Scatterplots
  • Regression analyses
  • Pharmacokinetic summaries
  • Exposure-response analyses

A value should not be silently removed from one table while remaining in another unless the difference is explicitly defined by the analysis.

Traceability Is Essential

When an outlier is corrected or excluded, the change should be traceable.

A reproducible workflow should make it possible to answer:

  • What was the original value?
  • Why was it flagged?
  • Who reviewed it?
  • What evidence supported the decision?
  • What value was ultimately used?
  • Which analyses were affected?
Clinical-programming principle: Never overwrite the original observation simply because it was identified as an outlier. Preserve the original data and document any subsequent correction or analysis decision.

Common Mistakes

  1. Deleting every observation beyond 1.5 IQR. The IQR rule identifies potential outliers; it does not establish that they are errors.
  2. Using z-scores blindly for skewed variables. Mean and SD can be distorted by extreme observations and may be inappropriate for heavily skewed data.
  3. Ignoring clinical context. A statistically unusual laboratory result may be biologically plausible.
  4. Checking only the overall dataset. Treatment group, visit, disease severity, and patient trajectory can materially change interpretation.
  5. Ignoring multivariate relationships. An observation can be unusual because of a combination of variables even when each individual measurement looks normal.
  6. Confusing leverage with an outlier. A high-leverage observation is unusual in predictor space; it is not necessarily a response outlier.
  7. Using Cook's distance as an automatic deletion rule. Influence diagnostics identify observations that affect the model; they do not determine whether those observations are invalid.
  8. Removing observations after looking at the treatment effect. This can introduce serious bias.
  9. Failing to document decisions. Outlier handling should be reproducible and traceable.
  10. Using an arbitrary threshold without justification. Thresholds such as 3 SD or 1.5 IQR are conventions, not universal laws.

A Practical Outlier Detection Strategy

1
Start with the raw data and understand the clinical variable.
2
Review units, allowable ranges, visit structure, and coding.
3
Create histograms, boxplots, and subject-level plots.
4
Use IQR or robust methods for univariate screening.
5
Use z-scores cautiously when distributional assumptions are appropriate.
6
Use multivariate diagnostics when combinations of variables matter.
7
For modeled endpoints, evaluate residuals, leverage, and influence.
8
Investigate every important flag using clinical and source-data information.
9
Correct confirmed data errors through the appropriate data-management process.
10
Retain valid extreme observations unless a prespecified analysis rule says otherwise.
11
Perform sensitivity analyses when influential observations materially affect conclusions.
12
Document the complete decision trail.

Choosing the Right Method

Situation Useful Approach
Simple continuous variable Boxplot / IQR
Approximately symmetric variable Z-scores
Skewed variable IQR or modified z-score
Strongly skewed positive variable Log-scale inspection + robust methods
Several correlated variables Mahalanobis / robust multivariate methods
Linear regression Residuals, leverage, Cook's distance, DFBETAs
Logistic regression Residuals, leverage, influence diagnostics
Longitudinal data Subject-level trajectories + model diagnostics
Time-to-event data Survival-specific diagnostics
Laboratory data Statistical + clinical reference ranges

A Layered Approach Works Best

The strongest clinical data-review strategy is usually layered.

Instead of asking which single outlier method is best, ask which combination of methods provides the most useful evidence.

A
Data validation: identify impossible or inconsistent values.
B
Clinical review: determine whether unusual values are plausible.
C
Univariate statistics: identify extreme observations.
D
Multivariate diagnostics: identify unusual combinations.
E
Model diagnostics: identify observations with unusual residuals or influence.
F
Sensitivity analysis: determine whether conclusions depend materially on valid extreme observations.

What Should Be Reported?

If outlier detection materially affects a clinical analysis, the statistical documentation should describe:

  • Which variables were screened
  • Which analysis population was used
  • Whether screening was performed overall or by treatment and visit
  • The statistical criteria used
  • How clinically important observations were investigated
  • How confirmed data errors were corrected
  • How valid extreme observations were handled
  • Any sensitivity analyses performed
  • The impact of influential observations on key conclusions

Example Statistical Analysis Plan Language

A practical analysis-plan description might state that continuous variables will be reviewed using graphical and descriptive methods, with potentially unusual observations identified using prespecified diagnostic criteria where appropriate.

Potential outliers will be investigated for data quality and clinical plausibility. Valid observations will not be excluded solely because they are statistically extreme. Any exclusions from the primary analysis will follow the prespecified analysis population and endpoint definitions.

Where an observation has substantial influence on a model-based analysis, appropriate sensitivity analyses may be performed to evaluate robustness of the conclusions.

Outliers and Regulatory Review

In a regulated clinical-trial environment, unexplained changes to patient data can create traceability and data-integrity concerns.

Therefore, the safest general principle is: investigate first, document second, and modify or exclude only under a defensible predefined process.

The statistical programming dataset should preserve traceability to the underlying source and derivation process.

Outlier Detection Checklist

Question Check
Is the value statistically unusual? IQR, robust z-score, or appropriate diagnostic
Is the value clinically plausible? Clinical review / reference range
Is the unit correct? Unit validation
Is the visit correct? Visit and date review
Is the subject trajectory unusual? Longitudinal plot
Is the combination of variables unusual? Multivariate diagnostics
Does the observation affect a model? Residuals / leverage / influence
Is the value erroneous? Source-data investigation
Should it be excluded? Apply prespecified analysis rules
Can the decision be reproduced? Document the reason and retain traceability

The Most Important Distinction

The most important distinction in outlier analysis is between:

statistical unusualness

and:

data invalidity.

These are not the same thing.

A value can be:

  • Statistically extreme and valid.
  • Statistically ordinary and incorrect.
  • Statistically extreme and incorrect.
  • Statistically ordinary and valid.

Statistical methods are therefore best viewed as screening tools within a broader clinical data-review process.

Summary of Major Methods

Method Best Use Main Limitation
IQR / Tukey fences General univariate screening Can flag legitimate tail observations
Z-score Approximately symmetric variables Sensitive to mean and SD distortion
Modified z-score Robust univariate screening Still requires interpretation
Boxplot Visual distribution review Not a formal data-validity test
Mahalanobis distance Multivariate unusualness Classical version sensitive to contamination
Studentized residuals Regression outliers Model-dependent
Leverage Unusual predictor patterns Not necessarily influential
Cook's distance Influential observations Does not establish data invalidity
Clinical reference ranges Clinical plausibility Not a statistical outlier definition

Key Takeaways

Bottom line: Outlier detection in clinical datasets is an investigative process, not an automatic data-deletion procedure. The IQR rule, z-scores, modified z-scores, boxplots, Mahalanobis distance, residual diagnostics, leverage, and influence measures can identify observations that deserve attention. The appropriate method depends on the distribution, endpoint, model, and clinical context. Once an observation is flagged, investigators should determine whether it is a genuine biological extreme, a clinically meaningful event, a measurement problem, or a data-processing error. Valid extreme observations should generally remain in the analysis unless a prespecified analysis rule provides another basis for exclusion.

References

Tukey, J.W. (1977). Exploratory Data Analysis. Addison-Wesley.
Rousseeuw, P.J. & Leroy, A.M. (1987). Robust Regression and Outlier Detection. Wiley.
Hubert, M. & Van der Veeken, S. (2008). Outlier detection for skewed data. Journal of Chemometrics, 22, 235–246.
Cook, R.D. (1977). Detection of influential observation in linear regression. Technometrics, 19(1), 15–18.
Mahalanobis, P.C. (1936). On the generalized distance in statistics. Proceedings of the National Institute of Sciences of India, 2, 49–55.
Barnett, V. & Lewis, T. (1994). Outliers in Statistical Data. Wiley.
Fox, J. & Weisberg, S. (2019). An R Companion to Applied Regression. SAGE Publications.
Chambers, J.M. (1992). Linear models. In Statistical Models in S. Wadsworth & Brooks/Cole.