calc_di
Go to your working directory and open the csv “Example_shocks”.
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.
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.
Save the edited csv file.
Upload the edited file to R by running the following function in the terminal:
exampledf <- read.csv(file_name, # File name or full file path
header = TRUE, # Header indicator (set to TRUE)
sep = ",", # Value separator used in the file
dec = ".", # Decimal point format used
...) # Additional arguments to be passed
calc_di
that this is the file from which to
take the price shocks to be applied.
calc_di( year, # Base year for the simulation (available 2006-2021)
elevate = F, # Elevation of raw data (set to FALSE)
shocks = exampledf, # Indicate here the name of the uploaded file with shocks
...) # Additional arguments to be passed
[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.
calc_di
to calculate distributional impacts
Select one of the variables that the function returns in the console. For example, “ZONA”.
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, # Base year for the simulation
elevate = F, # Elevation of raw data (set to FALSE)
shocks = exampledf, # Name of the uploaded file with shocks
var_impact = "DECILE", # Indicate here the socioeconomic variable to be used
...) # Additional arguments to be passed
var_impact
argument of
calc_di
.
#Create a vector
vars <- c("ZONA", "TAMAMU")
#Introduce the vector in var_impact argument
calc_di(year, # Base year for the simulation
elevate = F, # Elevation of raw data (set to FALSE)
shocks = exampledf, # Name of the uploaded file with shocks
var_impact = vars, # Indicate here the name of the vector with the selected variables
...) # Additional arguments to be passed
example_vars <- read.csv(file_name, # File name or full file path
header = TRUE, # Header indicator (set to TRUE)
sep = ",", # Value separator used in the file
dec = ".", # Decimal point format used
...) # Additional arguments to be passed
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, # Base year for the simulation
elevate = F, # Elevation of raw data (set to FALSE)
shocks = exampledf, # Name of the uploaded file with shocks
var_intersec = example_vars, # Indicate here the file name of the selected set of variables
...) # Additional arguments