---
author:
- |
    Seth Flaxman (Department of Statistics, Oxford)[^1],\
    Dougal J. Sutherland (Gatsby Computational Neuroscience Unit, University College London),\
    Yu-Xiang Wang (Machine Learning Department, Carnegie Mellon University),\
    and Yee Whye Teh (Department of Statistics, Oxford)
bibliography:
- 'us2016.bib'
title: Understanding the 2016 US Presidential Election using ecological inference and distribution regression with census microdata
---

Introduction
============

The results of the 2016 US Presidential Election were, to put it mildly, a surprise.  Pre-election polls and forecasts based on these polls pointed to a Clinton victory, a prediction shared by betting markets and pundits.  In the aftermath of the vote, the main question asked is “why?”  with answers ranging from the political to the economic to the social/cultural.  In this article we attempt to provide a preliminary answer to a fundamental question: who voted for Trump, who voted for Clinton, and who voted for a third party or did not vote? 

By combining data from the United States census with the election results and recently proposed machine learning methods for ecological inference using regressions based on samples from a distribution, we provide local demographic estimates of voting and non-voting.  Unlike with exit polls, we are able to draw conclusions across the entire US and at a local level, about voters and non-voters, for interesting and novel combinations of predictor variables.  It is our hope that this analysis will help inform the typical election post mortems, which are usually informed by incomplete information, due the following factors:

-   Vote counts will not be finalized in many precincts until days or in rare cases weeks after the election.  Very close popular vote totals yield winner-take-all results, a fact of the US’s electoral system but one that can lead to winner-take-all explanations. 

-   The winner-take-all system means that the geography of voting patterns is often overly simplified, with states considered as homogeneous entities, leading to the ubiquitous red and blue maps popularized in 2000 [@gastner2005maps].  The geography of voting patterns are also often based on overly broad demographic/geographic categories, such as “suburban whites” which do not necessarily reflect an up-to-date picture of who lives where. 

-   Exit polls (surveys of voters) conducted by Edison Research on behalf of a consortium of media outlets are available immediately, with sufficient sample coverage to yield representative samples in 28 US states and nationally.  But they are not designed to provide sub-state geographic coverage, and there is a limit to the number and types of questions they can ask, and questions about their reliability and coverage. 

All of the source code for our analysis is freely available online to enable replication[^2]. 

Our analysis is in two parts: building on [@flaxman2015ecological], we provide exit poll style estimates of the number of voters and non-voters by candidate and various subgroups.  We are able to make much more finely-grained estimates, at the local level, than conventional exit polling.  We make these estimates at the national, state, and local level.  For example, Table \[table:sex\] shows that 47% of voters were men while 53% were women.  Among women, Clinton received 56% of the vote while Trump received 45% of the vote.  Unlike exit polls, we also estimate the participation rate by demographic, calculating the fraction of “potential voters”—voting-age citizens—who voted for one of the two major party candidates.  Equivalently, we calculate the fraction of Other / non-voting.  Thus we see that 50% of eligible men participated, voting for either Clinton or Trump, while 53% of eligible women participated. 

The second part of our analysis is an exploratory analysis of which group-level variables (i.e. distribution of age, joint distribution of income and race) were correlated with the final outcome.  While previous approaches to this question have focused on correlations between group-level means[^3], our novel approach makes it possible to investigate correlations between the full distributions of these group-level variables, observed at the local area level. 

Note that in the months after the election, high quality survey results will become available (the 2016 American National Election Study will be a large-scale look at who voted and why, and the US Census Bureau collects data on who voted), along with voter rolls data, which will ultimately give a very accurate portrait of who voted and who did not.  In the meantime, we are left with incomplete information, and it is our goal to begin to fill in part of the picture. 

Methods
=======

Given $n$ local areas of interest (counties reporting electoral results merged with PUMA regions, following [@flaxman2015ecological]) we assume that we have:

-   Samples of individual level demographic data from the American Community Survey: $$\{{\bm{x}}_1^j\}_{j=1}^{N_1}, \ldots, \{{\bm{x}}_n^j\}_{j=1}^{N_n}$$

