Part 2 · Module 5

Exploratory Data Analysis

Learn how to explore medical data systematically using summaries and graphs while separating data discovery from prespecified confirmatory analysis.

Learning outcomes

After completing this lecture, you should be able to:

  • Explain the purpose of exploratory data analysis and distinguish it from confirmatory analysis.
  • Use a structured sequence to examine data structure, completeness, distributions, relationships and time patterns.
  • Select suitable numerical summaries and graphical displays for categorical and numerical variables.
  • Identify skewness, unusual observations, non-linearity, clustering and possible data-quality problems.
  • Document exploratory findings without converting data-driven discoveries into prespecified hypotheses.
  • Explain how exploratory findings inform, but do not automatically determine, the final statistical model.

Overview

Exploratory data analysis, abbreviated EDA, is the systematic examination of a dataset using summaries and visual displays before or alongside formal modelling. Its purpose is to understand what was collected, identify data problems, reveal patterns, assess modelling assumptions and generate questions for further investigation.

EDA is not a single statistical test. It is a reasoning process.

A good exploration asks:

  • What does each row and variable represent?
  • Which values are missing?
  • How are categorical variables distributed?
  • What is the shape and spread of numerical variables?
  • Are there unusual observations?
  • How do variables relate to one another?
  • Are there patterns by treatment group, clinic, time or participant?
  • Do the data support the planned model?

The term was developed and popularised by John Tukey, who emphasised learning from data through flexible graphical and numerical methods [1].

Why this matters

Two datasets can have the same mean, standard deviation, correlation and fitted regression line while showing very different patterns. Anscombe demonstrated this using four small datasets that share nearly identical conventional summaries but contain linear, curved, outlying and high-leverage structures [2].

Relying only on a summary table can therefore conceal:

  • skewed distributions;
  • floor or ceiling effects;
  • non-linear relationships;
  • clusters;
  • data-entry errors;
  • influential observations;
  • unequal follow-up;
  • site differences; and
  • missing-data patterns.

EDA helps investigators detect these features before the final interpretation. A structured EDA combines data-quality checks, numerical summaries and graphics rather than relying on one isolated procedure [3]. However, unrestricted exploration can also encourage selective reporting. Patterns discovered after looking at the data should be labelled exploratory and confirmed in new data when possible.

Exploratory and confirmatory analysis

Exploratory analysis

Exploratory analysis is flexible and discovery-oriented. It can:

  • identify unexpected patterns;
  • suggest transformations or non-linear terms;
  • reveal problematic measurements;
  • generate hypotheses;
  • guide sensitivity analyses; and
  • improve understanding of the data-generating process.

Confirmatory analysis

Confirmatory analysis evaluates a prespecified question using an analysis chosen before the relevant results are known. It requires a defined estimand, model, assumptions and error-control strategy.

Exploratory findings are not invalid, but they have a different evidential status. If a subgroup appears to benefit after many subgroups are examined, that finding is more vulnerable to chance and should not be presented as though it had been prespecified.

A structured sequence for EDA

1. Confirm the data structure

Start with:

  • number of files;
  • number of rows and columns;
  • observational unit in each table;
  • unique identifiers;
  • repeated measurements;
  • duplicate keys;
  • variable types; and
  • expected sample size.

A participant-level dataset with 241 rows in a 240-participant trial requires investigation before any graph is interpreted. Consistent rectangular organisation makes these structural checks easier to reproduce [4].

2. Review the data dictionary

Check whether:

  • variable labels match the data;
  • units are explicit;
  • category codes are valid;
  • dates use the intended format;
  • structural missingness is distinguished from absent data; and
  • derived variables follow the protocol rules.

EDA should not guess the meaning of an undocumented code.

3. Examine missingness

For each important variable, report:

  • observed number;
  • missing number and percentage;
  • denominator;
  • missingness by group, clinic and time; and
  • common missingness patterns.

A missing-data heat map or pattern table can show which variables are absent together. Missingness is developed in BIO-P02-M03.

4. Explore categorical variables

Use frequency tables and bar charts to examine:

  • category distribution;
  • unexpected codes;
  • rare levels;
  • empty categories;
  • imbalanced groups; and
  • percentages with correct denominators.

A pie chart is usually less effective when precise category comparison is important or categories are numerous.

5. Explore numerical variables

Useful summaries include:

  • minimum and maximum;
  • mean and standard deviation;
  • median and interquartile range;
  • selected percentiles;
  • number of distinct values; and
  • frequency of zero or boundary values.

Useful graphs include:

  • dot plots;
  • histograms;
  • density plots;
  • box plots;
  • violin plots when distribution shape matters; and
  • empirical cumulative distribution plots.

Do not choose mean or median solely from a formal normality-test p-value. The summary should match the clinical question, scale, distribution and influence of unusual observations [5].

6. Explore relationships

For two numerical variables, begin with a scatter plot. Look for:

  • direction;
  • strength;
  • non-linearity;
  • clusters;
  • changing spread;
  • ceiling or floor effects; and
  • influential observations.

Correlation alone may conceal these features and does not establish agreement or causation.

For a numerical variable across categories, use individual points, box plots or distribution displays. For two categorical variables, use a contingency table and a proportion display.

7. Explore time and repeated measurements

Repeated data require plots that preserve participant and time structure.

Possible displays include:

  • individual trajectories;
  • group mean or median trajectories;
  • distributions at each visit;
  • numbers observed at each time; and
  • event or missingness patterns over time.

Do not treat repeated observations from one participant as independent points in an ordinary group comparison.

8. Explore by site and data source

