This is a picture of the American electorate!
More precisely; this is a scatterplot I just made using the dataset recently released by PPP, a major political polling firm. (They’re the outfit that did the “is your state hot or not” poll I blogged about last week.) PPP has made available the raw responses from 46 polls with 1000 responses each, conducted more or less weekly over the course of 2011. Here’s the whole thing as a .zip file.
Analyzing data sets like this is in some sense not hard. But there’s a learning curve. Little things, like: you have to know that the .csv format is beautifully portable and universal — it’s the ASCII of data. You have to know how to get your .csv file into your math package of choice (in my case, python, but I think I could easily have done this in r or MatLab as well) and you have to know where to get a PCA package, if it’s not already installed. And you have to know how to output a new .csv file and make a graphic from it when you’re done. (As you can see, I haven’t quite mastered this last part, and have presented you with a cruddy Excel scatterplot.) In total, this probably took me about three hours to do, and now that I have a data-to-picture path I understand how to use, I think I could do it again in about 30 minutes. It’s fun and I highly recommend it. There’s a lot of data out there.
So what is this picture? The scatterplot has 1000 points, one for each person polled in the December 15, 2011 PPP survey. The respondents answered a bunch of questions, mostly about politics:
Q1: Do you have a favorable or unfavorable opinion of Barack Obama?
Q2: Do you approve or disapprove of Barack Obama’s job performance?
Q3: Do you think Barack Obama is too liberal, too conservative, or about right?
Q4: Do you approve or disapprove of the job Harry Reid is doing?
Q5: Do you approve or disapprove of the job Mitch McConnell is doing?
Q6: Do you have a favorable or unfavorable opinion of the Democratic Party?
Q7: Do you have a favorable or unfavorable opinion of the Republican Party?
Q8: Generally speaking, if there was an election today, would you vote to reelect Barack Obama, or would you vote for his Republican opponent?
Q9: Are you very excited, somewhat excited, or not at all excited about voting in the 2012 elections?
Q10: If passed into law one version of immigration reform that people have discussed would secure the border and crack down on employers who hire illegal immigrants. It would also require illegal immigrants to register for legal immigration status, pay back taxes, and learn English in order to be eligible for U.S. citizenship. Do you favor or oppose Congress passing this version of immigration reform?
Q11: Have you heard about the $10,000 bet Mitt Romney challenged Rick Perry to in last week’s Republican Presidential debate?
Q12: (Asked only of those who say ‘yes’ to Q11:) Did Romney‚Äôs bet make you more or less likely to vote for him next year, or did it not make a difference either way?
Q13: Do you believe that there’s a “War on Christmas” or not?
Q14: Do you consider yourself to be a liberal, moderate, or conservative?
Q15: Do you consider yourself to be a supporter of the Tea Party or not?
Q16: Are you or is anyone in your household a member of a labor union?
Q17: If you are a woman, press 1. If a man, press 2.
Q18: If you are a Democrat, press 1. If a Republican, press 2. If you are an independent or a member of another party, press 3.
Q19: If you are Hispanic, press 1. If white, press 2. If African American, press 3. If Asian, press 4. If you are an American Indian, press 5. If other, press 6.
Q20: (Asked only of people who say American Indian on Q19:) Are you enrolled in a federally recognized tribe?
Q21: If you are 18 to 29 years old, press 1. If 30 to 45, press 2. If 46 to 65, press 3. If you are older than 65, press 4.
Q22: What part of the country do you live in NOW – the Northeast, the Midwest, the South, or the West?
Q23: What is your household’s annual income?
The answers to these questions, which are coded as integers, now give us 1000 points in R^{23}. Our eyes are not good at looking at point clouds in 23-dimensional space. So it’s useful to project down to R^2, that mos bloggable of Euclidean spaces. But how? We could just look at two coordinates and see what we get. But this requires careful choice. Suppose I map the voters onto the plane via their answers to Q1 and Q2. The problem is, almost everyone who has a favorable opinion of Barack Obama approves of his job performance, and vice versa. Considering these two features is hardly better than considering only one feature. Better would be to look at Q8 and Q21; these two variables are surely less correlated, and studying both together would give us good information on how support for Obama varies with age. But still, we’re throwing out a lot. Principal component analysis is a very popular quick-n-dirty method of dimension reduction; it finds the projection onto R^2 (or a Euclidean space of any desired dimension) which best captures the variance in the original dataset. In particular, the two axes in the PCA projection have correlation zero with each other.
A projection from R^23 to R^2 can be expressed by two vectors, each one of which is some linear combination of the original 23 variables. The hope is always that, when you stare at the entries of these vectors, the corresponding axis has some “meaning” that jumps out at you. And that’s just what happens here.
The horizontal axis is “left vs. right.” It assigns positive weight to approving of Obama, identifying as a liberal, and approving of the Democratic Party, and negative weight to supporting the Tea Party and believing in a “War on Christmas.” It would be very weird if any analysis of this kind of polling data didn’t pull out political affiliation as the dominant determinant of poll answers.
The second axis is “low-information voter vs. high-information voter,” I think. It assigns a negative value to all answers of the form “don’t know / won’t answer,” and positive value to saying you are “very excited to vote” and having heard about Mitt Romney’s $10,000 bet. (Remember that?)
And now the picture already tells you something interesting. These two variables are uncorrelated, by definition, but they are not unrelated. The voters split roughly into two clusters, the Democrats and the Republicans. But the plot is “heart-shaped” — the farther you go into the low-information voters, the less polarization there is between the two parties, until in the lower third of the graph it is hard to tell there are two parties at all. This phenomenon is not surprising — but I think it’s pretty cool that it pops right out of a completely automatic process.
(I am less sure about the third-strongest axis, which I didn’t include in the plot. High scorers here, like low scorers on axis 2, tend to give a lot of “don’t know” answers, except when asked about Harry Reid and Mitch McConnell, whom they dislike. They are more likely to say they’re “not at all excited to vote” and more likely to be independents. So I think one might call this the “to hell with all those crooks” axis.)
A few technical notes: I removed questions, like “region of residence,” that didn’t really map on a linear scale, and others, like “income,” that not everyone answered. I normalized all the columns to have equal variance. I made new 0-1-valued columns to record “don’t know” answers. Yes, I know that many people consider it bad news to run PCA on binary variables, but I decided that since I was just trying to draw pictures and not infer anything, it would be OK.
Of course you know I’d love to see what happens if you try to impute the withheld income amounts using PCA with missing data! :)
Now you’re talking!
I removed questions, like “region of residence,” that didn’t really map on a linear scale
If you’re okay with using binary variables, you could just have dummy variables that are 1 for “lives in region X” and 0 otherwise. It probably wouldn’t change the results much, though.
True, although at that point it might be equally informative just to make four separate plots, one for each region. Also, most of these folks have zipcodes — I looked for a package that would plot the points on a US map with their two PCA coordinates indicated by color, but I didn’t find anything.
[…] Ellenberg has a heart-shaped plot of the American electorate obtained by principal component analysis of some raw polling […]
Regarding “.csv format is beautifully portable and universal”, whoever wrote the my.wisc.edu/faculty center grading software will disagree with you. I tried uploading my grades for last semester using a csv as directed and wasted a bunch of my time and my TAs time with it. By the time I talked to someone knowledgeable (this was over winter break), I was told that I had saved it as a Mac csv file, but I was supposed to save it as a Windows csv file. While I wasn’t told explicitly the difference, I’m pretty sure it’s that Windows and Mac have different “end of line” characters, i.e. different mixes of “carriage return” and “new line”. There’s also apparently an MS-DOS csv format. Of course, these are all just text files as you say, but if the person coding isn’t smart enough to adjust end of line characters, they end up wasting a lot of people’s time!!
Also, you could make that scatter plot in sage, if you like!