Price indexes based on a generalized mean of price relatives constitute a large family of bilateral index-number formulas that are consistent in aggregation, and any index based on the generalized mean can be used to make and aggregate elemental indexes. To see how to make superlative indexes as well, let’s start with a simple dataset of prices and quantities for two businesses over three periods. We’ll be making extensive use of the gpindex package for lower-level price-index functions; see the help pages for that package to get more detail.
library(piar)
library(gpindex)
prices <- data.frame(
period = rep(1:3, each = 6),
product = paste0("P", 1:6),
business = rep(c("B1", "B2"), each = 3),
price = 1:18,
quantity = 18:1
)
prices[c("back_price", "back_quantity")] <-
prices[back_period(prices$period, prices$product), c("price", "quantity")]
head(prices)
## period product business price quantity back_price back_quantity
## 1 1 P1 B1 1 18 1 18
## 2 1 P2 B1 2 17 2 17
## 3 1 P3 B1 3 16 3 16
## 4 1 P4 B2 4 15 4 15
## 5 1 P5 B2 5 14 5 14
## 6 1 P6 B2 6 13 6 13
As seen in vignette("piar")
, by default the
elemental_index()
function calculates a Jevons index
(equally-weighted geometric mean of price relatives). Although this is
the standard index-number formula for making elemental indexes, many
other types of index-numbers are possible. Among the unweighted
index-number formulas, the Carli index (equally-weighted arithmetic mean
of price relatives) is the historical competitor to the Jevons, and
requires specifying the order of the generalized mean r
when calling elemental_index()
. An order of 1 corresponds
to an arithmetic mean.
## Period-over-period price index for 2 levels over 3 time periods
## 1 2 3
## B1 1 4.666667 1.757937
## B2 1 2.233333 1.548485
The Coggeshall index (equally-weighted harmonic mean of price
relatives) is another competitor to the Jevons, but is seldom used in
practice. Despite it being more exotic, it is just as easy to make by
specifying an order r
of -1.
## Period-over-period price index for 2 levels over 3 time periods
## 1 2 3
## B1 1 4.131148 1.754499
## B2 1 2.214765 1.547408
Weights can be added to make, for example, elemental indexes using the geometric Laspeyres formula.
prices |>
elemental_index(
price / back_price ~ period + business,
weights = back_price * back_quantity
)
## Period-over-period price index for 2 levels over 3 time periods
## 1 2 3
## B1 1 3.853330 1.754015
## B2 1 2.202496 1.549081
The type of mean used to aggregate elemental indexes can be
controlled in the same way in the call to aggregate()
. The
default makes an arithmetic index, but any type of generalized-mean
index is possible.
Many superlative indexes can be made by supplying unequal and
time-varying weights when making the elemental indexes, usually from
information on quantities. The Törnqvist index is a popular superlative
index-number formula, using average period-over-period value shares as
the weights in a geometric mean. As elemental_index()
makes
a geometric index by default, all that is needed to make a Törnqvist
index is the weights.
tw <- grouped(index_weights("Tornqvist"))
prices |>
elemental_index(
price / back_price ~ period + business,
weights = tw(
price, back_price, quantity, back_quantity,
group = interaction(period, business)
)
)
## Period-over-period price index for 2 levels over 3 time periods
## 1 2 3
## B1 1 4.087422 1.759213
## B2 1 2.215995 1.556014
Making a Fisher index is more complex because it does not belong to the generalized-mean family. Despite this, it is possible to make weights to represent a Fisher index as a generalized mean of any order.
fw <- grouped(nested_transmute(0, c(1, -1), 0))
prices |>
elemental_index(
price / back_price ~ period + business,
weights = fw(
price / back_price, back_price * back_quantity, price * quantity,
group = interaction(period, business)
)
)
## Period-over-period price index for 2 levels over 3 time periods
## 1 2 3
## B1 1 4.076840 1.759215
## B2 1 2.215934 1.556046
Aggregating with a superlative index is more complex, and is the
subject of vignette("superlative-aggregation")
.