Computes the average shift in ranking. The novelty of the function is that it extends the 1 period formula to encompass multiple time periods. It returns three types of average shift in ranking - total, per year, and per country and year.

rankShift_avg(rInit, rNb)

Arguments

rInit

A dataframe. Column 1 - statistical units (countries, regions, companies etc.). Rest of columns - initial ranks for each year.

rNb

A list of dataframes (one dataframe per year - result of ranksCount()). Each dataframe contains the number of times a statistical unit takes a certain rank. Column 1 - statistical units; column 2 - time; rest of columns - the number of times the statistical unit takes rank 1, rank 2 and so on.

Value

A list with three objects: Total average shift in ranking ($RsTotal); Average shift in rakning for each year ($RsYear); Total shift in ranking per country in each year ($RsCountry). Please read country=statistical unit; year=time period.

Examples

ranksInitial2001_2003[1:5,]
#>          Country X2001 X2002 X2003
#> 1        Belgium    14    14    14
#> 2       Bulgaria     8     9     9
#> 3 Czech Republic     5     6     6
#> 4        Denmark    25    25    24
#> 5        Germany    13    11    12
names(ranksNb2001_2003)
#> [1] "ranksNb2001" "ranksNb2002" "ranksNb2003"
a=rankShift_avg(ranksInitial2001_2003, ranksNb2001_2003)
a$RsTotal
#> [1] 0.01544084
a$RsYear
#> [1] 0.01553103 0.01531117 0.01548031
round(a$RsCountry[[1]],4)
#>  [1] 0.0203 0.0208 0.0228 0.0188 0.0168 0.0198 0.0134 0.0114 0.0218 0.0134
#> [11] 0.0089 0.0154 0.0154 0.0163 0.0114 0.0248 0.0094 0.0198 0.0213 0.0139
#> [21] 0.0139 0.0119 0.0094 0.0173 0.0104 0.0124 0.0124 0.0114