Learn R Programming

PriceIndices (version 0.2.3)

dissimilarity: Calculating the relative price and/or quantity dissimilarity measure between periods

Description

This function returns a value of the relative price and/or quantity dissimilarity measure.

Usage

dissimilarity(data, period1, period2, type = "p")

Value

This function returns a value of the relative price (dSP) and/or quantity (dSQ) dissimilarity measure. In a special case, when the type parameter is set to pq, the function provides the value of dSPQ measure (the relative price and quantity dissimilarity measure calculated as min(dSP,dSQ).

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).

period1

The first period (as character) limited to the year and month, e.g. '2019-03'.

period2

The second period (as character) limited to the year and month, e.g. '2019-04'.

type

The parameter indicates what type of dissimilarity measure is to be calculated. Possible values of the type parameter are: p (for the price dissimilarity measure calculation), q (for the quantity dissimilarity measure calculation) or pq (for the dSPQ measure calculation, i.e. the measure of relative price and quantity dissimilarity - see References).

References

Diewert, E. (2020). The Chain Drift Problem and Multilateral Indexes. Chapter 6 in: Consumer Price Index Theory (draft)

Examples

Run this code
dissimilarity(milk, period1="2018-12",period2="2019-12",type="q")
dissimilarity(milk, period1="2018-12",period2="2019-12",type="pq")

Run the code above in your browser using DataLab