gpindex: Generalized Price and Quantity Indexes

Description Usage Note Author(s) References See Also


A small package for calculating lots of different price indexes, and by extension quantity indexes. Provides tools to build and work with any type of generalized bilateral index (of which most price indexes are), along with a few important indexes that don't belong to the generalized family. Implements and extends many of the methods in Balk (2008, ISBN:978-1-107-40496-0) and ILO, IMF, OECD, Eurostat, UN, and World Bank (2004, ISBN:92-2-113699-X) for bilateral price indexes.


To avoid duplication, everything is framed as a price index; it is trivial to turn a price index into its analogous quantity index by simply switching prices and quantities.

Generalized indexes are a large family of price indexes with nice properties (e.g., Balk, 2008, Chapter 3). Almost all bilateral price indexes used in practice are either generalized indexes (like the Laspeyres and Paasche index) or are nested generalized indexes (like the Fisher index).

All generalized indexes are based on the generalized mean, which is provided by the mean_generalized() function. Given a set of price relatives and weights, any generalized price index is easily calculated as a generalized mean.

Two important functions for decomposing generalized means are given by weights_transmute() and weights_factor(). These functions can be used to calculate quote contributions and price-update weights for generalized indexes.

Together these functions, along with logmean_generalized(), provide the key mathematical apparatus to work with any type of generalized index, and those that are nested generalized indexes. See the vignette for more details: vignette("gpindex").

On top of these basic mathematical tools are functions for making standard price indexes when both prices and quantities are known. Weights for a large variety of indexes can be calculated with index_weights(), which can be plugged into the relevant generalized mean to calculate most common price indexes, and many uncommon ones. The price_index functions provide a simple wrapper, with the quantity_index() function turning each of these into its analogous quantity index.


There are a number of R packages on the CRAN for working with price/quantity indexes (e.g., 'IndexNumber', 'productivity', 'IndexNumR', 'micEconIndex'). Compared to existing packages, this package provides greater flexibility for building index numbers in the class of generalized price and quantity indexes.

While there is support for a large number of index-number formulas out-of-the box, the focus is on the tools to easily make and work with any type of generalized price index. No assumptions are made about how data are stored or arranged; rather, the functions in the package are designed to work with atomic vectors, and can be used with R's standard data-manipulation functions for more complex data structures. Compared to existing packages, this package is suitable for building custom price/quantity indexes, and learning about or researching different types of index-number formulas.


Maintainer: Steve Martin


Balk, B. M. (2008). Price and Quantity Index Numbers. Cambridge University Press.

ILO, IMF, OECD, Eurostat, UN, and World Bank. (2004). Consumer Price Index Manual: Theory and Practice. International Monetary Fund.

ILO, IMF, OECD, Eurostat, UN, and World Bank. (2004). Producer Price Index Manual: Theory and Practice. International Monetary Fund.

See Also

gpindex documentation built on Feb. 3, 2021, 1:06 a.m.