linearAggExc.Rd
Computes index scores and ranks using linear aggregation for one or multiple time periods. Automatically computes alternative scores and ranks for inclusion and exclusion of individual indicators.
linearAggExc(x, direction, weight, path, year1, yearT)
A dataframe. Column 1 - statistical units (countries, regions, companies etc.). Column 2 - time (year, or month, or day etc. - numeric). Rest of columns - values for individual variables. The pre-processing (e.g. standardization, winsoriztion) has to be done by the researcher before using this function. For standardization, one may use the rescaleColumns() function of this package.
A vector. Specifies the direction (as 1 or -1) for each individual variable in the index.
A vector. Specifies the weight assigned to each individual variable.
Specifies the path to the folder where the returned .csv files of scores and ranks are to be saved.
Numeric. Use for multiple years (time periods). Specifies the first year (period) in x.
Numeric. Use for multiple years (time periods). Specifies the last year (period) in x.
Writes two .csv files per year - Index scores and Ranks - in the path folder. Both index scores and ranks are computed using all individual variables (column 3) and when alternatively dropping one individual variable (columns 4 to last). Countries and time are written in column 1 and 2, respectively. In case of one year data (x), the function returns two dataframes - scores and ranks.
For theoretical information on the linear aggregation method and on the inclusion-exclusion of individual indicators: Nardo et al.(2008). Handbook on Constructing Composite Indicators and User Guide. Publisher: OECD; Editor: European Commission, Joint Research Centre and OECD.
dataTest_oneYear[1:5,1:5]
#> country time fixedTerm fixedTermComp selfEmployment
#> 1 Belgium 2002 206.1538 248.9270 485.8757
#> 2 Bulgaria 2002 135.3846 141.6309 NA
#> 3 Czech Republic 2002 NA NA 146.8927
#> 4 Denmark 2002 243.0769 154.5064 242.9379
#> 5 Germany 2002 341.5385 47.2103 310.7345
direction=c(1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1)
weight=c(1/18, 1/18, 1/18, 1/18, 1/18, 1/18, 1/15, 1/15, 1/15, 1/75, 1/75, 1/75, 1/75, 1/75, 1/15, 1/6, 1/6)
a=linearAggExc(dataTest_oneYear, direction, weight)
#to also store the scores and ranks into 2 .csv files:
#a=linearAggExc(dataTest, direction, weight, path="E:/Sample folder")
a$scores[1:5,1:5]
#> Statistical unit Time S0 S1 S2
#> 1 Belgium 2002 -30.582826 -42.035818 -16.753546
#> 2 Bulgaria 2002 9.376503 1.855135 17.244886
#> 3 Czech Republic 2002 16.800431 16.800431 16.800431
#> 4 Denmark 2002 -90.919783 -104.424056 -82.336092
#> 5 Germany 2002 3.791631 -15.182728 6.414426
a$ranks[1:5,1:5]
#> Statistical unit Time S0 S1 S2
#> 1 Belgium 2002 14 14 14
#> 2 Bulgaria 2002 9 8 7
#> 3 Czech Republic 2002 6 5 8
#> 4 Denmark 2002 25 25 24
#> 5 Germany 2002 11 11 12
direction=c(1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1)
weight=c(1/18, 1/18, 1/18, 1/18, 1/18, 1/18, 1/15, 1/15, 1/15, 1/75, 1/75, 1/75, 1/75, 1/75, 1/15, 1/6, 1/6)
#linearAggExc(x=dataTest_moreYears, direction=direction, weight=weight, path="E:/Sample folder", year1=2001, yearT=2003)