Multicentre studies should inspect:

  • sample size by site;
  • category distributions;
  • measurement ranges;
  • missingness;
  • visit timing; and
  • outcome distributions.

A site difference may reflect patient mix, measurement procedure, device calibration or data-processing error. It is not automatically a biological finding.

Data structure

Simulated EDA inventory

simulated data

Table 1. Dataset inventory

TableObservational unitRowsKey
ParticipantOne randomised participant240participant_id
Clinic visitsOne participant-visit918participant_id + visit_week
Home readingsOne device reading18,420participant_id + reading_datetime
Medication changesOne medication-change event166participant_id + event_id
Adverse eventsOne adverse event72participant_id + adverse_event_id

Note: Different observational units are stored separately and linked using participant identifiers.

Table 2. Selected variable completeness

VariableObservedMissingPercentage missing
Baseline systolic blood pressure24000.0%
Week-4 systolic blood pressure23283.3%
Week-12 systolic blood pressure226145.8%
Medication-change status23820.8%
Treatment-burden score2103012.5%

Note: Structural non-applicability is not counted as missing.

(The missing percentages are calculated from the observed and missing counts shown in the table.)

What the trial EDA reveals

Baseline systolic blood pressure

Baseline systolic blood pressure is broadly unimodal, meaning it has one main concentration, but includes a verified value of 238 mmHg. The mean and standard deviation are reported with the median and interquartile range to show the effect of the extreme value.

Week-12 outcome

Observed week-12 values show:

  • a lower centre in the telemonitoring group;
  • similar overall spread;
  • no severe floor or ceiling effect;
  • one high residual value; and
  • slightly greater variance in usual care.

These observations support the planned adjusted linear model but motivate a sensitivity analysis using heteroscedasticity-robust standard errors.

Relationship with baseline

A scatter plot of week-12 against baseline systolic blood pressure shows a positive, approximately linear relationship over most of the range.

The verified baseline value of 238 mmHg has high leverage. Influence assessment is reported separately rather than deleting the participant.

Clinic differences

One clinic has:

  • fewer participants;
  • higher week-12 missingness;
  • slightly later visit timing; and
  • no obvious shift in measured blood pressure among attenders.

This pattern prompts an operational review and reinforces inclusion of clinic in the imputation and analysis models. It does not prove that clinic caused missingness.

Home readings

Home blood-pressure counts differ substantially because participants vary in adherence and monitoring duration. Treating every reading as an independent participant would be incorrect.

For descriptive exploration, the team examines:

  • readings per participant;
  • participant-level weekly means;
  • within-person variability; and
  • group trajectories over time.

Worked example

EDA under blinding and in observational research MMed extension

In randomised trials, treatment-group EDA performed before the analysis plan is finalised may reveal comparative outcomes and influence decisions.

Possible safeguards include:

  • completing the SAP before unblinding;
  • using masked treatment labels;
  • conducting pooled or blinded data review;
  • restricting unblinded access; and
  • documenting every post-unblinding change.

In observational studies, treatment or exposure cannot always be masked meaningfully. Analysts should prespecify the causal question and adjustment strategy, then use EDA to assess measurement, overlap, model form and data support without choosing the model solely for favourable results.

Recording the exploration

A reproducible EDA report should include:

  • dataset version;
  • code version;
  • date;
  • row and variable counts;
  • data-quality flags;
  • missingness summaries;
  • distributions;
  • subgroup and site displays;
  • relationship plots;
  • model-relevant findings;
  • decisions made; and
  • unresolved issues.

Repeatedly copying graphs into slide decks without the generating code weakens reproducibility.

Common mistakes

Knowledge check

Why should a scatter plot accompany a correlation coefficient?

Answer and reasoning

Different patterns can produce similar correlations. A scatter plot can reveal non-linearity, clusters, changing spread, outliers and high-leverage points that the coefficient alone conceals.

What should be examined before plotting clinical outcomes?

Answer and reasoning

The analyst should confirm the observational unit, keys, variable definitions, units, category codes, duplicates and missingness. A polished graph cannot compensate for misunderstood structure.

Does an exploratory subgroup difference establish effect modification?

Answer and reasoning

No. It may generate a hypothesis, but data-driven subgroup findings are vulnerable to chance and selective reporting. Effect modification should be evaluated using appropriate interaction estimates, confidence intervals and preferably independent confirmation.

Why should home blood-pressure readings not be treated as thousands of independent participants?

Answer and reasoning

Multiple readings come from the same participant and are correlated. The unit and repeated structure must be preserved in summaries and models.

What is the appropriate response when EDA reveals one clinic with high missingness?

Answer and reasoning

Verify the data and study process, report the pattern, investigate operational causes and ensure the missing-data analysis accounts for relevant observed clinic information. The pattern does not by itself prove a missingness mechanism.

Key take-home messages

References

  1. Tukey JW. Exploratory data analysis. Reading (MA): Addison-Wesley; 1977.
  2. Anscombe FJ. Graphs in statistical analysis. Am Stat. 1973;27(1):17–21. https://doi.org/10.1080/00031305.1973.10478966
  3. Behrens JT. Principles and procedures of exploratory data analysis. Psychol Methods. 1997;2(2):131–160. https://doi.org/10.1037/1082-989X.2.2.131
  4. Wickham H. Tidy data. J Stat Softw. 2014;59(10):1–23. https://doi.org/10.18637/jss.v059.i10
  5. Altman DG. Practical statistics for medical research. London: Chapman and Hall; 1991.

These notes support learning and research planning and do not replace statistical consultation for a specific study.

Report an error in this lecture