final_index {PriceIndices}R Documentation

A general function to compute a final price index

Description

This function returns a value (or values) of the selected final price index for the selected type of aggregation of partial results.

Usage

final_index(
  data = data.frame(),
  start = c(),
  end = c(),
  formula = c(),
  window = c(),
  splice = c(),
  base = c(),
  sigma = c(),
  r = c(),
  outlets = FALSE,
  groups = FALSE,
  by = c(),
  aggr = "fisher",
  interval = FALSE
)

Arguments

data

The user's data frame with information about sold products. It must contain columns: time (as Date in format: year-month-day,e.g. '2020-12-01'), prices (as positive numeric), quantities (as positive numeric) and prodID (as numeric, factor or character). A column retID (as numeric, factor or character) is also essential if the aggregation over outlets is considered. A column with grouping variable (as numeric, factor or character - indicated by the by parameter) is essential if the aggregation over product subgroups is considered.

start

The base period (as character) limited to the year and month, e.g. "2019-12".

end

The research period (as character) limited to the year and month, e.g. "2020-04".

formula

The character string indicating the price index formula is to be calculated. To see available options please use the link: PriceIndices.

window

The length of the time window if the multilateral index is selected (as positive integer: typically multilateral methods are based on the 13-month time window).

splice

A character string indicating the splicing method (if the multilateral splicing index is selected). Available options are: "movement", "window","half","mean" and their additional variants: "window_published", "half_published" and "mean_published".

base

The prior period used in the Young- or Lowe-type price indices (as character) limited to the year and month, e.g. "2020-01".

sigma

The elasticity of substitution parameter used in the Lloyed-Moulton, AG Mean or GEKS-LM indices (as numeric).

r

The non-zero parameter used in the quadratic mean of order r quantity / price index or in the GEKS-QM index (as numeric).

outlets

A logical parameter indicating whether the aggregation over outlets (defined by retID column) should be done.

groups

A logical parameter indicating whether the aggregation over product subgroups (indicated by 'by' parameter) should be done.

by

A character string which indicates a column name for creating product subgroups.

aggr

The formula used for aggregating partial index results (available values are: "arithmetic", "geometric", "laspeyres", "paasche", "fisher", "tornqvist").

interval

A logical value indicating whether the function is to provide price indices comparing the research period defined by end to the base period defined by start (then interval is set to FALSE) or all fixed base indices are to be presented (the fixed base month is defined by start).

Value

This general function returns a value or values of the selected final price index for the selected type of aggregation of partial results. If the interval parameter is set to TRUE, then it returns a data frame where its first column indicates dates and the remaining columns show corresponding values of all selected price indices.

Examples

final_index(coffee, start = "2018-12", end = "2019-12", 
         formula = "fisher", groups = TRUE, outlets = FALSE, 
         aggr = "tornqvist", by = "description")
final_index(milk, start = "2018-12", end = "2019-12", 
         formula = "fisher", groups = TRUE, outlets = TRUE, 
         aggr = "laspeyres", by = "description", 
         interval = TRUE)

[Package PriceIndices version 0.1.9 Index]