R/price_data.R

#' Sample price/quantity data
#'
#' Prices and quantities for six products over five periods.
#'
#' @name price_data
#' @aliases price6 quantity6
#' @docType data
#' @format
#' Each data frame has 6 rows and 5 columns, with each row corresponding
#' to a product and each column corresponding to a time period.
#'
#' @note
#' Adapted from tables 3.1 and 3.2 in Balk (2008), which were adapted
#' from tables 19.1 and 19.2 in the PPI manual.
#'
#' @source
#' Balk, B. M. (2008). *Price and Quantity Index Numbers*.
#' Cambridge University Press.
#'
#' ILO, IMF, OECD, UNECE, and World Bank. (2004).
#' *Producer Price Index Manual: Theory and Practice*.
#' International Monetary Fund.
#'
#' @examples
#' # Recreate tables 3.4, 3.6, and 3.12 from Balk (2008)
#'
#' index_formulas <- function(p1, p0, q1, q0) {
#'   c(
#'     harmonic_laspeyres = harmonic_index("Laspeyres")(p1, p0, q0),
#'     geometric_laspeyres = geometric_index("Laspeyres")(p1, p0, q0),
#'     laspeyres = arithmetic_index("Laspeyres")(p1, p0, q0),
#'     paasche = harmonic_index("Paasche")(p1, p0, q1),
#'     geometric_paasche = geometric_index("Paasche")(p1, p0, q1),
#'     palgrave = arithmetic_index("Palgrave")(p1, p0, q1),
#'     fisher = fisher_index(p1, p0, q1, q0),
#'     tornqvist = geometric_index("Tornqvist")(p1, p0, q1, q0),
#'     marshall_edgeworth = arithmetic_index("MarshallEdgeworth")(p1, p0, q1, q0),
#'     walsh1 = arithmetic_index("Walsh1")(p1, p0, q1, q0),
#'     vartia2 = geometric_index("Vartia2")(p1, p0, q1, q0),
#'     vartia1 = geometric_index("Vartia1")(p1, p0, q1, q0),
#'     stuvel = stuvel_index(2, 2)(p1, p0, q1, q0)
#'   )
#' }
#'
#' round(t(mapply(index_formulas, price6, price6[1], quantity6, quantity6[1])), 4)
#'
NULL
marberts/gpindex documentation built on Nov. 25, 2024, 1:12 p.m.