MHIA 6160: Value & Quality in Healthcare
Week 2 R-Laboratory: Measuring Value, Utilization & The Efficiency Frontier
Laboratory Overview
Welcome to Week 2. Building on our Week 1 R-Laboratory foundation, this laboratory shifts our perspective from individual patient clinical pathways to macro-level system performance. As health systems leaders, evaluating value requires comparing entities (e.g., hospitals, regional health authorities, or entire national health systems) to identify who is delivering the highest quality of care per dollar spent.
Today’s session introduces the tools required for your Week 4 R-Visualization Assessment. We will build a comprehensive statistical summary matrix and visualize the Effectiveness-Efficiency Frontier using a Quadrant Analysis.
Today’s session is divided into four progressive parts:
- Part I: The Utilization Friction Exercise: Macro-economic drivers of health.
- Part II: The Statistical Summary Matrix: Generating descriptive statistics.
- Part III: The Effectiveness-Efficiency Frontier: Visualizing strategic trade-offs.
- Part IV: The Value-Based Storyline: Structuring the executive insight.
Part I: The Utilization Friction Exercise
Background & Objective
Before we can evaluate access and utilization, we must understand the macro-economic conditions driving them. In Module 2, we discussed the Effectiveness-Efficiency Frontier. No health system has unlimited resources, that is, healthcare leaders must constantly plot their system’s performance to ensure they are not operating in a high-cost, low-outcome state.
To model this, we are using the gapminder dataset, a gold-standard teaching tool in global health economics. It captures the macro-economic reality of different health systems by tracking life expectancy (our Effectiveness/Outcome proxy) against GDP per capita (our Efficiency/Cost proxy).
The gapminder dataset (from the gapminder package) is a cleaned excerpt of historical data from the Gapminder Foundation. It tracks global development across 142 countries from 1952 to 2007 in 5-year increments.
It contains 1,704 observations and 6 variables:
country: Factor with 142 levels.continent: Factor with 5 levels.year: Integer ranging from 1952 to 2007.lifeExp: Life expectancy at birth, in years.pop: Total population.gdpPercap: GDP per capita (inflation-adjusted US$).
Quick Start Code:
# Install and load the dataset
install.packages("gapminder")
library(gapminder)
# Preview the data
head(gapminder)Part II: The Data Audit & Statistical Summary Matrix
In Week 1, we learned how to isolate a single metric to answer targeted questions. However, when an analyst hands you a new, massive dataset, you cannot simply dive into manipulation; you must first understand its underlying architecture, quality, and limitations. This critical diagnostic phase is known as a data audit or Exploratory Data Analysis (EDA). Once the EDA is complete, you will frequently be required to construct a Statistical Summary Table. This table serves as a foundational baseline, condensing complex variables into key descriptive metrics, including means, medians, and variances, to evaluate a health outcome, system performance, or progress toward strategic organizational goals.
Exploratory Data Analysis (EDA)
When working with thousands of rows (sometimes millions), opening the data in a spreadsheet is inefficient and prone to crashing. To avoid some of the inherent constraints of traditional spreadsheet software, R provides several rapid commands to peek inside the dataset or data object. In the first exercise, we will explore some common commands in R that are used to explore the dataset.
Run these commands in your console to explore the gapminder dataset:
Code
# ACTIVATE PROGRAMMATIC SUITES
library(tidyverse) # Data wrangling and visualization
library(gapminder) # Global health economics dataset (Macro-Conditions)
library(gt) # Executive summary tables
# VARIABLE LOOKUP: Print only the column headers
# Useful when you need to copy/paste exact spelling for a pipeline
names(gapminder)
# THE GLIMPSE: A structural x-ray of your data
# Shows row counts, column counts, and the data type (numeric, character, factor)
glimpse(gapminder)
# TOP & BOTTOM AUDITS: View the first or last 6 rows
# A quick way to verify that your sorting or data loading worked correctly
head(gapminder)
tail(gapminder)
# RAPID DESCRIPTIVE STATS: The automatic summary
# Immediately calculates min, median, mean, max, and detects missing values (NAs)
summary(gapminder)
# INTEGRITY CHECK: Audit for missing values
# In health administration, missing records distort metrics. Always run this first.
any(is.na(gapminder))Spreadsheet Bridge: The View() Function
To bridge the gap between traditional spreadsheets and programming, RStudio includes the View() function (note the mandatory capital “V”). When you type View(gapminder) directly into your console and hit enter, RStudio opens the dataset in a familiar, Excel-style grid tab. Just like in Microsoft Excel, this interactive window allows you to visually scroll through all rows and columns, inspect variable naming conventions, click on column headers to sort the data chronologically or alphabetically, and use a search bar to isolate specific records.
Administrative Warning: Because View() opens an interactive graphical interface, you must only run this command in your console. Never type View() directly into your script’s code chunks, as it will cause your automated HTML executive report rendering process to freeze and fail.
Formal Statistical Summary Matrix
While summary() is great for a rapid check, you cannot put raw console text into a boardroom presentation. Using the dplyr package, we will now group our global health data by region and calculate a robust, customizable statistical profile: Mean, Median, Standard Deviation, and Minimum / Maximum ranges. We will then pipe (%>%) this into the table (gt()) summary engine.
Code
# Load Libraries
library(tidyverse) # Data wrangling and visualization
library(gapminder) # Global health economics dataset (Macro-Conditions)
library(gt)
# INTRODUCE AND FILTER THE DATA
# We will filter the dataset to isolate the most recent reporting year (2007)
health_econ_data <- gapminder %>%
filter(year == 2007)
# BUILD THE STATISTICAL SUMMARY MATRIX
system_summary <- health_econ_data %>%
# Group the data by continent (our macro-regional proxy)
group_by(continent) %>%
# Calculate the comprehensive statistical profile for Life Expectancy (Effectiveness)
summarize(
total_n = n(),
mean_life_exp = mean(lifeExp, na.rm = TRUE),
median_life_exp = median(lifeExp, na.rm = TRUE),
sd_life_exp = sd(lifeExp, na.rm = TRUE),
min_life_exp = min(lifeExp, na.rm = TRUE),
max_life_exp = max(lifeExp, na.rm = TRUE)
) %>%
# Rank the regions by the highest mean life expectancy (Comparative Ordering)
arrange(desc(mean_life_exp))
# RENDER THE EXECUTIVE TABLE
system_summary %>%
gt() %>%
tab_header(
title = "Macro-System Performance Baseline",
subtitle = "Descriptive Statistics: Life Expectancy by Region (2007)"
) %>%
cols_label(
continent = "Region",
total_n = "System Count (N)",
mean_life_exp = "Mean (Yrs)",
median_life_exp = "Median (Yrs)",
sd_life_exp = "Std. Deviation",
min_life_exp = "Minimum",
max_life_exp = "Maximum"
) %>%
# Round all our calculated metrics to 1 decimal place for clean reporting
fmt_number(
columns = c(mean_life_exp, median_life_exp, sd_life_exp, min_life_exp, max_life_exp),
decimals = 1
) %>%
# Highlight the region with the highest variance (inequity) in outcomes
tab_style(
style = cell_fill(color = "yellow"),
locations = cells_body(
columns = sd_life_exp,
rows = sd_life_exp == max(sd_life_exp)
)
)| Macro-System Performance Baseline | ||||||
| Descriptive Statistics: Life Expectancy by Region (2007) | ||||||
| Region | System Count (N) | Mean (Yrs) | Median (Yrs) | Std. Deviation | Minimum | Maximum |
|---|---|---|---|---|---|---|
| Oceania | 2 | 80.7 | 80.7 | 0.7 | 80.2 | 81.2 |
| Europe | 30 | 77.6 | 78.6 | 3.0 | 71.8 | 81.8 |
| Americas | 25 | 73.6 | 72.9 | 4.4 | 60.9 | 80.7 |
| Asia | 33 | 70.7 | 72.4 | 8.0 | 43.8 | 82.6 |
| Africa | 52 | 54.8 | 52.9 | 9.6 | 39.6 | 76.4 |
Example of an Interpretation: Statistical Summary Matrix
Notice the highlight (yellow) applied to the Standard Deviation column. While averages (means and medians) provide a helpful systemic baseline, they often mask severe inequalities. By programmatically isolating the maximum standard deviation, we instantly identify the region with the widest variance in health outcomes. In health administration, high variance is a direct proxy for inequity—it indicates that while some populations within that region achieve high life expectancies, others are experiencing critical system failures. This application of conditional formatting adheres to the “So What?” principle of executive communication, instantly directing leadership’s attention to the exact operational zone that requires an equity-focused audit.
Part III: The Effectiveness-Efficiency Frontier
The Grammar of Graphics (ggplot2 Primer)
In R, professional data visualization is powered by the ggplot2 package. Instead of generating a chart all at once, ggplot2 builds visuals layer by layer—much like stacking clear transparencies on an overhead projector. You begin with a blank canvas, map your data to axes, and then add geometric shapes, strategic boundary lines, and executive formatting. Before building the Effectiveness-Efficiency Frontier, review the core grammar you will use today, alongside a customization palette you can use to experiment and personalize your future plots.
Plotting Grammar (The Structure)
These are the foundational commands required to build and render a baseline plot.
| Code Layer / Function | Visual Element | What it tells R to do) |
|---|---|---|
ggplot(data = ...) |
Blank Canvas | Initializes the blank chart and assigns the specific dataset you want to visualize. |
aes(x = ..., y = ...) |
Aesthetics | Maps specific data columns (e.g., Cost & Outcomes) to the X and Y axes. |
+ |
Layer Stacker | Adds a new visual layer to the plot. (Must always be placed at the end of a line, never the beginning). |
geom_point() |
Geometry | Tells R to represent the data rows as individual dots, creating a scatter plot. |
geom_vline() & geom_hline() |
Intercepts | Draws rigid vertical or horizontal reference lines to create strategic quadrants or benchmarks. |
labs() |
Labels | Generates professional titles, subtitles, and axis labels for reporting. |
scale_y_continuous() & scale_x_continuous() |
Axis Calibration | Explicitly sets the boundaries (limits), tick marks (breaks), or formatting labels (e.g., currency, percentages) across your continuous data axes. |
Executive Customization Palette (The Polish)
You are highly encouraged to experiment with these functions to own your visuals. Try swapping themes, adjusting opacities, or changing colors to match corporate branding.
| Customization Tool | Application | How it Changes Your Visual |
|---|---|---|
| Alternative Geometries | Swap geom_point() for: |
geom_col() (Bar charts for totals)geom_line() (Time-series trends)geom_boxplot() (Distribution and equity tracking) |
color = vs. fill = |
Inside your geom_...() |
color changes the outline/point color (e.g., color = "darkblue").fill changes the solid inside of a bar or boxplot. |
alpha = |
Inside your geom_...() |
Controls transparency from 0.0 (invisible) to 1.0 (solid). Highly useful for dense datasets where points overlap (e.g., alpha = 0.6). |
scale_color_viridis_d() |
Added as a new + layer |
Applies a professional, colorblind-friendly color palette automatically to your grouped categories. |
| Alternative Themes | Swap theme_minimal() for: |
theme_classic() (Clean, traditional academic look with no gridlines)theme_light() (Distinct gridlines for precise numeric tracking) |
Code-Along Quadrant Analysis
In healthcare leadership, value is defined as outcomes achieved per dollar spent (recall the equation?). To visualize this trade-off, we will plot our Effectiveness proxy (Life Expectancy) against our Efficiency/Cost proxy (GDP per Capita) using the plotting library ggplot2 and syntax. To guide strategic placement, we will calculate global threshold medians to divide our plot into a Strategic Quadrant Matrix defined as follows:
- Top-Right: High Cost, High Outcome (Resource-Intensive Success).
- Top-Left: Low Cost, High Outcome (The High-Value Frontier).
- Bottom-Right: High Cost, Low Outcome (System Inefficiency / Waste).
- Bottom-Left: Low Cost, Low Outcome (Under-resourced Challenges).
Economic data like GDP is heavily right-skewed; a few ultra-wealthy systems stretch the scale, obscuring patterns among average performers. We apply scale_x_log10() to transform the chart into a readable linear distribution without deleting or altering raw records.
Visualizing the Frontier allows health administrators to instantly spot outlier systems. We will use a Scatter Plot to map Financial Cost (X-Axis) against Health Outcomes (Y-Axis).
Code
# Load libraries
library(tidyverse) # Data wrangling and visualization
library(gapminder) # Global health economics dataset (Macro-Conditions)
# Calculate the global averages to build our Quadrant Intercept Lines
global_avg_cost <- mean(health_econ_data$gdpPercap)
global_avg_outcome <- mean(health_econ_data$lifeExp)
# Build the Effectiveness-Efficiency Frontier Plot
ggplot(data = health_econ_data, aes(x = gdpPercap, y = lifeExp)) +
# Map the entities (Scatter points sized by population volume)
geom_point(aes(size = pop, color = continent), alpha = 0.7) +
# Add the Quadrant Intercept Lines (The System Benchmarks)
geom_vline(xintercept = global_avg_cost, linetype = "dashed",
color = "#333333", linewidth = 0.8) +
geom_hline(yintercept = global_avg_outcome, linetype = "dashed",
color = "#333333", linewidth = 0.8) +
# Explicit X and Y Axis Scaling & Calibration
# Cost (X-Axis): Log10 scale to correct skewness
scale_x_log10(
limits = c(100, 100000),
labels = scales::dollar_format()
) +
# Effectiveness (Y-Axis): Custom boundaries (35 to 90 years)
scale_y_continuous(
limits = c(30, 90),
breaks = seq(30, 100, by = 10)
) +
# System Volume (Size Legend): Remove scientific notation for executive readability
scale_size_continuous(
labels = scales::comma_format()
) +
# Annotate the Strategic Quadrants
annotate("text", x = 1000, y = 82, label = "High Value\n(Low Cost, High Outcome)",
color = "#006400", fontface = "bold", size = 3.5) +
annotate("text", x = 30000, y = 45, label = "Low Value\n(High Cost, Low Outcome)",
color = "#8b0000", fontface = "bold", size = 3.5) +
# Executive Formatting
labs(
title = "Fig 1. The Effectiveness-Efficiency Frontier",
subtitle = "INSERT AN APPROPRIATE SUBTITLE",
x = "Resource Consumption Proxy (GDP per Capita, Log Scale)",
y = "Effectiveness Proxy (Life Expectancy in Years)",
color = "Region",
size = "System Volume"
) +
theme_minimal(base_size = 12) +
theme(
plot.title = element_text(face = "bold", color = "#333333"),
legend.position = "right"
)Example Interpretation: The Power of Quadrant Analysis
The Effectiveness-Efficiency scatter plot moves beyond basic financial reporting by forcing a dual-lens perspective. By overlaying the global average intercepts, this visual automatically triages health systems into actionable strategic zones. For instance, a system plotted in the bottom-right quadrant (High Cost, Low Outcome) is experiencing critical operational friction, warning health administrators that injecting more capital without structural reform will likely result in systemic waste. Conversely, systems in the top-left quadrant represent the “High-Value Frontier,” offering empirical blueprints for maximizing population health within constrained budgets.
Part IV: The Value-Based Storyline
Data visualization is a tool for strategic persuasion, not just decoration. As you prepare for your R-Visualization Assessment, practice looking past the code to uncover the health systems implications. As a reminder, the R-Visualization Assessment requires you to submit two technical visuals, accompanied by a 200-word structured insight per figure. Visualizations are useless if they are not translated into strategic action. Use the fill-in-the-blank template below to practice writing your executive insights based on the Quadrant Analysis plot we just generated.
This framework / template can be used as a guide when developing your executive communication. The answers for each of the prompts are examples only.
1. Methodology: Describe the data processing procedures used to prep this visual.
To prepare this visual, the raw dataset was filtered using
filter()to isolate the 2007 reporting year. Global averages for both outcomes and resources were calculated to establish programmatic intercept lines usinggeom_vlineandgeom_hline.
2. Rationale: Justify the selection of this specific figure type.
A scatter plot was selected because… [FILL IN YOUR RATIONALE: e.g., mapping continuous numeric variables against one another is the optimal way to display the Effectiveness-Efficiency Frontier and identify systemic outliers].
3. Insights: Elaborate on the principal findings or patterns disclosed by the visual.
The Quadrant Analysis reveals significant macro-level variances. Specifically… [FILL IN YOUR INSIGHT: e.g., observe the cluster of systems operating below the global outcome average despite spending above the global resource average. What regional traits define the “High Value” quadrant?].
4. Recommendation: Provide an evidence-based strategic recommendation to leadership.
Based on this data, health systems operating in the bottom-right quadrant must… [FILL IN YOUR RECOMMENDATION: e.g., pivot away from capital-intensive acute interventions and investigate the upstream preventive delivery models utilized by top-left quadrant systems].
Executive Discussion Questions
Look closely at the statistical data matrix and quadrant plot generated during today’s laboratory:
- Which geographical region occupies the High-Value Frontier quadrant (Top-Left: lower spend, higher outcomes than global average)? What institutional or structural factors might explain this?
- Locate the outliers on the extreme far right of the spending axis. Are they receiving proportional returns on health outcomes for their heavy capital investment?
- How does the size of the system (population) appear to correlate, if at all, with its efficiency positioning?
Week 2 R-Laboratory Synthesis Deliverable
Review the Effectiveness-Efficiency Frontier generated in Part III. In your own words, explain the operational danger of evaluating a health system’s performance based solely on clinical outcomes (the Y-axis) without adjusting for resource consumption (the X-axis).
{end}