Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Consumer price index from a fixed basket with Jevons elementary aggregates, chain-linking and average inflation rates

cpi(p_0, p_t, q_b, V_b, I_Dec, L_Jan, L_t, I_1, I_2, n) = (I_0t, J, I_t, g)

Maps the base-period and current prices of a fixed basket, with the quantities or expenditure of an earlier weight reference period, to a Lowe-type index level, and combines the matched prices of one elementary aggregate by the Jevons geometric mean. It also joins yearly links into a long series on the 2015 = 100 reference and maps two index values and the months between them to an average annual inflation rate. The ratio of two index values is the I_b / I_a input of the live price-year adjustment HE-FM-COST-002 under HE-FN-COST-001, which is not repeated here, and a ratio of the US CPI for all urban consumers enters the Medicaid additional rebate of HE-FM-340B-002. Currency conversion and purchasing power parities are left to the Basket of Countries page. Notation follows the Consumer Price Index article.

  • Lowe fixed-basket consumer price index of a two-item basket

    E_0 = p1_0 * q1_b + p2_0 * q2_b; E_t = p1_t * q1_b + p2_t * q2_b; I_0t = 100 * E_t / E_0

    Prices the same basket of quantities q_b, bought in the weight reference period b, at time t prices and at base-period prices, and expresses the first cost as a percentage of the second, the Laspeyres-type index of section 3.3 of the ONS technical manual. Because the UK quantities come from a period before the base period, the manual classes the CPI and CPIH as Lowe-type indices. The same index is a weighted arithmetic average of the price relatives p_t / p_0, each weighted by its share of the basket cost at base-period prices, the route HE-CF-CPI-001 follows from expenditure data. The formula is written out for two items so that the calculator runs, and the Excel and code forms take any number of items. A ratio of two index values is the input of HE-FM-COST-002.

  • Jevons elementary aggregate of three matched consumer prices

    J = (p1_t / p1_0 * p2_t / p2_0 * p3_t / p3_0)^(1 / 3)

    Combines the prices of matched products within one elementary aggregate, where no expenditure weights exist, as the geometric mean of their price relatives, the formula the ONS technical manual names as the one primarily used at this level in the UK CPI and CPIH (section 3.4). Each price carries the same weight, the reciprocal of the number of prices. The manual gives an algebraically equivalent form, the ratio of the geometric means of current and base prices. J is a ratio, and 100 times it gives the elementary index on the scale of HE-FM-CPI-001; item and higher-level indices are weighted averages of these elementary indices (section 3.5). The formula is written out for three prices so that the calculator runs.

  • Chain-linked consumer price index from the December level and two annual links

    I_t = I_Dec * L_Jan / 100 * L_t / 100

    Builds a long-run index level for month t of year y from the published level for December of year y minus 1 on the 2015 = 100 reference, the January index of year y on the previous December = 100, and the index for month t on January of year y = 100. Section 3.6 of the ONS technical manual sets out the two-link product for the CPI and CPIH, whose weights are updated twice a year, and prints it as the product of the three index values with no divisor. Each link is stated on a base of 100, so here each is divided by 100 before it multiplies the December level (derived from the link bases), as the manual's RPI chaining formulas in section 12.4.2 and its July 1987 example in section 11.2 divide the link by 100. For January itself L_t is 100. A series chained once a year, such as the RPI, is entered with L_Jan = 100 and the long-run level of its January link month in I_Dec. Ratios of chained levels such as the D7BT series are what HE-FM-COST-002 takes.

  • Average annual inflation rate between two consumer price index values

    g = (I_2 / I_1)^(12 / n) - 1

    Turns the ratio of a later index value I_2 to an earlier value I_1, n months apart, into the constant annual rate that compounds to the same change, the equation section 11.3 of the ONS technical manual gives for an annual average inflation rate over any period other than a year. With n = 12 it is the change on the figure 12 months earlier, the annual inflation rate of section 11.2. The ratio I_2 / I_1 is the I_b / I_a of HE-FM-COST-002, which uprates a cost and is not repeated here. The financial-year averages that the article compares are built in HE-CF-CPI-002.