In this tutorial, we will show how to merge the Manifesto Project Dataset with data on cabinet compositions from parlgov.org. We assume that you have already read the Short primer on the Manifesto Project and its methodology and First steps with manifestoR. Moreover, you should be familiar with the %>% operator and the dplyr package and grammar.

ParlGov.org - a data source for parties, cabinets and elections

Along with our policy-codings, our dataset encompasses a number of useful metadata, such as the voteshare (pervote), partyname and -abbreviation, or codes that identify eu- and oecd-membership. However, a majority of research questions demand for more information and a broader dataset. Thus, combining the Manifesto Project Dataset with other datasets is often necessary to answer many research questions. In this brief tutorial, we will show how our data can be expanded by merging it with the popular database ParlGov (Döring & Manow 2018). Parlgov provides information on parties, cabinets and elections for 37 countries (EU and OECD). This can be useful if for example one would like to distinguish strategies of opposiiton and government parties, analyze whether some parties or strategies are associated with gaining or loosing office, or when calculating the position of whole cabinets (in contrast to party positions).

Downloading data

We first download the Manifesto Project Dataset using manifestoR (see the tutorial First steps with manifestoR for a more detailed explanation of this step): we load manifestoR, set the apikey and download the current version of the Manifesto Project Dataset.

library(manifestoR) # to access the Manifesto Project Dataset
library(ggplot2) # for plots
library(dplyr) # for data wrangling
library(tidyr) # for data wrangling, too
library(lubridate) # for handling date variables


# Loading the Manifesto Project Dataset (Version 2018a)
mp_setapikey(key.file = "manifesto_apikey.txt")
mpds <- mp_maindataset(version = "MPDS2018a")
## Connecting to Manifesto Project DB API... corpus version: 2018-1

Parlgov provides three main table views of its database:

view_party - Party information and merge table for various external data sets on party positions. view_cabinet - Cabinet and opposition parties in parliament with their seat strength at each instance of government formation. (main view)
view_election - Electoral results for national and EP elections.

For our task here, we use the party and cabinet data. For the goal of easy replication of this tutorial, we read the data directly from the parlgov website within R, but it might be a good idea to save the raw data on your computer, too. We use the read_csv function from the readr package. This slightly differs from read.csv because it has different default settings: it does not convert characters to factors by default, and it encodes in UTF-8. Moreover, it automatically detects dates as dates and returns a clean tibble instead of a “normal” data.frame.

# Loading information on cabinets and parties from ParlGov data
library(readr)
pg_cabinets <- read_csv("http://www.parlgov.org/static/data/development-utf-8/view_cabinet.csv")
pg_cabinets
## # A tibble: 11,064 x 19
##    country_name_short country_name election_date start_date cabinet_name
##    <chr>              <chr>        <date>        <date>     <chr>       
##  1 AUS                Australia    1901-03-30    1901-03-30 Barton      
##  2 AUS                Australia    1901-03-30    1901-03-30 Barton      
##  3 AUS                Australia    1901-03-30    1901-03-30 Barton      
##  4 AUS                Australia    1901-03-30    1901-03-30 Barton      
##  5 AUS                Australia    1901-03-30    1901-03-30 Barton      
##  6 AUS                Australia    1901-03-30    1903-09-24 Deakin I    
##  7 AUS                Australia    1901-03-30    1903-09-24 Deakin I    
##  8 AUS                Australia    1901-03-30    1903-09-24 Deakin I    
##  9 AUS                Australia    1901-03-30    1903-09-24 Deakin I    
## 10 AUS                Australia    1901-03-30    1903-09-24 Deakin I    
## # ... with 11,054 more rows, and 14 more variables: caretaker <int>,
## #   cabinet_party <int>, prime_minister <int>, seats <int>,
## #   election_seats_total <int>, party_name_short <chr>, party_name <chr>,
## #   party_name_english <chr>, left_right <dbl>, country_id <int>,
## #   election_id <int>, cabinet_id <int>, previous_cabinet_id <int>,
## #   party_id <int>

