read

In our collaborative research on the democratic rhetoric of IOs, we are developing explanatory models that explain why IOs use democracy as a normative point of reference when they describe who they are and what they do in their annual reports. In one of our models, we check if the economic inequality of an IO’s membership helps to explain this phenomenon. In this blog post, I illustrate how we calculate economic inequality. This may be of interest to some of you because I

  • first show how to download the COW-IO dataset and the Penn World Tables data in R.
  • Second, I show how to merge the two data-sets.
  • Third, I show how to calculate the Gini-Coefficient of inequality for the IOs.

If there are any comments, please feel free to send me a mail or please leave a comment, below.

Importing IGO membership data

First, I import the COW data-set and subset it for our research project’s sample of 20 IOs and then bring it into shape for the next steps.

# download the COW data
temp <- tempfile()
download.file("http://www.correlatesofwar.org/data-sets/IGOs/IGO_igounit_v2.3.zip",temp)
data.cow <- read.csv(unz(temp, "igounit_v2.3.csv"))
unlink(temp)

# filter IOs and only years after 1979
library(dplyr)
data.cow.sub <-   data.cow %>% filter(ioname == "UNIDO" | ioname == "UNESCO" | ioname == "IBRD" | ioname == "IMF" | ioname == "ILO" | ioname == "ICC" | ioname == "IAEA" | ioname == "BIS" | ioname == "WTO" | ioname == "GATT" | ioname == "IWhale" | ioname == "ISA" | ioname == "OECD" | ioname == "GEF" | ioname == "ICAO" | ioname == "PCA" | ioname == "UN" | ioname == "OPEC" | ioname == "OSCE" | ioname == "ComSec" | ioname == "WMO") %>% filter(year > 1979)

# transform into long data format
library(reshape2)
data.cow.sub <- melt(data.cow.sub[, c(1, 3:217)], id.vars=c("ioname", "year"), variable.name="country",	value.name = "membership")

#and remove states that are not full members from the data-set
data.cow.sub <- filter(data.cow.sub, membership == 1)

Data in the COW data-set is only available until 2005. We need data until 2011 for our analysis. Therefore, we need to add information for the missing years. As a simplifying assumption, we assume that no countries have left an IO since

  1. So, first we copy the 2005 data for the 2006-2011 years.
copy1 <- filter(data.cow.sub, year == 2005)
copy1[which(copy1$year == 2005), 2] <- 2006
copy2 <- filter(data.cow.sub, year == 2005)
copy2[which(copy2$year == 2005), 2] <- 2007
copy3 <- filter(data.cow.sub, year == 2005)
copy3[which(copy3$year == 2005), 2] <- 2008
copy4 <- filter(data.cow.sub, year == 2005)
copy4[which(copy4$year == 2005), 2] <- 2009
copy5 <- filter(data.cow.sub, year == 2005)
copy5[which(copy5$year == 2005), 2] <- 2010
copy6 <- filter(data.cow.sub, year == 2005)
copy6[which(copy6$year == 2005), 2] <- 2011

data.cow.sub <- rbind_all(list(data.cow.sub, copy1, copy2, copy3, copy4, copy5, copy6))
rm(copy1, copy2, copy3, copy4, copy5, copy6)

Next, we need to add data for the states that have joined the IOs since 2005. We have created a separate file (download), containing the new member states that is now added to the existing data.

add.members <- read.csv("io-members-since-2006.csv")
data.cow.sub <- rbind_all(list(data.cow.sub, add.members))

The data now includes complete membership data for the IOs from 1980-2011.

Importing Penn World Tables

Next, I import the Penn World Tables data. It includes annual GDP data for most of the states that are in the COW-IGO data-set. For the analysis, we use the rgdpna measure, which is “RealGDP at constant 2005 national prices (in mil. 2005US$).”

# download pwt8.1 in excel format and import relevant sheet
temp2 <- tempfile()
download.file("http://www.rug.nl/research/ggdc/data/pwt/v81/pwt81.xlsx",temp2)

library(xlsx)
data.penn <- read.xlsx2(file = temp2, sheetIndex = 3, colIndex = c(1, 2, 4, 18), colClasses = c("character", "character", "numeric", "numeric"), startRow = 1, endRow = 10358)

