Statistics Appendix D

Appendix D: Index Numbers and Grouped Data

Extra topics common in national curricula

All chapters
On this page

Many national syllabuses and business-statistics courses include two topics that this course has touched only lightly: summarizing data that arrive already grouped into classes, and index numbers such as the Consumer Price Index. Neither needs new mathematics, but both have their own vocabulary and conventions, and both turn up in exams. This appendix covers them with worked examples, interactive calculators, and a practice set. It also covers moving averages, the simplest tool for smoothing a time series.

What you will be able to do
  • Estimate the mean, median, mode, variance, standard deviation and quartiles of grouped data, and draw a histogram and an ogive.
  • Compute price relatives and simple, Laspeyres, Paasche and Fisher price indices, and explain how they differ.
  • Change the base period of an index, chain indices together, and use a price index to convert nominal values into real values.
  • Smooth a time series with a moving average, including the centered version for even periods.
D.1

Grouped frequency data

Published data are often reported only as a frequency table of classes (for example "20 up to 30: 18 people"). The individual values are gone, so we cannot compute exact statistics. Instead we pretend that every observation in a class sits at the class midpoint (for the mean and variance) or is spread evenly across the class (for the median, mode and quartiles). The results are estimates, and they are accurate when the classes are narrow and the data are not strongly clustered at the class edges.

Formulas for grouped data

For classes \(i = 1, \dots, k\) with lower limit \(L_i\), upper limit \(U_i\), width \(w_i = U_i - L_i\), frequency \(f_i\), midpoint \(x_i = (L_i + U_i)/2\), and total \(n = \sum f_i\):

QuantityFormula
Mean\(\bar{x} = \dfrac{\sum f_i x_i}{n}\)
Variance\(s^2 = \dfrac{\sum f_i x_i^2 - n\bar{x}^2}{n - 1}\), \(\; s = \sqrt{s^2}\)
Median\(L + \dfrac{n/2 - F}{f}\, w\), where the median class is the first with cumulative frequency at least \(n/2\), \(L\) and \(w\) are its lower limit and width, \(f\) its frequency, and \(F\) the cumulative frequency of the classes before it
QuartilesThe same formula with \(n/4\) (for \(Q_1\)) or \(3n/4\) (for \(Q_3\)) in place of \(n/2\)
Mode\(L + \dfrac{d_1}{d_1 + d_2}\, w\), where the modal class has the largest frequency, \(d_1 = f - f_{\text{before}}\) and \(d_2 = f - f_{\text{after}}\)

If the classes have unequal widths, replace each frequency \(f_i\) by the frequency density \(f_i/w_i\) when finding the modal class and in \(d_1\) and \(d_2\), and draw the histogram with density on the vertical axis so that area, not height, represents frequency.

Example D.1: Ages of 50 customers

The ages of 50 customers of a shop are grouped as follows.

Age (years)Midpoint \(x\)Frequency \(f\)Cumulative \(F\)\(fx\)\(fx^2\)
0 up to 1055525125
10 up to 201512171802,700
20 up to 3025183545011,250
30 up to 4035104535012,250
40 up to 504555022510,125
Total501,23036,450

Mean. \(\bar{x} = 1230/50 = 24.6\) years.

Variance. \(\sum f x^2 - n\bar{x}^2 = 36450 - 50(24.6)^2 = 36450 - 30258 = 6192\), so \(s^2 = 6192/49 = 126.37\) and \(s = 11.24\) years.

Median. \(n/2 = 25\). The cumulative frequencies are 5, 17, 35, so the median class is 20 up to 30, with \(F = 17\) and \(f = 18\): \(\text{median} = 20 + \dfrac{25 - 17}{18}(10) = 24.44\).

Quartiles. \(n/4 = 12.5\) falls in the class 10 up to 20 (\(F = 5\), \(f = 12\)): \(Q_1 = 10 + \dfrac{12.5 - 5}{12}(10) = 16.25\). \(3n/4 = 37.5\) falls in 30 up to 40 (\(F = 35\), \(f = 10\)): \(Q_3 = 30 + \dfrac{37.5 - 35}{10}(10) = 32.5\).

Mode. The modal class is 20 up to 30 (\(f = 18\)), with \(d_1 = 18 - 12 = 6\) and \(d_2 = 18 - 10 = 8\): \(\text{mode} = 20 + \dfrac{6}{6 + 8}(10) = 24.29\).

