Temporal trends in Catalan ethnic vote in Catalonia (1984-2015)

This is the second post about the Catalan ethnic vote. In the first one, I defined the Catalan vote in terms of independence of Catalonia/Union to Spain with a model based on birthplace. In this second, I’ll explore the time series for the Catalan ethnic parties’ vote (CiU, ERC, CUP and JxSí) in Catalan regional elections. As in the previous post, election data comes from the Statistical Institute of Catalonia (Idescat), processed with RStudio and plotted with ggplot2.

1 Tools and data

First of all, the needed packages:

library(tidyverse) #general use
library(rgdal) #working with shapefiles (spatial data)
library(rgeos) #needed for the maptools package operations
library(maptools) #needed for operations on the shapefiles (spatial data)
library(ggmap) #used in ggplot
library(scales) #for colors in maps in ggplot

Now, I used the tidy data for all the Catalan elections obtained in the previous post:

#Reading tidy data
df <- read_csv("Catalan Parliament 1980-2015.csv")

#Selection of variables, excluding first elections (1980)
df2 <- df %>% 
  select(
    INE:Year,
    Indy_percent
    ) %>% 
  filter(
    !is.na(Indy_percent),
    Year !=1980
  )

I’m excluding the first election (1980) due to two main reasons. First one, because it was the first elections after 40 years of a Spanish dictatorship. Second one, because Idescat doesn’t provide detailed data, so I have only the current parties with their historical results, and the rest of parties, now extinct, in the “Other parties” category. This category is especially high in 1980 and affects trends.

Here Indy_percent corresponds to the support to the Catalan ethnic parties (CiU, ERC, CUP and 2015 coalition JxSí (CiU+ERC)): parties based in the Catalan linguistic area, focused in Catalonia, self-government (currently all advocating for independence), Catalan language and culture, political conflict with Spain, etc. The rest of the parties, are Catalan regional delegations for Spanish parties centered in promote reforms in Spain to accommodate the Catalan singularities. As we saw in the previous post, vote for this two type of parties are determined by birthplace (inside/outside Catalonia), which is an indicator for the native language, culture and media consumption: Catalan or non-Catalan (mainly, Spanish).

In total, I’m using 9,444 observations and 6 variables (strictly need for this analysis only 3) for 10 elections and 948 municipalities:

#Data
glimpse(df2)

## Observations: 9,444
## Variables: 6
## $ INE          <chr> "25001", "25001", "25001", "25001", "25001", "250...
## $ Municipality <chr> "Abella de la Conca", "Abella de la Conca", "Abel...
## $ County       <chr> "Pallars Jussà", "Pallars Jussà", "Pallars Jussà"...
## $ Vegueria     <chr> "Alt Pirineu", "Alt Pirineu", "Alt Pirineu", "Alt...
## $ Year         <int> 1984, 1988, 1992, 1995, 1999, 2003, 2006, 2010, 2...
## $ Indy_percent <dbl> 95.71, 89.36, 81.67, 80.00, 74.70, 84.42, 73.24, ...

#Number of municipalities
length(levels(as.factor(df2$Municipality)))

## [1] 948

#Number of elections
length(levels(as.factor(df2$Year)))

## [1] 10

2 Trends: linear models

The aim for this exercise is to find if there is some temporal trend in the Catalan ethnic parties’ vote, and where is showed an increase/decrease trend. To perform that I followed:

  • Obtaining a linear model (lm()) vote vs time for every of the 948 municipalities.

  • Extracting the statistics for the regression curve.

  • Selecting the significant models (p-value < 0.05 and R-squared > 0.4).

#Loop for every municipality
ine <- levels(as.factor(df2$INE))
final <- tibble()

for (i in ine) {
  muni <- df2 %>% filter(INE == i)
  linear <- lm(Indy_percent ~ Year, data = muni)
  slope <- round(coef(linear)[[2]], 4)
  r_square <- round(summary(linear)$r.squared, 4)
  p_value <- round(anova(linear)$`Pr(>F)`[1], 4)
  data <- as.tibble(cbind(i,slope,r_square,p_value))
  colnames(data)[1] <- "INE"
  final <- rbind(final, data)
}

#Selection of relevant trends

selection <- final %>% 
  filter(
    p_value < 0.05 & r_square > 0.4
  ) %>% 
  mutate(
    id = as.character(as.numeric(INE))
  )

As a result, we obtained 249 municipalities (observations) with significant temporal trends:

glimpse(selection)

## Observations: 249
## Variables: 5
## $ INE      <chr> "08001", "08002", "08003", "08005", "08007", "08008",...
## $ slope    <chr> "-0.2724", "-0.6763", "-0.2792", "-0.5408", "-0.35", ...
## $ r_square <chr> "0.4956", "0.4566", "0.5301", "0.6005", "0.4476", "0....
## $ p_value  <chr> "0.0231", "0.032", "0.017", "0.0085", "0.0344", "0.04...
## $ id       <chr> "8001", "8002", "8003", "8005", "8007", "8008", "8009...

3 Ploting results

Finally, I show the results in a map. I use the official shapefile for the Catalan municipalities boundaries provided by the Cartographic and Geological Institute of Catalonia, plotted with ggplot2. In the map, I represent the slope statistic: higher slope -> higher increase/decrease -> darker color.

#Mapping
#Loading the shapefile and preparing for ggplot2
shape <- readOGR(dsn = ".", layer = "muni_WGS84") 
shape <- fortify(shape, region = "INE_antic")

#Joining data and spatial data
map2 <- left_join(shape, selection, by = "id") %>%
  mutate(
    slope = as.numeric(slope)
  )

#Plotting results
ggplot() +
  geom_polygon(data = map2, aes(x = long, y = lat, group = group, fill = slope)) +
  coord_map() +
  scale_fill_distiller(palette = "RdYlBu", direction = -1,
                       breaks = pretty_breaks(n = 6), name = "Increase") +
  guides(fill = guide_legend(reverse = TRUE)) +
  theme_nothing(legend = TRUE) +
  labs(
    title = "Trends in Catalan ethnic vote (1984-2015)",
    caption = "Marc Belzunces. Data from Idescat."
  ) +
  theme(plot.title = element_text(hjust = 0.5))

_config.yml

I didn’t explore results municipality by municipality, by a first look interpretation is that blue municipalities, where Catalan ethnic parties show a decreasing trend, are those municipalities with higher immigration. In contrast, they are showing increasing support specially in the South (Terres de l’Ebre), zones where Catalan as native language presents higher values. Rest of municipalities doesn’t show any clear temporal trend, but it doesn’t mean that Catalan ethnic parties has no support. Grey municipalities include ones with maximum support and ones with minimum support, meaning that they are not increasing neither decreasing support.

Written on May 31, 2017