shrinkflation: Detecting and summarising downsized and upsized products.

shrinkflationR Documentation

Detecting and summarising downsized and upsized products.

Description

This function detects and summarises downsized and upsized products.

Usage

shrinkflation(
  data,
  start,
  end,
  type = "shrinkflation",
  min_p_change = 0,
  max_p_change = Inf,
  min_s_change = 0,
  max_s_change = Inf,
  prec = 3,
  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 (with standardised 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. "2024-01".

end

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

type

A parameter specifying what phenomenon is to be included in the resulting elements of the returned list (i.e. in returned products_detected, df_detected and df_reduced). The available values are: shrinkflation, shrinkdeflation, sharkflation, unshrinkdeflation, unshrinkflation and sharkdeflation (default value is: shrinkflation).

min_p_change

Lower limit for unit price change, i.e.: a product is considered if the percentage change in its unit price is greater than the value of this parameter. The default value is zero, possibly positive values can be considered (in percentage).

max_p_change

Upper limit for unit price change, i.e.: a product is considered if the percentage change in its unit price is less than the value of this parameter. The default value is Inf, possibly positive values can be considered (in percentage).

min_s_change

Lower limit for size change, i.e.: a product is considered if the percentage change in its size is greater than the value of this parameter. The default value is zero, possibly positive values can be considered (in percentage).

max_s_change

Upper limit for size change, i.e.: a product is considered if the percentage change in its size is less than the value of this parameter. The default value is Inf, possibly positive values can be considered (in percentage).

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 and upsized products. The function detects phenomena such as: shrinkflation, shrinkdeflation, sharkflation, unshrinkdeflation, unshrinkflation, sharkdeflation (see the type parameter). It returns a list containing the following objects: df_changes - data frame with detailed information on downsized and upsized products with the whole history of size changes, df_type - data frame with recognized type of products, df_overview - a table with basic summary of all detected products grouped by the type parameter, products_detected with prodIDs of products indicated by the 'type' parameter, df_detected being a subset of the data frame with only detected products, df_reduced which is the difference of the input data frame and the data frame containing the detected products, and df_summary which provides basic statistics for all detected downsized and upsized products (including their share in the total number of products and mean price and size changes).

References

Białek, J., Bobel, A., Oprych-Franków D. (2004). Immeasurability of shrinkflation in the CPI? Automatic downsizing detection using scanner data. 18th Meeting of the Ottawa Group, Ottawa.

Examples

#Data matching over time
df<-data_matching(data=data_DOWN_UP_SIZED, start="2024-01", end="2024-02", 
codeIN=TRUE,codeOUT=TRUE,description=TRUE, 
onlydescription=FALSE,precision=0.9,interval=FALSE)
# Extraction of information about grammage (if needed)
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 and upsized products detection
result<-shrinkflation(data=df, start="2024-01","2024-02", 
prec=3, interval=FALSE, type="shrinkflation")
result$df_changes
result$df_type
result$df_overview
result$products_detected
result$df_detected
result$df_reduced
result$df_summary


PriceIndices documentation built on Sept. 11, 2024, 8:35 p.m.