-   Election results ${\bm{y}}_1, \ldots, {\bm{y}}_n$.

Election results for each local area $i$ are summarized as counts vectors ${\bm{y}}_i$. We use the method of “distribution regression” [@szabo2015two; @lopez2015towards; @flaxman2015ecological] to regress from a set of samples $\{{\bm{x}}_i^j\}_{j=1}^{N_i}$ to a label ${\bm{y}}_i$. This entails encoding $N_i$ samples as a high-dimensional feature vector, using explicit feature vectors and kernel mean embeddings [@smola2007hilbert; @gretton2012kernel]:

We use an additive featurization to compute mean embeddings ${\bm{\mu}}_i$ as follows for local area $i$: $$\begin{aligned}
    \{{\bm{x}}_i^j\}_{j=1}^{N_i}  = \{{\bm{x}}_i^1, {\bm{x}}_i^2, \ldots, {\bm{x}}_i^{N_i} \}\end{aligned}$$ Each ${\bm{x}}_i^j$ is a vector of length $d$ consisting of a mix of categorical and real valued variables: $${\bm{x}}_i^j = [x_{r1}^j, \ldots, x_{rd}^j]^{\top}$$ We consider feature mappings $\phi_1, \ldots, \phi_d$ and the additive featurization in which feature vectors are concatenated: $${\bm{\phi}}(x_i^j) := [\phi_1(x_{r1}^j), \ldots, \phi_d(x_{rd}^j)]^{\top}$$ We also consider including interaction terms of the form: $\phi_{pq}(x_{rp}^j, x_{rq}^j)$ in ${\bm{\phi}}(x_i^j)$ in ${\bm{\phi}}$.

We use ${\bm{\phi}}$ to estimate mean embeddings, one for each region, where the weights $w_j$ are the person weights, one per observation, reported in the census: $$\begin{aligned}
    {\bm{\mu}}_i = \sum_{j=1}^{N_i} w_j {\bm{\phi}}({\bm{x}}_i^j)\end{aligned}$$

We model the outcome ${\bm{y}}_i$ as a function of covariate distribution vectors ${\bm{\mu}}_i$ using penalized multinomial regression with a softmax link function.  Let $${\bm{y}}_i = [\mbox{Clinton votes}, \mbox{Trump votes}, \mbox{Non-votes and third party votes}]^{\top}$$ Then: $${\bm{y}}\sim \mbox{Multinomial}(\mbox{softmax}({\bm{\mu}}\beta_1, {\bm{\mu}}\beta_2, {\bm{\mu}}\beta_3))$$ where $\mbox{softmax}$ generalizes the logistic link to multiple categories: $$\mbox{softmax}_i(x_1,x_2,x_3) = \frac{\exp(x_i)}{\exp(x_1) + \exp(x_2) + \exp(x_3)}$$ We implemented the featurization using orthogonal random Fourier features [@felix2016orthogonal] for real-valued variables and unary coding for categorical variables.  We fit the penalized multinomial model using [glmnet]{} in R, crossvalidating to choose the $\alpha$ parameter (relative strength of $L_1$ vs. $L_2$ penalty) and sparsity parameter $\lambda$. We used [glmnet]{}’s built-in group lasso functionality meaning that $(\beta_1)_i, (\beta_2)_i, (\beta_3)_i$ would either all be simultaneously zeroed out by the $L_1$ penalty or not. 

Inferring who voted
-------------------

After obtaining maximum likelihood estimates $\hat \beta_1, \hat \beta_2, \hat \beta_3$ from our fit of the model, we used subgroup populations to make predictions, calculating mean embeddings for each local area based only on the group under consideration.  For example, to predict the vote among women in region $i$ we calculated new predictor vectors restricting our summation to the $N_i^{\mbox{w}}$ women in area $i$: $$\begin{aligned}
    {\bm{\mu}}_i^{\mbox{w}} = \sum_{j=1}^{N_i^{\mbox{w}}} w_j {\bm{\phi}}({\bm{x}}_i^j)\end{aligned}$$ and then used $\hat \beta_1, \hat \beta_2, \hat \beta_3$ and $\mbox{softmax}$ to calculate the corresponding probabilities of supporting Clinton, Trump, and other among women in region $i$. To calculate expected vote totals, we multiply these probabilities by the estimated total number of women in each region i, calculated by summing the census weights: $$\sum_j^{N_i^{\mbox{w}}} w_j$$

