PUBH-311 · Lesson 2 of 12 · 23 min
Describing data: summaries and graphs
▶ Video coming soon A video version of this lesson is on the way.
The Kestrel Valley medical officer of health asked Dr. Osei a simple question: “How long do people stay when they are admitted to our hospital for a respiratory infection?” Jonah pulled 500 recent admissions and calculated the average: 5.3 days. Dr. Osei asked him to draw a histogram first. Most stays were two to five days, but a handful of patients had stayed more than four weeks. The median stay was 4 days. “Which number would you give a family asking how long their mother will probably be in hospital,” she asked, “and which would you give the hospital’s finance office?” Both numbers were correct. They answered different questions.
This lesson covers the tools for describing a single variable: frequency tables, measures of center and spread, percentiles and the shape of a distribution, and the graphs that show them. These are the first steps of every analysis and the basis of almost every public health report. Getting them right also prepares you for inference, because the standard deviation and the shape of a distribution reappear in every later lesson.
Describing categorical variables
A categorical variable is summarized by counting how many observations fall in each category and expressing each count as a proportion of the total. A frequency table lists the categories, the counts (frequencies) and the relative frequencies (proportions or percentages). For ordinal variables a cumulative relative frequency column, adding the proportions in order, is often useful.
| Self-rated health | Frequency | Relative frequency | Cumulative |
|---|---|---|---|
| Excellent | 216 | 0.180 | 0.180 |
| Very good | 420 | 0.350 | 0.530 |
| Good | 348 | 0.290 | 0.820 |
| Fair | 156 | 0.130 | 0.950 |
| Poor | 60 | 0.050 | 1.000 |
| Total | 1,200 | 1.000 |
From Table 1 we can say that 18 percent of respondents rated their health fair or poor (0.13 + 0.05), and that the median category is "very good," because the cumulative proportion first passes 0.5 in that row. Always state the denominator. "Sixty people reported poor health" means little until we know it was 60 of 1,200.
Public health also uses rates, which relate a count of events to the size of the population at risk and a time period, such as 42 new cases of chlamydia per 10,000 people per year. Rates allow fair comparison between populations of different sizes. Principles of Epidemiology covered incidence, prevalence and standardized rates in detail; here the point is that a count alone is rarely a useful summary.
The best graph for categorical data is usually a bar chart, with bars separated by gaps to show that the categories are distinct. For ordinal variables, keep the bars in their natural order. Pie charts are popular but harder to read accurately, because people judge angles and areas less precisely than lengths, and they become unreadable with more than a few categories.
Measures of center
For numerical variables we want to know where the values are concentrated (center), how much they vary (spread) and the overall shape of the distribution. Three measures of center are common.
The mean (arithmetic average) is the sum of the values divided by the number of values:
The median is the middle value when the data are sorted. With an odd number of values it is the single middle one; with an even number it is the average of the two middle values. Half the observations lie at or below the median and half at or above it.
The mode is the most frequent value. It is mainly useful for categorical variables or for discrete data with few distinct values.
The mean uses every value, which makes it efficient but sensitive to extreme values. The median depends only on the order of the values, so it is resistant to outliers. In the hospital example, a few very long stays pulled the mean up to 5.3 days while the median stayed at 4. For skewed data such as length of stay, health care costs, income or viral load, the median is usually the better description of a typical value. The mean is still important when totals matter: the hospital’s bed-days are the mean stay multiplied by the number of admissions, so the finance office needs the mean.
Measures of spread
Two groups can share the same mean and differ greatly in variability. The simplest measure of spread is the range, the maximum minus the minimum. It is easy to understand but depends entirely on the two most extreme values.
The variance and standard deviation describe how far values typically lie from the mean. The sample variance is the sum of squared deviations from the mean divided by \(n - 1\):
We square the deviations so that positive and negative ones do not cancel. Dividing by \(n - 1\) rather than \(n\) corrects for the fact that the sample mean is itself estimated from the same data; it makes \(s^2\) an unbiased estimate of the population variance. The standard deviation, the square root of the variance, is in the same units as the data (mmHg, kilograms, days), so it is the measure usually reported.
The interquartile range (IQR) is the distance between the first quartile (Q1, the 25th percentile) and the third quartile (Q3, the 75th percentile). It covers the middle half of the data and, like the median, is resistant to outliers. Report the median with the IQR and the mean with the standard deviation.
A percentile is the value below which a given proportion of observations fall: the 90th percentile of birth weight is the weight that 90 percent of babies are at or below. Growth charts used in child health are built from percentiles. Different software uses slightly different rules for calculating quartiles from small samples, so hand calculations may differ a little from computer output; the differences shrink as samples grow.
Worked problem
Summarizing ten blood pressure readings
A workplace screening clinic measured systolic blood pressure (mmHg) in ten employees: 118, 124, 130, 112, 141, 127, 135, 122, 150, 131. Find the mean, median, range, variance and standard deviation.
Show solution
- Sort the values: 112, 118, 122, 124, 127, 130, 131, 135, 141, 150.
- Mean: the sum is 1,290, so \(\bar{x} = 1290/10 = 129.0\) mmHg.
- Median: with ten values, average the 5th and 6th sorted values: (127 + 130)/2 = 128.5 mmHg. Mean and median are close, suggesting a roughly symmetric distribution.
- Range: 150 − 112 = 38 mmHg.
- Deviations from 129: −17, −11, −7, −5, −2, 1, 2, 6, 12, 21. Their squares are 289, 121, 49, 25, 4, 1, 4, 36, 144, 441, which sum to 1,114.
- Variance: \(s^2 = 1114/9 = 123.8\) mmHg squared. Standard deviation: \(s = \sqrt{123.8} = 11.1\) mmHg.
Answer: Mean 129.0 mmHg, median 128.5 mmHg, range 38 mmHg, standard deviation 11.1 mmHg. A report would say: mean systolic pressure was 129 mmHg (SD 11).
A useful check on any standard deviation: for roughly symmetric data, most values lie within two standard deviations of the mean. Here that is 129 ± 22, or 107 to 151 mmHg, which contains all ten readings. If your calculated SD implies a range wildly different from the data, recheck the arithmetic.
The coefficient of variation (CV), the standard deviation divided by the mean, expresses variability relative to the size of the values. Laboratories use it to describe the precision of an assay: a CV of 0.03, often written as 3 percent, means repeated measurements vary by about 3 percent of their average.
The shape of a distribution
A distribution describes which values a variable takes and how often. Its shape can be described by symmetry, skewness, the number of peaks and the presence of outliers (Figure 1).
In a symmetric distribution the two halves are mirror images and the mean and median coincide. Height and many laboratory values in healthy adults are roughly symmetric. In a right-skewed (positively skewed) distribution a long tail extends toward high values; the mean is larger than the median. Length of stay, health care costs, number of sexual partners, blood lead levels and income are right-skewed. In a left-skewed (negatively skewed) distribution the tail extends toward low values and the mean is below the median; age at death in a high-income country and gestational age at birth are examples. A distribution with two peaks is bimodal, which often means two different groups have been combined, for instance adults and children.
Comparing the mean and median is a quick check on skewness. Right-skewed data are often analyzed after a logarithmic transformation, which compresses the long tail and can make the distribution roughly symmetric. Results on the log scale are then transformed back, giving a geometric mean, which is close to the median for log-symmetric data.
Graphs for numerical data
A histogram divides the range of values into intervals (bins) of equal width and draws a bar for the number or proportion of observations in each; the bars touch because the scale is continuous. The choice of bin width matters: too few bins hide the shape and too many make it ragged. A box plot (box-and-whisker plot) shows the median as a line inside a box from Q1 to Q3, with whiskers extending to the most extreme values within 1.5 times the IQR from the box; points beyond that are plotted individually as possible outliers. Box plots are compact and excellent for comparing several groups side by side.
Other useful graphs include the dot plot, which shows every value for small samples, and the stem-and-leaf plot, an older paper-based display. For two numerical variables, a scatterplot shows the relationship (Lesson 8). For a numerical variable measured over time, such as weekly influenza cases, a line graph or, for counts of cases by date of onset, an epidemic curve is standard.
Identifying outliers
An outlier is an observation far from the others. The 1.5 × IQR rule used in box plots flags values below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR. In the hospital data, Q1 is 2 days and Q3 about 6 days, so the IQR is 4 days and the upper fence is 6 + 6 = 12 days; stays longer than 12 days are flagged. Flagging is not the same as deleting. An outlier may be a data entry error (a stay of 400 days caused by a misplaced digit), which should be corrected, or a genuine and important observation, such as patients with complications, which should be kept and perhaps studied. Never remove outliers simply because they make results less tidy.
Good practice in health graphics
Graphs in public health reports reach policy makers and the public, so they must be honest and clear. A few principles, drawn from the work of statisticians and designers such as Edward Tufte and William Cleveland, serve well.
- Start bar chart axes at zero. Because readers compare bar lengths, a truncated axis exaggerates differences. Line graphs showing change over time may use a non-zero axis if it is clearly labeled.
- Label axes with units and give each graph a clear title and data source.
- Avoid three-dimensional effects, which distort areas and make values hard to read.
- Show uncertainty where it matters, such as confidence intervals on estimates from samples.
- Use color sparingly and choose palettes that remain distinguishable for people with color vision deficiency.
- Prefer showing rates rather than counts when comparing populations of different sizes, and say whether rates are age-standardized.
Worked problem
Choosing summaries for a skewed variable
Ten patients’ lengths of stay (days) were 2, 3, 3, 4, 4, 5, 6, 8, 12, 23. Find the mean and median, explain which better describes a typical stay, and say whether 23 days would be flagged by the 1.5 × IQR rule if Q1 = 3.25 and Q3 = 7.5 days.
Show solution
- Mean: the total is 70 days, so the mean is 70/10 = 7.0 days.
- Median: the 5th and 6th sorted values are 4 and 5, so the median is 4.5 days.
- The mean is well above the median because of the 12-day and 23-day stays, a sign of right skew. The median better describes a typical stay.
- IQR = 7.5 − 3.25 = 4.25 days; 1.5 × IQR = 6.375 days; the upper fence is 7.5 + 6.375 = 13.875 days.
- The 23-day stay exceeds the fence and is flagged as a possible outlier; 12 days is not flagged.
Answer: Median 4.5 days (IQR 3.25 to 7.5) describes a typical stay better than the mean of 7.0 days. The 23-day stay is flagged and should be checked, not automatically deleted.
Describing data for a report: Table 1
Almost every health study opens with a descriptive table, often literally labeled Table 1, that summarizes the characteristics of the participants, usually overall and by exposure or treatment group. Numerical variables appear as mean (SD) or median (IQR), and categorical variables as n (percent). Table 1 tells readers who was studied, so they can judge whether the results apply to their own population, and it reveals differences between groups that may confound comparisons. You will build a Table 1 for the Kestrel Valley data in the final lesson.
When writing about summaries, round sensibly. Reporting a mean blood pressure of 129.04716 mmHg implies precision the measurement does not have; 129 mmHg is enough. A common guide is to report means to one more decimal place than the raw data and proportions to one decimal place when expressed as percentages.
Back to the hospital
Dr. Osei’s final report gave both numbers with a sentence explaining each: half of patients went home within 4 days (the median), while the average stay of 5.3 days determined how many beds the hospital needed. She added the histogram so that readers could see why the two differed. The finance office and the family-facing patient guide each used the number that answered their question.
Common mistakes
MistakeReporting only the mean for strongly skewed data such as costs or length of stay.
InsteadReport the median and IQR, and add the mean if totals matter, explaining the difference.
MistakeDividing by n instead of n − 1 when calculating a sample standard deviation.
InsteadUse n − 1 for the sample variance; it gives an unbiased estimate of the population variance.
MistakeDeleting outliers because they look inconvenient.
InsteadInvestigate outliers; correct errors but keep genuine observations and describe them.
MistakeStarting the vertical axis of a bar chart well above zero.
InsteadStart bar chart axes at zero so bar lengths are proportional to the values.
MistakeGiving a count without its denominator.
InsteadAlways pair counts with the number at risk, as a proportion or rate.
Summary and key terms
- Categorical variables are summarized with counts, proportions and bar charts; rates add a population and time denominator.
- The mean uses every value but is pulled by extreme values; the median is resistant and suits skewed data.
- The standard deviation measures typical distance from the mean and is reported with the mean; the IQR is reported with the median.
- Distributions may be symmetric, right-skewed or left-skewed; in skewed data the mean lies toward the long tail.
- Histograms and box plots display numerical data; the 1.5 × IQR rule flags possible outliers for investigation.
- Honest graphs start bar axes at zero, label units and sources, avoid 3-D effects and show uncertainty.
- Table 1 describes study participants overall and by group using mean (SD), median (IQR) and n (percent).
- Relative frequency
- The proportion of observations in a category.
- Mean
- The sum of values divided by their number.
- Median
- The middle value of sorted data; half the values lie on each side.
- Standard deviation
- The square root of the variance; a measure of typical distance from the mean in the units of the data.
- Interquartile range
- The difference between the third and first quartiles, covering the middle half of the data.
- Percentile
- The value below which a stated proportion of observations fall.
- Right skew
- A distribution with a long tail toward high values, in which the mean exceeds the median.
- Box plot
- A graph showing the median, quartiles, whiskers and possible outliers.
- Outlier
- An observation that lies unusually far from the rest of the data.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Find the mean, median and range of these birth weights in grams: 3,100; 3,400; 2,900; 3,600; 3,250.
Show answer
Sorted: 2,900, 3,100, 3,250, 3,400, 3,600. Mean = 16,250/5 = 3,250 g; median = 3,250 g; range = 700 g.
Annual health care costs in a sample have a mean of 6,800 dollars and a median of 2,100 dollars. What does this tell you about the shape, and which summary describes a typical person?
Show answer
The distribution is strongly right-skewed (a few people have very high costs). The median describes a typical person; the mean is needed for budgeting total costs.
Q1 = 20 and Q3 = 32 for a set of ages. Which values would the 1.5 × IQR rule flag?
Show answer
IQR = 12; 1.5 × 12 = 18. Fences are 20 − 18 = 2 and 32 + 18 = 50, so ages below 2 or above 50 are flagged.
Why should a bar chart comparing vaccination coverage in two regions start its axis at zero?
Show answer
Readers compare the lengths of bars; truncating the axis makes a small difference look large and misrepresents the data.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.