Learn R Programming

PriceIndices (version 0.0.7)

price_index: A general function to compute a price index

Description

This function returns a value or values of the selected price index.

Usage

price_index(
  data,
  start,
  end,
  formula = "fisher",
  window = 13,
  splice = "movement",
  base = start,
  sigma = 0.7,
  interval = FALSE
)

Value

This function returns a value or values of the selected price index. If the interval parameter is set to TRUE then it returns a data frame with two columns: dates and index values. The function does not take into account aggregating over outlets or product subgroups (to consider these types of aggregating, please use the final_index or the final_index2 function).

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) and prodID (as numeric, factor or character). A column quantities (as positive numeric) is also essential even if the selected index is an unweighted formula (unit values are calculated).

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 and AG Mean indices (as numeric).

interval

A logical value indicating whether the function is to provide the price index 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).

Examples

Run this code
price_index(milk, start="2018-12", end="2020-02",formula="walsh",interval=FALSE)
price_index(milk, start="2018-12",end="2020-02",formula="tpd_splice",
splice="half",interval=TRUE)

Run the code above in your browser using DataLab