Biostatistics · Intermediate

Exploring Two or More Variables

Written by SignalsLab

Early edition: these lessons are being reviewed.

Content

Summary

This lesson covers bivariate and multivariate analysis techniques for numeric and categorical data, emphasizing visualization methods like hexagonal binning and contingency tables to handle large datasets. It demonstrates how these tools reveal underlying structures, such as clusters in tax data or risk profiles in loan grades, that univariate statistics cannot capture. The focus is on selecting appropriate visual displays based on variable types to avoid common pitfalls like overplotting.

Intuition

When moving beyond single-variable summaries like the mean, we must understand how variables interact. For numeric data, standard scatterplots fail with large datasets due to overplotting, creating a 'monolithic dark cloud' where patterns are hidden. Hexagonal binning and contour plots solve this by visualizing density, allowing us to see clusters and trends. For categorical data, contingency tables provide a structured way to compare counts and percentages across groups, such as assessing loan risk. Combining these methods, like overlaying contours on scatterplots or using faceting, helps disentangle complex relationships and reveals the true structure of the data.

Derivation

  1. Univariate analysis uses mean and variance to describe single distributions.
  2. Bivariate analysis examines relationships between two variables, while multivariate involves three or more.
  3. Method selection depends on whether variables are numeric or categorical.
  4. For numeric data, hexagonal binning groups records into hexagons colored by count to handle overplotting.
  5. Contour plots visualize density using topographical-like bands increasing toward peaks.
  6. Contour plots can be overlaid on scatterplots to retain individual point visibility.
  7. For categorical data, contingency tables tally counts across combinations of variables.
  8. Boxplots compare numeric distributions across categorical groups, showing quartiles and outliers.
  9. Faceting splits data by categorical variables to reveal hidden patterns in multivariate visualization.

Worked example

Problem

An analyst has a dataset of 432,733 King County tax records and wants to visualize the relationship between finished square footage and tax-assessed value while identifying any subgroups.

  1. Recognize that a standard scatterplot would result in overplotting due to the large number of records.
  2. Apply hexagonal binning to group records into hexagonal cells, where color intensity represents the count of records.
  3. Observe the resulting plot to identify the strong positive relationship between square footage and value.
  4. Look for secondary clusters, such as homes with the same square footage but higher assessed values.
  5. Optionally, use contour plots or faceting by zip code to validate the structure and identify location-based disparities.

Answer Hexagonal binning reveals a strong positive relationship and a secondary cluster of high-value homes, which is confirmed by contour plots and further explained by faceting on zip codes.

Common mistakes

  • Applying standard scatterplots to datasets with hundreds of thousands or millions of records, resulting in a 'monolithic dark cloud' that obscures patterns.
  • Ignoring the need for density visualizations like hexagonal binning or contour plots when dealing with large numeric datasets.
  • Failing to use contingency tables for categorical data, which are essential for comparing counts and percentages across groups.

Animation

Animation coming soon

The animated version of this lesson is being prepared for the web. In the Signals AI app, lessons are drawn step by step.

Code

This is a text lesson: it has no animation code yet.

ccBYNC© 2026 SignalsLab. Lesson text shared as is under CC BY-NC 4.0.