The mean, median and mode are close together, so the distribution is nearly symmetric. Note that the median formula is just linear interpolation along the ogive.

Going deeper: How accurate are the grouped estimates?

Replacing every value in a class by its midpoint adds a small error to each observation. If the values within a class are spread roughly evenly, the errors average out and the grouped mean is very close to the true mean. The variance, however, is systematically too large by about \(w^2/12\) (the variance of a uniform distribution of width \(w\)) when computed from midpoints. Sheppard's correction subtracts this amount for equal-width classes:

\[ s^2_{\text{corrected}} \approx s^2_{\text{grouped}} - \frac{w^2}{12}. \]

For Example D.1 with \(w = 10\) the correction is \(100/12 = 8.33\), which would reduce the variance from 126.4 to about 118.0. The correction is valid only for smooth, roughly bell-shaped data with narrow classes, and it is not applied by most textbooks, so use it only if your course asks for it. Using open-ended classes ("60 and over") makes midpoints arbitrary and is the largest source of error in real grouped data.

D.2

Index numbers

An index number expresses the size of a quantity in one period relative to a chosen base period, which is given the value 100. An index of 118 means "18 percent higher than in the base period". The most familiar index is the Consumer Price Index (CPI), which tracks the cost of a fixed basket of goods and services that a typical household buys.

Price relatives and simple indices

For a single item with price \(p_0\) in the base period and \(p_t\) in period \(t\), the price relative is

\[ I_t = \frac{p_t}{p_0} \times 100. \]

To combine several items there are two simple approaches. The simple aggregate index adds the prices, \(\dfrac{\sum p_t}{\sum p_0}\times 100\), and the mean of price relatives averages the individual relatives. Both ignore how much of each item people buy, so an expensive item dominates the first and a trivial item counts as much as an important one in the second. That is why weighted indices are used in practice.

Weighted indices: Laspeyres, Paasche and Fisher

A weighted index prices a basket of quantities \(q\) at the prices of two periods and compares the totals. The choice of which quantities to use gives different indices.

Weighted price indices
IndexFormulaBasket used
Laspeyres\(\displaystyle L = \frac{\sum p_t q_0}{\sum p_0 q_0}\times 100\)Base-period quantities
Paasche\(\displaystyle P = \frac{\sum p_t q_t}{\sum p_0 q_t}\times 100\)Current-period quantities
Fisher (the "ideal" index)\(F = \sqrt{L \times P}\)Geometric mean of the two
Marshall-Edgeworth\(\displaystyle \frac{\sum p_t (q_0 + q_t)}{\sum p_0 (q_0 + q_t)}\times 100\)Average of the two quantities

The corresponding quantity indices swap the roles of \(p\) and \(q\); for example the Laspeyres quantity index is \(\sum p_0 q_t / \sum p_0 q_0 \times 100\). The value index is \(\sum p_t q_t / \sum p_0 q_0 \times 100\), and it equals the price index times the quantity index in the Fisher case.

Example D.2: A four-item basket

A household buys four items. Prices are in dollars and quantities are per month.

Item\(p_0\)\(p_t\)\(q_0\)\(q_t\)\(p_0 q_0\)\(p_t q_0\)\(p_0 q_t\)\(p_t q_t\)
Bread2.002.405044100.0120.088.0105.6
Milk1.501.80404260.072.063.075.6
Eggs3.003.30202560.066.075.082.5
Rice4.005.0010840.050.032.040.0
Total260.0308.0258.0303.7

Price relatives: bread 120, milk 120, eggs 110, rice 125. Simple aggregate: \(\sum p_t/\sum p_0 = 12.50/10.50 = 119.05\). Mean of relatives: \((120 + 120 + 110 + 125)/4 = 118.75\).

Laspeyres: \(L = 308.0/260.0 \times 100 = 118.46\). Paasche: \(P = 303.7/258.0 \times 100 = 117.71\). Fisher: \(\sqrt{118.46 \times 117.71} = 118.09\). Marshall-Edgeworth: \(611.7/518.0 \times 100 = 118.09\).

Quantity and value. The Laspeyres quantity index is \(258.0/260.0 \times 100 = 99.23\) and the value index is \(303.7/260.0 \times 100 = 116.81\): households spend 16.8 percent more, but almost all of that is price, not volume.

Interpretation. The typical base-period basket costs 18.5 percent more than before. The Paasche index is slightly lower than the Laspeyres because households bought less of the items whose prices rose most (bread and rice): they substituted away from the expensive items. This pattern (\(L \ge P\)) is typical and is called substitution bias in the Laspeyres index.

