shrinkflation {PriceIndices}R Documentation

Detecting and summarising downsized products.

Description

This function detects and summarises downsized products.

Usage

shrinkflation(data, start, end, min_change = 0, prec = 2, 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') and prodID (as numeric, factor or character), prices and quantities (as numeric), grammage (as numeric), unit (as character) and description (as character). Important: prices must be standardized beforehand, that is, they must refer to the sales unit (the data_norm function can be used for this).

start

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

end

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

min_change

The minimum increase in the average (unit) price of a product in order for it to be considered downsized at the same time. The default value is zero, possibly positive values can be considered.

prec

Number of decimal places for the presented summary results.

interval

A parameter that specifies whether the search for downsized products should consider the entire time interval, or only the compared months specified by the start and end parameters.

Value

This function detects and summarises downsized products. It returns a list containing the following objects: changes with detailed information on downsized products, products_downsized with prodIDs of downsized products, df_downsized being a subset of the data frame with only downsized products, df_reduced which is the difference of the input data frame and the data frame containing the downsized products, and df_summary which provides basic statistics for detected downsized products (including their share in the total number of products).

Examples

#Data matching over time
df<-data_matching(data=dataDOWNSIZED, start="2024-01", end="2024-02", 
codeIN=TRUE,codeOUT=TRUE,description=TRUE, 
onlydescription=FALSE,precision=0.9,interval=FALSE)
# Extraction of information about grammage
df<-data_unit(df,units=c("g|ml|kg|l"),multiplication="x")
# Price standardization
df<-data_norm(df, rules=list(c("ml","l",1000),c("g","kg",1000)))
# Downsized products detection
result<-shrinkflation(data=df, start="2024-01","2024-02", prec=3, interval=FALSE)
result$changes
result$products_downsized
result$df_downsized
result$df_reduced
result$df_summary

[Package PriceIndices version 0.1.9 Index]