Bread, Laptops and a Chain of Fisher Links

chain-weighted real GDP · Fisher index · Laspeyres · Paasche · nested loops

Real GDP at fixed base-year prices depends a lot on which base year you pick when relative prices change fast. Here laptops get much cheaper while bread gets dearer:

  • at year-0 prices (laptops expensive), real GDP grows from 1200 to 4208, a factor of 3.5;
  • at year-2 prices (laptops cheap), it grows from 640 to 1849.6, a factor of 2.9.

Many statistics offices therefore chain: they measure each year's growth with the prices of that year and the year before, and multiply the yearly growth factors together. With S(a, b) = \sum_{\text{goods}} p_a \, q_b (prices of year a times quantities of year b), the links for year t \ge 1 are

L_t = \frac{S(t-1,\ t)}{S(t-1,\ t-1)} \qquad P_t = \frac{S(t,\ t)}{S(t,\ t-1)} \qquad F_t = \sqrt{L_t \, P_t}

(L_t values both years' output at last year's prices, P_t at this year's; the Fisher link F_t is their geometric mean). The chained quantity index starts at I_0 = 100 and I_t = I_{t-1} \, F_t. Chained real GDP in the money of reference year r is

R_t = S(r, r) \cdot \frac{I_t}{I_r}

so it equals nominal GDP in year r. prices[good] and quantities[good] are lists over years 0, ..., n-1, with the same goods in both.

Write chain_fisher(prices, quantities, ref) that returns the pair of lists (index, real).

Examples

Input:  prices     = {"bread": [2, 2.2, 2.4], "laptops": [1000, 600, 400]}
        quantities = {"bread": [100, 102, 104], "laptops": [1, 2, 4]}
        ref = 0
Output: ([100.0, 178.61759124576454, 322.85635945031413],
         [1200.0, 2143.4110949491746, 3874.2763134037696])
Explanation: in year 1, L = 2204 / 1200 = 1.8367 and P = 1424.4 / 820 = 1.7371,
so F = 1.7862. Chained real GDP grows by a factor of 3.23, between 2.9 and 3.5.

Input:  the same prices and quantities, ref = 2
Output: ([100.0, 178.61759124576454, 322.85635945031413],
         [572.8863458502336, 1023.2757915335671, 1849.6])

Constraints

  • all prices are positive, and every year at least one good has a positive quantity
  • floats are compared with a tolerance of 1e-6

Goals

  • Compute Laspeyres and Paasche quantity links between neighbouring years
  • Combine them into a Fisher link and chain the links into an index
  • Express a chained index as real GDP in a reference year's money
Starting Python…