Group-based exploratory data analysis
-------------------------------------

While exit poll style ecological inference can give us deep insights into various preselected demographic categories, exploratory data analysis can reveal unexpected patterns.  We consider fitting the same models as above, but only using related subsets of the features, e.g. all of the categorical variables related to race or the interaction between age and income. 

Data and implementation
=======================

Our analysis can be replicated using a python package we wrote called [pummeler]{}[^4] with R replication scripts in our GitHub repository[^5].  We obtained the most recent American Community Survey 5-year dataset, 2010-2014 and the 2015 1-year dataset and merged them.  We excluded data from 2010 and 2011 because these years used the 2000 US Census geography, leaving us with four years of individual-level data.  We adjusted the 2015 weights to match 2012-14 thus obtaining a 4% sample of the US population, consisting of 9,222,637 million individual observations.  Electoral results by county were scraped from nbc.com on 9 November 2016 (the day after the election).  Using the merging strategy described in [@flaxman2015ecological] we ended up with 979 geographic regions.  Real-valued data was standardized to have mean zero and variance one and categorical variables were coded in unary, omitting a reference category to aid in model fit. 

We obtained state-level exit polling data obtained from foxnews.com for the following demographics: age, sex, and education.  We used these to increase the size and diversity of our sample.  In addition to the 979 geographic regions labeled with election outcome data, we used a total of 249 state-level subgroups, e.g. women in Florida, calculating the subgroup feature vectors as described above by restricting to the individual’s in the census matching the demographic reported in the exit poll.  As shown in Figure \[fig:scatter\] in the Appendix, our model is not overfitting, either to true outcome data (black) or exit poll data (blue).  The best $\alpha$ parameter we found was 0.05 (where $0$ is pure ridge regression).  The number of parameters in the best model was 415 out of a total of 11,112 features.  Using this model, we made predictions for a variety of groups derived from the census, as detailed in the next section. 

