Applied Coxcombs: The Quality of Democracy

As it happens, my department at the WZB Berlin Social Research Center now has a blog ( Naturally, I was volunteered, sorry, I volunteered to describe some of the department’s research. One project that I’ve been particularly active in for quite some time is the Democracy Barometer. This project has developed a not-so-new-anymore instrument, which evaluates the quality of established democracies. The project is based on a joint effort of the WZB Berlin Social Research Center, the University of Zurich (UZH), and the Swiss National Center of Competence in Research (NCCR). Covering the period from 1990 to 2007, the Democracy Barometer offers detailed information on the state of democracy in thirty established democracies.

The underlying theoretical concept (see this paper) assumes that democracies try to maintain a balance between the three normative principles of freedom, equality, and control. Taken together these principles dictate what functions democracies must fulfill. Freedom, our team argues, depends on the guarantee of fundamental individual rights, a secure rule of law, and a functional public sphere. Equality in terms of equal access to political processes depends on inclusive participation, transparency, and high levels of descriptive and substantial representation. Finally, to reconcile the competing demands of freedom and equality control comes into play. This third principle includes a separation of constitutional powers, political competition, and effective power to govern. In short, the Democracy Barometer is quite a lot of nuts.

Spider_ChartAnyhow, one of the principle problems has long been to visualize the data in an adequate format. More often than not my colleagues relied on radar charts, whichplot multivariate data on a single plane. Variables are represented using multiple axes that all originate from the same point and have equal angles from one another. A line then directly connects each data value of the axes. The resulting polygon gives a profile for each observation.  You can see an example from Wikipedia on the right.  The blue polygon represents allocated budget across departments, and the red polygon denotes actual spending across departments. From the overlap of the polygons you can thenjudge how similar or dissimilar observations are.

As long as all variables are on the same scale and equally important, there is nothing really wrong with radar charts. However, I don’t like the direct connection part. More precisely, I think that this connection method gives a misleading impression of differences between measurements on the same observation. Take a look at the Information Technology, Administration, and Sales variables of the allocated spending polygon. The segment connecting these three variables is almost straight, giving the impression of minor differences. Otherwise there would be visible edge, wouldn’t it? Well, the underlying values are roughly $21, $8, and $41. I’d call that considerable differences.

For my blog post I wanted to keep the disaggregated image of the nine functions of democracy as offered by radar charts, but I wanted to avoid get rid of the direct connections. Also I wanted to visualize the relationship between principles and functions. Thus, I came back to coxcombs, but this time I added a specific color scheme an also retained a scale. But let’s do this step by step.

First, you’ll need the data, which you can load into R directly using:

dembar <- read.dta(
  file = paste0("",
    "DB_Dataset_blueprint_std.dta"),  ## I just like my line
                                  ## breaks at 65 characters
  convert.dates = TRUE,
  convert.factors = TRUE

As you can see below, the data is in long (country-year) format.

> head(dembar[, 1:5])
    country year consttort convtort il_phin1
1 Australia 1990         0      100       50
2 Australia 1991         0      100       50
3 Australia 1992         0      100       50
4 Australia 1993         0      100       50
5 Australia 1994         0      100       50
6 Australia 1995         0      100       50

Before we proceed to plotting, let’s subset the data to the function level. This will keep things much cleaner. Also I’ll only keep three years for the United States. That’ll be sufficient to demonstrate the essentials. <- subset(dembar,
  subset = country == "United States" &
    year %in% c(1990, 1997, 2007) ==  TRUE,
  select = c(
    "year", "indlib", "ruleoflaw", "public",
    "compet", "mutucons", "govcap", "transpar",
    "particip", "repres"

Next, I prepare the data for plotting. Using the reshape package, I convert the data.frame into a ggplot2 appropriate format. Afterwards I define axis labels and finally I pick a color scale.

m.df <- melt(    ## melt data for simpler x-scale definition,
  id.vars = c("year"),
  measure.vars = c("indlib", "ruleoflaw", "public",
    "compet", "mutucons", "govcap", "transpar", "particip",
m.df <- within(m.df, {
  order <- factor(variable,        ## factor with democratic 
  ## functions ordered by democratic principle for x-scale 
    levels = c(
      "indlib", "ruleoflaw", "public", "compet",
      "mutucons", "govcap", "transpar", "particip", "repres"
    labels = c(                    ## define speaking labels
      "Individual Freedom", "Rule of Law",
      "Public Sphere", "Competition",
      "Horizontal Control", "Government Capability",
      "Transparency", "Participation", "Representation"
  fill <- NA                       ## factor for fill colors
  fill <- ifelse(order %in% c("Individual Freedom",
    "Rule of Law", "Public Sphere") == TRUE, 1, NA
  fill <- ifelse(order %in% c("Competition",
    "Horizontal Control", "Government Capability") == TRUE,
    2, fill
  fill <- ifelse(order %in% c("Transparency",
      "Participation", "Representation") == TRUE, 3, fill
  fill <- factor(                 ## Principles of Democracy
    levels = 1:3,
    labels = c("Freedom", "Control", "Equality")

colors <- c("#599ad3", "#727272", "#f1595f")   ## colors for
                                               ## principles

A first plot of the data is shown to the left. Note that it still lacks an appropriate scale, and so readers will have a hard time to extract information. Also I deactivated the standard grid and will provide one manually in a single call to geom_bar() — I got the idea here. This manual grid has the advantage that readers will always see it and hence it will be easier to Second draftread measurement values from the chart. More importantly, however, some axis labels overlap and need to be readjusted. Using the code below, a more satisfying result is achieved as you can also see on the left. In general, I find that this visualization approach to the Democracy Barometer data gives a better idea of the underlying measurements. Strengths and deficits in individual functions of each democracy are readily apparent, and the overall shape of the plot gives you a very good impression of how well-rounded democracy is. If you have additional ideas, feel free to leave a comment. 

scale.labs <- data.frame(             ## define scale labels
  x = rep(1, 10),
  y = seq(10, 100, 10),
  labels = as.character(seq(10, 100, 10))
scale.grid <- data.frame(            ## define grid for plot
  x = rep(1:9, each = 10),       ## 9 functions of democracy
  y = rep(10, 90)

p <- ggplot(
  data = m.df,
  aes(x = order, y = value, fill = fill)
p +
    width = 1, stat = "identity"
  ) +
  scale_fill_manual(values = colors) +
    data = scale.grid,              ## implement manual grid
    aes(x = x, y = y, fill = NA), width = 1,
    colour = "white", position = "stack", stat = "identity"
  ) +
    data = scale.labs, aes(x = x, y = y, label = labels,
      fill = NULL
    size = 4
  ) +
    labels = c(                    ## define speaking labels
      "Individual Freedom", "Rule of Law",
      "Public\nSphere", "Competition",
      "Horizontal Control", "Government Capability",
      "Transparency", "Partici-\npation", "Representation"
  ) +
    limits = c(0, 100), breaks = seq(0,100,10)
  ) +
  labs(x = "", y = "",
    title = "Quality of Democracy in the USA") +
    fill = guide_legend(title = "Democratic Principle",
      override.aes = list(colour = NULL, alpha = 1)
  ) +
  theme_grey(base_size = 20) +
    axis.line.x = element_blank(),
    axis.line.y = element_blank(),
    axis.ticks.x = element_blank(),
    axis.ticks.y = element_blank(),
    axis.text.x = element_text(colour = "black"),
    axis.text.y = element_blank(),
    panel.grid = element_blank(),
    legend.position = "top",
    legend.direction = "horizontal"
  ) +
  coord_polar(start = 340*0.0174532925) +
  facet_grid(. ~ year)
This entry was posted in Democracy measurement, ggplot2, R, Tutorial. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s