The shape of the United States’ presidential elections

There are many ways to map election results — you’ve probably not tried this one (and you are still in time before this year’s election).

Francesco Palma
Towards Data Science

--

Written by Philipp Weiler, Lewis Tunstall, Francesco Palma and Thomas Boys

It is rare to know everyone’s opinion on a given matter at a given point in time. General elections offer a true snapshot of how inhabitants of a country perceive their country’s needs and priorities. Although we must be careful with conclusions, the way voters cast their ballot reflects (to a certain extent!) their situation and their values.

After an election, analysts give this prime material its meaning with a series of illustrations to support their conclusions. One recurring illustration is the election map. This map shows how actual physical boundaries align with political ones. Specifically, in the USA it sends the general message that country-side voters are conservative, and densely populated areas voters are liberal.

Election map colored by voting margins

The election map confirms our prior, and acts as a sanity check. However, the limited information it represents constrains the diversity of hypotheses we can come up with.

It is not always easy to spot causal relationships, as they are not bound geographically; sometimes we simply do not know what to look for.

Although the way you cast your ballot is entirely subjective, studies have shown that factors like your socio-economic background, or even your zip-code influence your voting preferences. Formulating appropriate hypotheses remains subjective, in particular when considering high-dimensional datasets, where making the right connection between variables is a real challenge.

It is in our interest to use a systematic method to aggregate data visually in order to reveal new insight. This is where the Mapper algorithm can help us. It is an unsupervised method which divides data into different regions and makes connections between them when appropriate. These regions are the key to producing new hypotheses.

An economic landscape of counties in USA

Counties are the administrative sub-divisions of a state in the USA. Oftentimes, county level analysis offers the most detailed insight as statistics about them are often the smallest scale available.

Using the Mapper algorithm, we want to understand if there is a natural way of dividing the counties into socio-economic categories and relate them to vote behaviours. Our study on county level data from 2016 uses 21 socio-economic features from the U.S. Bureau of Economic Analysis, which, for example, include personal income data and per capita retirement. Because there is a lack of data about some counties (like Alaskan and Hawaiian counties), they are excluded from our study. As a result, we count 3043 counties.

Our results in a nutshell

Our study shows we can divide the counties into five main regions based on economic indicators:

1. High net worth

2. High net worth per inhabitant

3. High per capita retirement

4. Elevated and average net worth

5. Low net worth

Socio-economic landscape of the USA in 2016 as depicted by Giotto-learn Mapper

That high per capita retirement is itself a cluster is not the only surprising result. In combination with low net worth counties, they both account for the vast majority of counties and surface area. It is also worth mentioning that high net worth of a county does not translate into high net worth individuals and, thus, creates two separate categories in our study.

When combined with election results, we find that in 2016, the high per capita retirement, and low net worth regions are strongholds for the Republicans. The remaining three regions vote predominantly Democrat with an exception for some clusters of elevated and medium net worth counties.

Our results are obtained with Giotto-learn’s implementation of Mapper. You can find a more detailed explanation of its innerworkings in this blogpost. If you want to replicate our results or try by yourself, we provide the code to do so using the open-source library Giotto-learn. Another application of Mapper to voting in the USA can be found here.

The methodology

A successful application of Mapper requires choosing:

  • A filter function, i.e. a map from the dataset to a lower-dimensional space,
  • A cover of the image space,
  • A clustering method
Workflow to run the Mapper algorithm in Giotto-learn

With only a few lines of code, Giotto-learn’s Mapper will provide you with a colored graph. The nodes represent clusters, that, by default, are colored by the average filter values of points within the cluster. An edge is drawn when two clusters when they share at least one point. In our case, a point represents a county.

Mapper graph colored by filter value

Meaning in the graph’s structure can be revealed by coloring the nodes by variables of interest. For example, by coloring each node by the mean net worth of its members, we get a view into which sets of nodes are similar. The default coloring by mean filter value divides the connected component into two regions: elevated and low filter values. The singletons are diverse in filter value as they cover the entire spectrum. However, this does not provide much insight, as the filter function is too abstract to be interpretable. Fortunately, in Giotto-learn’s implementation of Mapper, it is easy to change the coloring of the nodes to extract insight from the structure.

