Learn R Programming

IndexNumR

An R package for computation of index numbers

IndexNumR provides a set of functions for computing various bilateral and multilateral indices. It is designed to compute price or quantity indices over time. Bilateral indices include Laspeyres, Paasche, Fisher, Tornqvist, Sato-Vartia, Walsh, CES, geometric Laspeyres, geometric Paasche, time-product-dummy and Geary-Khamis as well as elementary indices Dutot, Carli, Harmonic mean, CSWD and Jevons. All of these bilateral indices can be computed as period-on-period, fixed-base or chained.

Multilateral indices can be computed in the time series context using the GEKS, Weighted Time Product Dummy or Geary-Khamis indexes, and updating is provided via the window, movement, half, mean, fbew or fbmw splicing methods. The GEKS method is computed using either the Fisher, Tornqvist, Walsh, Jevons or TPD index number methods.

The package also provides functions to compute measures of dissimilarity between time periods, which can be used to choose the linking period for chained indices.

A sample dataset is included called CES_sigma_2, which is a dataset containing prices and quantities on four products over twelve periods, but additional datasets assuming different values of the elasticity of substitution can be computed using the function CESData.

There is also a function dominicksData that can be used to download the Dominicks Finer Foods scanner data from the Chicago Booth School of Business.

Installation

You can install the released version of IndexNumR from CRAN with:

install.packages("IndexNumR")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("grahamjwhite/IndexNumR")

Example

To estimate a simple chained Laspeyres price index using the CES_sigma_2 dataset,

library(IndexNumR)

priceIndex(CES_sigma_2, 
           pvar = "prices", 
           qvar = "quantities", 
           pervar = "time", 
           prodID = "prodID", 
           indexMethod = "laspeyres", 
           output = "chained")
#>            [,1]
#>  [1,] 1.0000000
#>  [2,] 0.9673077
#>  [3,] 1.2905504
#>  [4,] 1.3382002
#>  [5,] 1.2482444
#>  [6,] 1.7346552
#>  [7,] 1.6530619
#>  [8,] 1.4524186
#>  [9,] 1.8386215
#> [10,] 1.7126802
#> [11,] 2.1810170
#> [12,] 2.2000474

A GEKS index with mean splicing and an 11 period window is estimated as follows,

GEKSIndex(CES_sigma_2, 
          pvar = "prices", 
          qvar = "quantities", 
          pervar = "time", 
          prodID = "prodID", 
          indexMethod = "tornqvist", 
          window = 11, 
          splice = "mean")
#>            [,1]
#>  [1,] 1.0000000
#>  [2,] 0.8927314
#>  [3,] 1.0776386
#>  [4,] 1.1127724
#>  [5,] 0.9310834
#>  [6,] 1.1785361
#>  [7,] 1.1219447
#>  [8,] 0.9380228
#>  [9,] 1.0951667
#> [10,] 0.9501914
#> [11,] 1.1277725
#> [12,] 1.1330748

More examples are contained in the package vignette.

vignette("indexnumr", package = "IndexNumR")

Copy Link

Version

Install

install.packages('IndexNumR')

Monthly Downloads

602

Version

0.6.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Graham White

Last Published

November 10th, 2023

Functions in IndexNumR (0.6.0)

priceIndicator

Calculate a price indicator
shares

Compute expenditure shares for each product and time period
monthIndex

Generate an index of months
valueDecomposition

valueDecomposition
values

Compute values (price x quantity)
imputeCarryPrices

Fill all missing prices with carry forward/backward prices
groupIndexes

Calculate price indexes for product groups
productChanges

Product ID's for appearing/disappearing products
quarterIndex

Generate an index of quarters
relativeDissimilarity

Computes measures of relative dissimilarity between all periods
unitValues

Aggregates prices to unit values and quantities to sums
quantityIndicator

Compute a quantity indicator
GEKSIndex

Compute a GEKS multilateral index
quantityIndex

Computes a bilateral quantity index
yearOverYearIndexes

Estimate year-over-year indexes
predictedShares

Predicted shares for predicted share relative price dissimilarity
priceIndex

Computes a bilateral price index
weekIndex

Generate an index of weeks
yearIndex

Generate an index of years
GKIndex

Compute the Geary-Khamis index
IndexNumR-package

IndexNumR: A package for computing index numbers
WTPDIndex

Compute a weighted time-product-dummy multilateral index
elasticity

Computes the elasticity of substitution
CESData

Generate data assuming CES preferences
dominicksData

Get data from the Dominicks dataset
evaluateMatched

Evaluate product overlap between periods
imputeQuantities

Impute quantities when only prices are available
mixScaleDissimilarity

Computes mix, scale and absolute dissimilarity measures
maximumSimilarityLinks

Finds periods to link using minimum dissimilarity.
CES_sigma_2

Dataset of prices and quantities on four products
DominicksWeeks

Date information for the Dominicks data