geks: GEKS index

Description Usage Arguments Value References See Also Examples

View source: R/geks.R

Description

Calculate an inter-temporal GEKS price index, as described in chapter 7 of Balk (2008) and by Ivancic et al. (2011).

Usage

1
2
3
4
5
6
7
geks(f)

tornqvist_geks(price, quantity, period, product, 
               window = nlevels(period), n = window - 1, na.rm = FALSE)

fisher_geks(price, quantity, period, product, 
            window = nlevels(period), n = window - 1, na.rm = FALSE)

Arguments

f

A price_index function that uses information on both base and current-period prices and quantities, and satisfies the time-reversal test. Usually a Tornqvist, Fisher, or Walsh index.

price, quantity

A numeric vector of prices/quantities.

period

A factor, or something that can be coerced into one, that gives the corresponding time period for each element in price and quantity. The ordering of time periods follows the levels of period to agree with cut().

product

A factor, or something that can be coerced into one, that gives the corresponding product identifier for each element in price and quantity.

window

The length of the window. The default is a window that encompasses all periods in period. Values that are neither integers nor length 1 are silently truncated to a length 1 integer.

n

A number giving the length of the index series for each window. For example, if there are 13 periods in window, setting n = 1 gives the index for period 13. The default gives an index for each period in window. Values that are neither integers nor length 1 are silently truncated to a length 1 integer.

na.rm

Should missing values for price and quantity be removed when calculating the index? By default missing values will return a missing value for the index.

Value

geks() returns a function to calculate a GEKS index with the desired index-number formula.

tornqvist_geks() and fisher_geks() both return a list with a named numeric vector giving the value of the respective period-over-period GEKS index for each window.

References

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

Ivancic, L., Diewert, W. E., and Fox, K. J. (2011). Scanner data, time aggregation and the construction of price indexes. Journal of Econometrics, 161(1): 24–35.

See Also

price_index for price-index functions that can be used in geks().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
price <- 1:6
quantity <- 6:1
period <- rep(1:3, 2)
product <- rep(letters[1:2], each = 3)

tornqvist_geks(price, quantity, period, product)

tornqvist_geks(price, quantity, period, product, window = 2)

# Missing data
quantity[2] <- NA

# Use all non-missing data
fisher_geks(price, quantity, period, product, na.rm = TRUE)

# Remove records with any missing data
fg <- geks(balanced(fisher_index))
fg(price, quantity, period, product, na.rm = TRUE)

marberts/gpindexExtra documentation built on Dec. 21, 2021, 1:49 p.m.