Results: inferring who voted with ecological inference {#section:inferring}
======================================================

We start by highlighting the local inferences that our method allows.  We inferred the gender gap of support for Trump among men minus support for Trump among women (11 percentage points nationally) for each of 979 geographic regions.  As shown in Figure \[fig:gender-gap\] gender gap varies spatially, with some regions showing parity and others exceeding the national average—29 regions had gaps of more than 20 percentage points and 54 regions had negative gender gaps (higher support for Clinton among men than women). 

![ Gender gap in support for Trump represented as percentage point difference between support for Trump among men minus support for Trump among women[]{data-label="fig:gender-gap"}](gender-gap.jpg){width=".9\textwidth"}

In this section we show exit poll-style results which we inferred using the ecological inference methods described above.  We could have presented these as contingency tables, but we prefer to mimic the way that exit polls are often presented in the popular press.  Here is how to read Table \[table:sex\], for example.  Nationally, among voters who voted for either Trump or Clinton, we estimate that 45% of men voted for Clinton while 55% of men voted for Trump.  These two columns will always sum to 1 within a row.  The third column says that we estimated that men made up 47% of the electorate, while women made up 53% of the electorate.  The column “Participation Rate” gives the percent of voting-age men/women who voted for either Clinton or Trump.  The column Other / non-voting is 1-Participation Rate as it gives the percentage of voting-age men/women who voted for a third party or did not vote. 

The tables give national results for categories usually reported in exit polls.  A variety of other groupings are included in the Appendix in Section \[sec:supplement\] CSV files with all of our estimates are available at the local level on our github repository. 

Results: group-based exploratory data analysis {#section:group-based}
==============================================

In order to explore which parameters were correlated with the outcome, we used penalized multinomial distribution regression using the same setup as above restricted to subsets of related categorical parameters, e.g. there are 6 different categories for marital status, as shown in Figure \[fig:marital\].  In each case, we calculated the crossvalidated deviance for the multinomial logistic likelihood, which is a measure of fit allowing different models with different numbers of parameters to be compared.  Smaller deviance is better.  In Table \[table:deviance\] we show the top 25 performing features. 

We visualize the marginal effects of the most informative categorical features in Figures \[fig:ethnicity-has-degree\] and \[fig:categorical\], considering not just their predictive ability for Clinton vs. Trump but also their predictive ability in terms of voting for other / not voting, labeling “Participation Rate” to mean the fraction of eligible voters in a category who voted for either Trump or Clinton, thus combining both nonvoters and those who voted for a third-party candidate.  In Figure \[fig:ethnicity-has-degree\], for example, whites with college degrees participated highly and mostly supported Clinton.  Whites without college degrees did not participate as highly and mostly supported Trump.  Sizes of each buble represent the approximate relative size of each subgroup.  For race, occupation, and education level, we show only the most-populous subgroups. 

![ Ethnicity-has degree[]{data-label="fig:ethnicity-has-degree"}](square_ETHNICITY_HASDEGREE){width=".7\textwidth"}

[.45]{} ![ Several categorical features’ estimated marginal effects on outcomes.[]{data-label="fig:categorical"}](square_COW "fig:"){width="\textwidth"}

 

[.45]{} ![ Several categorical features’ estimated marginal effects on outcomes.[]{data-label="fig:categorical"}](square_MSP "fig:"){width="\textwidth"}

\

[.45]{} ![ Several categorical features’ estimated marginal effects on outcomes.[]{data-label="fig:categorical"}](square_OCCP "fig:"){width="\textwidth"}

 

[.45]{} ![ Several categorical features’ estimated marginal effects on outcomes.[]{data-label="fig:categorical"}](square_RAC3P "fig:"){width="\textwidth"}

\

[.45]{} ![ Several categorical features’ estimated marginal effects on outcomes.[]{data-label="fig:categorical"}](square_SCHL "fig:"){width="\textwidth"}

 

[.45]{} ![ Several categorical features’ estimated marginal effects on outcomes.[]{data-label="fig:categorical"}](square_SEX_ETHNICITY "fig:"){width="\textwidth"}

Conclusions
===========

This is a work in progress—we are sharing it before the analysis is complete in order to get feedback and in the hopes that it can inform the thinking and analysis of others.  In particular, we intend to make comparisons to 2012 data.  We will also further explore the wealth of variables in the American Community Survey, add fine-grained spatial maps to complement the demographic modeling in Section \[section:inferring\] and visualize the distributions of real-valued covariates for the most important features discovered in Section \[section:group-based\].  Finally, we will consider Bayesian alternatives to the penalized MLE approach in Section \[section:group-based\] so as to, e.g. infer posterior uncertainty regions over the location of our estimates in the square plots. 

Model fit {#sec:model-fit}
=========

![ Fit of our model.  Black dots are electoral outcomes by local area, while blue dots are exit polling (survey-based) state-level results by age, sex, and education.[]{data-label="fig:scatter"}](scatter){width=".6\paperwidth"}

Supplementary results {#sec:supplement}
=====================

[^1]: For correspondence: flaxman@stats.ox.ac.uk

[^2]: [www.github.com/dougalsutherland/pummeler](www.github.com/dougalsutherland/pummeler) and [www.github.com/flaxter/us2016](www.github.com/flaxter/us2016)

[^3]: <http://www.nytimes.com/2016/03/13/upshot/the-geography-of-trumpism.html>

[^4]: [www.github.com/dougalsutherland/pummeler](www.github.com/dougalsutherland/pummeler)

[^5]: [www.github.com/flaxter/us2016](www.github.com/flaxter/us2016)