The cabinet composition data includes information on which parties within a country formed a cabinet. Rows are the most relevant parties within a country. election_date indicates the date of the last election. cabinet_name is the name of the cabinet (the prime minister + a Roman number), the variable cabinet_party indicates whether a party was part of a cabinet or not. For more information on the precise meaning and coding of the variables, see the parlgov website.

pg_parties <- read_csv("http://www.parlgov.org/static/data/development-utf-8/view_party.csv")
pg_parties
## # A tibble: 1,568 x 23
##    country_name_sho… country_name party_name_short party_name_english     
##    <chr>             <chr>        <chr>            <chr>                  
##  1 AUS               Australia    ACP-V            Australian Country Par…
##  2 AUS               Australia    AD               Australian Democrats   
##  3 AUS               Australia    AG               Australian Greens      
##  4 AUS               Australia    ALP              Australian Labor Party 
##  5 AUS               Australia    AP               Australia Party        
##  6 AUS               Australia    C                Coalition              
##  7 AUS               Australia    CDP              Christian Democratic P…
##  8 AUS               Australia    CLP              Commonwealth Liberal P…
##  9 AUS               Australia    CN-QLD           Country-National Party…
## 10 AUS               Australia    CPA              Communist Party of Aus…
## # ... with 1,558 more rows, and 19 more variables: party_name <chr>,
## #   party_name_ascii <chr>, family_name_short <chr>, family_name <chr>,
## #   left_right <dbl>, state_market <dbl>, liberty_authority <dbl>,
## #   eu_anti_pro <dbl>, cmp <int>, euprofiler <int>, ees <int>,
## #   castles_mair <int>, huber_inglehart <int>, ray <int>,
## #   benoit_laver <int>, chess <int>, country_id <int>, party_id <int>,
## #   family_id <int>

Merging and working with the data

In the following, we will illustrate how to merge the Manifesto Project Data with parlgov data. For illustrative purposes, we will do this on German governments since 1950 only, but the shown procedure should work similarly for other countries.

Subsetting

We subset the the three data sources to electoral programs issued by German parties since 1960, German governments since 1960 and German parties.

mpds_germany <- filter(mpds, countryname == "Germany" & date > 196000)
pg_cabinets_germany <- filter(pg_cabinets, country_name == "Germany" & election_date > "1960-01-01")
pg_parties_germany <- filter(pg_parties, country_name == "Germany")

Merging

ParlGov data is easy to merge with the Manifesto Project Data because the party view tables contain the party identifier from the Manifesto Project (often called CMP party code). To be able to calculate government position based on the positions of electoral programs of parties that form a government, we first merge the parlgov party information with the cabinet information, so that the cabinet information also contains the party identifier.

We first create a simple link table from the parlgov party view that only includes the parlgov party id , the cmp variable (the Manifesto Project party id) and the party name.

pg_mpds_link_table <- pg_parties_germany %>% 
  select(party_id, cmp, party_name) %>%
  mutate(cmp = ifelse(party_id == 255, 41113, cmp))
         
pg_mpds_link_table
## # A tibble: 35 x 3
##    party_id   cmp party_name                                              
##       <int> <dbl> <chr>                                                   
##  1      796    NA Arbeit & soziale Gerechtigkeit – Die Wahlalternative    
##  2     2253    NA Alternative für Deutschland                             
##  3      255 41113 Bündnis 90 / Grüne – BürgerInnenbewegung                
##  4      772 41113 Bündnis 90 / Die Grünen                                 
##  5     1720    NA Bund freier Bürger – Offensive für Deutschland          
##  6     1131 41911 Bayernpartei                                            
##  7      808 41521 Christlich Demokratische Union                          
##  8     1727 41521 Christlich Demokratische Union / Christlich Soziale Uni…
##  9     1180 41521 Christlich Soziale Union                                
## 10      633    NA Deutsche Friedensunion                                  
## # ... with 25 more rows

While this link tables from parlgov are relatively complete, they are sometimes not up-to-date. Here, we eg add the cmp party code for the Alternative für Deutschland yet.

pg_mpds_link_table <- pg_mpds_link_table %>%
  mutate(cmp = ifelse(party_name == "Alternative für Deutschland", 41953, cmp))