Coloring the Mapper graph to find meaning

Mapper graph colored by personal income
Mapper colored by per capita personal income
Mapper graph colored by per capita retirement

Coloring the graph by either personal income, or per capita personal income or per capita retirement reveal the five cohesive regions mentioned above. These five regions only became visible because we analyzed 21 features at the same time. Obtaining such categories would have been much more difficult, or even impossible, had we studied the features separately.

To see how this unfolds on the map, we color the county map accordingly.

Five main regions colored in the Mapper graph and in the map of the USA

While these counties separate nicely in the Mapper graph, this is not true when they are plotted by location. The topology of the regions is highly non-trivial, and probably not even an expert would have chosen such a grouping.

To show the significance of the Mapper output, we can color the graph by any variable of interest.

Voting Behaviour in the USA

The Mapper graph helps us understand voting behaviour by colouring the nodes by the percentage of counties won by Republicans and Democrats, respectively. Our colour scale ranges from dark blue (all counties were won by Democrats), over white (there is an equal number of counties won by both parties) to dark red (all counties were won by Republicans).The data has been made available by the MIT Election Data and Science Lab.

We are not limited to a socio-economic framework but can introduce a temporal dimension as well. Keeping the Mapper graph unchanged and colouring it by election results of different years helps us understand how the voting behaviour evolved over time. Here, we colour the nodes by the results of the presidential elections of this millennial.

In order to reflect the relative weight of a cluster, we can add another level of information by varying the size of a node. We resize a node proportional to the percentage of electors it is responsible for. We define this number (per county) in the following way: given the number of electors for a state, for each county, we weigh it by the population percentage of that county.

Results

There are two polar opposites in the main connected component, which align almost perfectly with the high/low filter value separation. As a general rule, the Republicans tend to be strong in counties with a low number of electors. We notice that after 2004, the votes of high net worth, high per capita net worth and high per capita retirement remain stable. Grossly, the “swinging” counties are contained in the elevated, average and low net worth counties. One small fact about the singletons: they are almost always all entirely won by one of the parties.

The evolution of the vote: 2004 to 2008

The year President Obama won the elections we notice two things: the high per capita retirement and low net worth regions are less dominated by Republicans. In 2004, the high per capita personal income region voted predominantly Republican, whereas in 2008, it becomes Democrat.

Mapper graph colored by election outcome

The evolution of the vote: 2012 to 2016

In 2016, we see a net progression of Republican vote in the regions mentioned above. In the traditional Republican regions we notice an average increase of 10–20% in comparison to previous years. There is, however, also one Republican stronghold which the Democrats manage to take over.

Mapper graph colored by election outcome

The contribution of counties to the Electoral College

Democrats tend to win big counties (like L.A. which amounts to 2.7% of the electors) and Republicans win small but many counties, which is reflected in the nodes of the Mapper graph. We can separate the nodes in two new regions in function of the number of the average number of electors per county. The first region contains counties with a small number of electors. For the second region the opposite is true.

For example, in 2016, a large dark blue node represents 4.5% of electors and contains only nine counties, eight of which were won by Democrats. At the same time, in a Republican cluster, a staggering 700 counties sum to 10% of the electors, which means each county is only responsible for a mere 0.015% of electors. The percentage of electors per county in a node won by Republicans is always smaller than for their Democrat won counterparts.

From economic indicators to voting behaviour

As for any political analysis, we need to be careful with our conclusions. Definite conclusions cannot be drawn as we do not have access to exit poll data. However, this analysis suggests a persisting correlation between socio-economic factors and voting behaviour:

1. In the high and most of the elevated net worth counties, the Democrats secure more votes.

2. The Republicans, on the other hand, score in regions of high per capita retirement and low net worth.

3. The swing votes are contained in the boundary regions of the two parties’ respective strong-holds.

Conclusion

The Mapper algorithm reduces the dimensionality of our data and aggregates it while preserving topological properties. Through the Mapper graph we found different socio-economical categories, which seem to have voting trends.

Understanding these trends and how they change over time may help building a strategy for the campaign trail.

Useful Links:

--

--

Co-founder at L2F | Open-source developer @Giotto_ai | Mathematician interested in everything with a topology