Journalism in the Public Interest

The ProPublica Nerd Blog

Untangling a Web of FEC Data


Our Tangled Web graphic shows the 200 biggest recipients of expenditure money from the five major presidential campaigns (Gingrich, Obama, Paul, Romney and Santorum), as well as from major super PACs, from around the middle of 2011 through February, 2012.

Campaign finance reporters Kim Barker and Justin Elliott dug into the top 200 recipients and assembled detailed descriptions most of them. Some of the companies receiving money from campaigns and committees incorporated shortly before this election cycle and are described here in detail for the first time. The graphic also shows examples of campaigns and super PACs sharing consultants, which as the New York Times detailed last month can raise questions about improper coordination.

Assembling the Data

To assemble the data, we used the New York Times’ Campaign Finance API to grab ID numbers for FEC filings. From there, we grabbed the filings thesmelves by passing each of the filing IDs to FECh, a handy Ruby gem also written by the Times. Then we filtered out ones marked as amendments or as quarterly, year-end or monthly aggregations.

Using Google Refine, a tool for cleaning messy data, we clustered recipient organization names and merged ones that differed slightly; for example, we merged together payments marked “Google” and “Google Inc.” We then selected the top 200 recipients across all of the committees and campaigns we are tracking.

We also needed to filter out line items that contained a back_reference_tran_id_number which are simply the itemization details of another expenditure we’ve already counted, like credit card payments.

This is obviously very complicated stuff and we did have a hiccup: the first version of the graphic, which was live on our site for a few minutes, didn’t filter out some filings that were superceded by amendments. We also hadn’t taken out backreferenced transactions. Because of that, our numbers were much larger than they should have been. To get it right, we ended up running every step of our methodology by the FEC.

Making the Graphic

The graphic itself is called a Sankey diagram. They’re designed to show both flow direction and rate. The most famous Sankey diagram is probably Minard’s map of Napoleon’s 1812 Russia campaign, one of visualization expert Edward Tufte’s favorite graphics.

To make the diagram, we wrote scripts to output the top 200 recipients, as well as the campaigns and committees into a huge JSON hash. Using jQuery, we created divs on each side of the graph with heights proportional to each committee’s share of all the money that went to a given payee. To create the flow lines, we used Raphael.js, a library that makes it easy to draw vector graphics on web pages. In Raphael, we drew lines with the thickness of each committee-payee div connecting them by their ids. To create the nice quadratic bezier curve, we used a little code from Tom Counsell’s Sankey library. Basically, instead of drawing lines directly from one side to the other, we curved them by a specific ratio to give it the snake-like look typical of the Sankey diagram. Here’s how that looks and works:

Special thanks to Derek Willis at the Times and Paul Clark at the FEC for helping us interpret the filing data.