# Aggregation of sub-components of the HDI with simulated weights # This is an R software code for obtaining index outcomes with the simulated 500 capacities. # The simulated weights and achievements in three dimensions of HDI are inputted. # For each capacity, HDI scores for countries are obtained. # “HDI.csv” provides the subcomponent achievements in income, health and education indices in 2018, respectively. This is used as one of the input files to obtain composite scores. Furthermore, actual data used for calculations are also uploaded as “2018 HDI data” for reference. # The HDI is recalculated regularly and interest readers could collate relevant input data from http://hdr.undp.org/en/data library (kappalab) setwd("C:/Security copy") indicators <- read.csv("HDI.csv", sep=";", dec=".") #inputs the HDI indicators - attached HDI scores in 2018 and HDI.csv as an example# attach(indicators) weightset <- read.csv("HDI_Simulation.csv", sep=";", dec=".") # Insert simulated weights - This is obtained via simulation# attach(weightset) mu_HDI <- matrix(0, 8,500) mu_HDI <- weightset # set up number of runs for the simulation HDI <- matrix(0, 189, 500) # Begin large loop on y, Monte Carlo procedure set.seed(281089) for (y in 1:500){ # Aggregates the values of the sub-components into the HDI using Choquet. for (i in 1: 189) { HDI[i,y] <- Choquet.integral(capacity(mu_HDI[,y]),c(Income[i],Health[i],Education[i])) } } # Ends the aggregation write.table(x=HDI, row.names=FALSE, sep=";" ,dec=".", "HDI_scores.csv")