generate_CES: Generating an artificial scanner dataset in the CES model

View source: R/f_data_processing.R

generate_CESR Documentation

Generating an artificial scanner dataset in the CES model

Description

This function provides artificial scanner datasets where prices are lognormally distributed and quantities are obtained under a CES utility.

Usage

generate_CES(
  pmi = c(),
  psigma = c(),
  prec = 2,
  elasticity = 0.7,
  S = 1000,
  alfa = c(),
  n = 100,
  n0 = 1,
  r = 1,
  r0 = 1,
  start,
  days = FALSE
)

Arguments

pmi

A numeric vector indicating mi parameters for lognormally distributed prices from the subsequent months.

psigma

A numeric vector indicating sigma parameters for lognormally distributed prices from the subsequent months.

prec

A numeric value indicating precision, i.e. the number of decimal places, for generating prices.

elasticity

The elasticity of substitution. The default value is 0.7.

S

Sum of spending. The default value is 1000.

alfa

A numeric vector indicating positive weights that reflect the consumer preferences.By default, this vector is randomized based on a uniform distribution.

n

An integer parameter indicating the number of products which are to be generated.

n0

An integer parameter indicating the first (the smallest) prodID.

r

An integer parameter indicating the number of outlets (retailer sale points) for which prices and quantities are to be generated.

r0

n0 An integer parameter indicating the first (the smallest) retID.

start

The first period in the generated data frame (as character) limited to the year and month, e.g. '2019-12'.

days

A logical parameter indicating whether the trading day in a given month is to be randomised. The default value of days is FALSE, which means that each transaction for a given month takes place on the first day of the month.

Value

This function returns an artificial scanner dataset where prices are lognormally distributed, quantities are calculated under the assumption that consumers have CES (Constant Elasticity of Substitution) preferences and their spending on all products is S. The characteristics for the lognormal price distribution are set by pmi and psigma parameters. This function works for a fixed number of products and outlets (see n and r parameters). The generated dataset is ready for further price index calculations.

References

(2004). Consumer Price Index Manual. Theory and practice. ILO/IMF/OECD/UNECE/Eurostat/The World Bank, International Labour Office (ILO), Geneva.

Examples

#Generating an artificial dataset (the elasticity of substitution is 1.25)
df<-generate_CES(pmi=c(1.02,1.03),psigma=c(0.04,0.03),
elasticity=1.25,start="2020-01",n=100,days=TRUE)
#Verifying the elasticity of substitution
elasticity(df, start="2020-01",end="2020-02")

PriceIndices documentation built on July 9, 2023, 6:20 p.m.