# filter out years before 1980
data.penn <- filter(data.penn, year > 1979)

unlink(temp2)

Next, we have to match both data sources. This can be achieved with the help of the countrycodes package.

# add country code to cow data with countrycodes-package
library(countrycode)
data.cow.sub$isoc <-  countrycode(data.cow.sub$country, origin="country.name", destination="iso3c", warn=T)
## Warning in countrycode(data.cow.sub$country, origin = "country.name", destination = "iso3c", : Some values were not matched: domrepublic, etimor, kosovo, nokorea, sokorea, stlucia
# add non-matching values manually
data.cow.sub$isoc[which(data.cow.sub$country == "domrepublic")] <- "DOM"
data.cow.sub$isoc[which(data.cow.sub$country == "etimor")] <- "TLS"
data.cow.sub$isoc[which(data.cow.sub$country == "kosovo")] <- "UNK"
data.cow.sub$isoc[which(data.cow.sub$country == "nokorea")] <- "PRK"
data.cow.sub$isoc[which(data.cow.sub$country == "sokorea")] <- "KOR"
data.cow.sub$isoc[which(data.cow.sub$country == "stlucia")] <- "LCA"

# merge, keeping all entries in data.cow.sub
data.complete <- merge(x = data.cow.sub, y = data.penn, by.x = c("isoc", "year"), by.y = c("countrycode", "year"), all.x = T)

# rename GATT to WTO
library(car)
data.complete$ioname <- recode(data.complete$ioname, recodes = "'GATT' = 'WTO'")

Calculate inequality measures

Finally, we can calculate measures of inequality. Here, I limit myself to the Gini-coefficient. Other measures of inequality (e.g. the spread of the data, variances, etc) can be calculated in a similar way.

library(ineq)

inequality.io.year <- data.complete %>% group_by(ioname, year) %>% summarise(n_members = n(), gini = ineq(rgdpna), mean = mean(rgdpna, na.rm = T))

# export inequality measures in IO-year format
write.csv2(inequality.io.year, file = "inequality-io-year.csv")

Calculate share of LDCs in IO membership

As an additional measure of inequality, we look at the share of LDCs in the IOs’ membership. LDC data is taken from the United Nations (and summarized by us here.

## import LDC data
LDCs <- read.xlsx2("LDCs.xlsx", sheetIndex = 1, colIndex = c(1:5), colClasses = c("character", "numeric", "character", "numeric", "numeric"))

# filter LDCs
LDC.sub <- LDCs %>% filter(LDC == 1)

# merge with COW
LDCs.merged <- merge(x = data.cow.sub, y = LDC.sub, by.x = c("isoc", "year"), by.y = c("stateabb", "year"), all.x = T)

#summarize to IO-year
LDC.shares <- LDCs.merged %>% group_by(ioname, year) %>% summarise(n_members = n(), n_LDC = sum(LDC, na.rm = T), LDC_share = sum(LDC, na.rm = T) / n())

# export
write.csv2(LDC.shares, file = "share.ldcs.csv")

Plot

As the plots show, there is some variation across IOs when it comes to inequality. The general trend over time shows that IOs have become more unequal over the years.

library(googleVis)

# plot IO summaries
plot.df <- data.complete %>% group_by(ioname) %>% summarise(n_members = n(), gini = ineq(rgdpna))
pl1 <-  gvisBarChart(plot.df, xvar = "ioname", yvar = "gini", options = list(height = 450, width = 650))
# plot annual summary
plot.df <- data.complete %>% group_by(year) %>% summarise(n_members = n(), gini = ineq(rgdpna))
plot.df$year <- as.Date(as.character(plot.df$year), "%Y")
pl2 <- gvisLineChart(plot.df, xvar = "year", yvar = "gini", options = list(height = 450, width = 650))

And here’s a plot for the annual share of LDCs in our IO population

# plot annual summary
plot.df <- LDC.shares %>% group_by(year) %>% summarise(LDC_share = mean(LDC_share))
plot.df$year <- as.Date(as.character(plot.df$year), "%Y")
pl3 <- gvisLineChart(plot.df, xvar = "year", yvar = "LDC_share", options = list(height = 450, width = 650))
Blog Logo

Tobias Weise


Published

Image

Tobias Weise

political scientist, university administration specialist

Back to Overview