Step by step tutorials

Example 1. How to enter price shocks in calc_di

  1. Download the example file into your directory by running the following function in the terminal:
  1. Go to the defined folder in your directory and open the csv “Example_shocks”.

  2. Define the scenarios: Each column Scenario__ is a scenario. To run calc_di for a single scenario delete column Scenario2. To add another scenario, copy column Scenario2 to the right and change the heading to Scenario3. You can also rename the scenarios by changing the heading of each column (e.g. renaming “Scenario1” to “Shock1”). It is recommended to keep the names short, as additional variables with this name will be created later and inserted into the graphs.

  3. Enter the price shocks: Each row corresponds to a COICOP code [1] . Enter in each row the price change to be applied to each coicop in each scenario (column). A price shock greater than 1 indicates a price increase (e.g. 1.1 indicates a 10% increase) and less than 1 indicates a price decrease (e.g. 0.9 indicates a 10% decrease). If there is no shock in that category, keep 1.

  4. Save the edited csv file.

  5. Upload the edited file to R by running the following function in the terminal:

file_name <- read.csv(file,        # File name or full file path
             header = TRUE,        # Read the header (TRUE)
             sep = ",",            # Value separator
             dec = ".",            # Decimal point
             ...)                  # Additional arguments
  1. Indicate to calc_di that this is the file from which to take the price shocks to be applied.
calc_di( year,                 
         elevate = F,
         shocks = file_name,   # Indicate here your file name
         ...)

[1] The COICOP variables of the file correspond to the aggregate variables of the package, if you are not going to aggregate the COICOP variables you have to replace the column labels by the COICOP variables that appear in your dataset.

Example 2. How to enter the variables for which we want calc_di to calculate distributional impacts

Introduce individual variables (var_impact)

  1. To know the variables for which the calculation of basic distributional impacts is available run the following function.
  1. Select one of the variables that the function returns in the console. For example, “ZONA”.

  2. Enter that variable in the var_impact argument of calc_di. By default, var_impact = "all" , i.e. it calculates the distributional impacts for all variables returned by available_var_impact(). For more information on variables click here.

calc_di( year,                 
        elevate = F,
        shocks ,   
        var_impact = "ZONA",       # Indicate here the selected variable
        ...)
  1. In case you want to calculate distributional impacts for several variables, e.g. for “ZONE” and “TAMAMU”, create a vector with these variables and enter it in the var_impact argument of calc_di.
#Create a vector
vars <- c("ZONA", "TAMAMU")

#Introduce the vector in var_impact argument
calc_di( year,                 
        elevate = F,
        shocks ,   
        var_impact = vars,       # Indicate here the name of the vector with the selected variables
        ...)

Introduce a set of variables (var_intersec)

  1. To know the set of variables for which the calculation of intersectional distributional impacts is available run the following function. The function returns a table with the set of variables (category_a and category_b) for which the calculation of intersectional distributional impacts is available.
  1. Create a table with the set of variables for which you want to calculate distributional impacts in the format predefined in the package. To do this, run the following function that saves a csv file in your directory, open it and delete the rows with the combinations you are not interested in. Once you have a table with only the set of variables you are interested in, save it.
  1. Upload the edited file to R by running the following function in the terminal:
file_name <- read.csv(file,        # File name or full file path
             header = TRUE,
             ...)                  # Additional arguments
  1. Enter the file in the var_intersec argument in calc_di. By default, var_intersec = NULL , i.e. iif no data is entered in this argument it will not calculate any intersectional impacts, it will only calculate distributional impacts for individual variables. For more information on variables click here.
calc_di( year,                 
        elevate = F,
        shocks ,   
        var_intersec = file_name,       # Indicate here the file name of the selected set of variables
        ...)