Which index do official statistics use?

Most consumer price indices (including many national CPIs) are Laspeyres-type indices with a basket that is updated every few years, because collecting current quantities for every period would be very expensive. Paasche indices are common for deflators of national accounts, where current quantities are known. Some agencies now publish Fisher-type chained indices to reduce substitution bias.

D.3

Changing the base, chaining, and deflating

Shifting the base period

To move the base from period \(a\) to period \(b\), divide every index value by the index value of the new base and multiply by 100:

\[ I^{\text{new}}_t = \frac{I^{\text{old}}_t}{I^{\text{old}}_b} \times 100. \]

For example, with 2019 \(= 100\) the values 100, 104, 110, 121 for 2019, 2020, 2021, 2022 become, on a 2021 base, \(90.91,\ 94.55,\ 100,\ 110\). The percentage changes between years are unchanged; only the reference point moves.

Chain indices and splicing

A fixed-base index compares every period with the same base. A chain index compares each period with the previous one and multiplies the links together. If prices rise 3 percent, then 5 percent, then 2 percent in successive years, the chain index is \(100 \times 1.03 \times 1.05 \times 1.02 = 110.31\). Chaining lets the basket be updated regularly. When an old series (with one base or basket) must be joined to a new one, we splice them by rescaling the older series so that the two agree in an overlap period.

Deflating: nominal and real values

A price index converts nominal (current-dollar) amounts into real amounts, which measure purchasing power in base-period dollars:

\[ \text{real value} = \frac{\text{nominal value}}{\text{price index}/100}. \]

The inflation rate between two periods is \((I_t/I_{t-1} - 1)\times 100\), and the purchasing power of a dollar is \(100/I_t\) (relative to the base).

Example D.3: Did the raise keep up with prices?

An employee earned $50,000 in 2019 and $58,000 in 2023. The CPI (2019 \(= 100\)) was 118 in 2023.

The nominal raise is \(58000/50000 - 1 = 16\%\). The real salary in 2019 dollars is \(58000/1.18 = \$49{,}152.54\), so in real terms the salary fell by \(49152.54/50000 - 1 = -1.7\%\). Prices rose 18 percent but pay rose only 16 percent, so the employee is slightly worse off despite the raise.

D.4

Moving averages

A time series is often too jagged to see its trend. A moving average replaces each value by the average of the values around it. A \(k\)-point moving average with \(k\) odd is centered on the middle observation:

\[ \text{MA}_t = \frac{y_{t-m} + \cdots + y_t + \cdots + y_{t+m}}{k}, \qquad k = 2m + 1. \]

For example, the 3-point moving average of 5, 7, 6, 8, 9, 7, 10, 11 is 6.00, 7.00, 7.67, 8.00, 8.67, 9.33 (there are no averages for the first and last observations). For an even period such as \(k = 4\) quarters, the average falls between two observations, so we average two consecutive 4-point averages to re-center it (a \(2 \times 4\) moving average):

\[ \text{MA}_t = \frac{\tfrac12 y_{t-2} + y_{t-1} + y_t + y_{t+1} + \tfrac12 y_{t+2}}{4}. \]

When \(k\) equals the length of a seasonal cycle (4 for quarterly data, 12 for monthly data), each average contains exactly one value from every season, so the seasonal pattern cancels and only the trend remains. For quarterly values 20, 32, 28, 44, 24, 36, 32, 48 the centered \(2 \times 4\) averages are 31.5, 32.5, 33.5, 34.5: a steady upward trend of one unit per quarter hidden underneath the wild seasonal swings. Longer windows smooth more but lose more observations at the ends and react more slowly to real changes.

D.5

Practice

D.6

Summary

Key points
  • Grouped data: mean and variance use midpoints; median, quartiles and mode use interpolation within a class. The results are estimates.
  • Index number: the ratio of a quantity in one period to its value in a base period, times 100.
  • Laspeyres uses base-period quantities, Paasche uses current-period quantities, and Fisher is their geometric mean. Laspeyres is usually the largest because of substitution.
  • Rebasing: divide by the new base value and multiply by 100. Chaining: multiply year-on-year relatives.
  • Deflating: real value = nominal value divided by (index/100).
  • Moving average: average of neighboring values; use a window equal to the seasonal period to remove seasonality (centered \(2 \times k\) for even \(k\)).