Moreover, parlgov sometimes treats parties slightly different than the Manifesto Project Dataset due to other coding criteria for political parties. For example the Manifesto Project treats the Left Party and the PDS as different parties with different ids. In contrast, parlgov codes them with the same party_id. In order to correctly merge them, we need to harmonize the coding in our dataset and treat them as the same party, too.

mpds_germany <- mpds_germany %>% 
  mutate(
    party = ifelse(party %in% c(41222, 41223), 41221, party),
    party = ifelse(party %in% c(41111, 41112, 41113), 41113, party),
    partyabbrev = ifelse(party == 41113, "Greens", partyabbrev),
    partyabbrev = ifelse(party == 41221, "Left", partyabbrev)
  )

We then add the cmp ids to the cabinet information by left joining them to the cabinet data. For the sake of simplicity in this tutorial, we only keep the information for the first cabinet in each election term. Depending on the research question, one might rather take the last cabinet, or keep the information from all cabinets.

pg_mpds_link_table <- pg_mpds_link_table %>% select(-party_name)

pg_cabinets_with_cmp_ids <- left_join(pg_cabinets_germany, pg_mpds_link_table, by = "party_id") %>% 
  select(cabinet_party, party_id, cmp, party_name, cabinet_name, cabinet_id, election_date, start_date, seats, election_seats_total) %>% # adding the cmp-codes to the parlgov cabinet data on germany
group_by(election_date) %>%
top_n(n = 1, wt = cabinet_id) %>% ungroup() # only keep information from first cabinet in each electoral term

In the next step, we slightly shorten the mpds dataset and keep only the party, date and the left-right positon (rile) and merge with the cabinet data.

cabinets_mpds <- mpds_germany %>% 
  select(edate, party, partyabbrev, rile, pervote, absseat) %>%
  left_join(pg_cabinets_with_cmp_ids, by=c("party" = "cmp", "edate" = "election_date")) %>%
  filter(edate > "1960-01-01") %>%
  mutate(cabinet_party = ifelse(edate == "2013-09-27" & partyabbrev == "FDP", 0, cabinet_party)) %>%
  filter(!is.na(cabinet_party))
  
cabinets_mpds 
## # A tibble: 66 x 14
##    edate      party partyabbrev    rile pervote absseat cabinet_party
##    <date>     <dbl> <chr>         <dbl>   <dbl>   <dbl>         <int>
##  1 1961-09-17 41320 SPD          -2.91    36.2      190             0
##  2 1961-09-17 41420 FDP         -17.8     12.8       67             1
##  3 1961-09-17 41521 CDU/CSU       2.33    45.3      242             1
##  4 1965-09-19 41320 SPD          -5.92    39.3      202             0
##  5 1965-09-19 41420 FDP           0.943    9.49      49             1
##  6 1965-09-19 41521 CDU/CSU      -1.6     47.6      245             1
##  7 1969-09-28 41320 SPD         -10.4     42.7      224             1
##  8 1969-09-28 41420 FDP         -18.7      5.77      30             1
##  9 1969-09-28 41521 CDU/CSU      -5.08    46.1      242             0
## 10 1972-11-19 41320 SPD         -14.4     45.8      230             1
## # ... with 56 more rows, and 7 more variables: party_id <int>,
## #   party_name <chr>, cabinet_name <chr>, cabinet_id <int>,
## #   start_date <date>, seats <int>, election_seats_total <int>

Plotting parties’ ideological movements

We have succesfully merged our info on party manifestos with data by parlgov on cabinet status. We plot parties’ ideological movements. The shapes provide information on the government/opposition status. A triangle marks when a party gained office at a focal election and marks when it became an opposition party.

ggplot(data = cabinets_mpds, aes(edate, rile), group = as.factor(partyabbrev)) +
  geom_line(aes(colour = as.factor(partyabbrev))) +
  geom_point(aes(shape = factor(cabinet_party, labels = c("Opposition", "Government")), colour = as.factor(partyabbrev)), size = 3) + 
  labs(color = "Party", shape = "government status", y = "Left-Right-Positions", x = "Time")