<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>David B. Sparks</title>
	<atom:link href="http://dsparks.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dsparks.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sat, 22 Dec 2012 12:41:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='dsparks.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>David B. Sparks</title>
		<link>http://dsparks.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://dsparks.wordpress.com/osd.xml" title="David B. Sparks" />
	<atom:link rel='hub' href='http://dsparks.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Mapping Public Opinion: A Tutorial</title>
		<link>http://dsparks.wordpress.com/2012/07/18/mapping-public-opinion-a-tutorial/</link>
		<comments>http://dsparks.wordpress.com/2012/07/18/mapping-public-opinion-a-tutorial/#comments</comments>
		<pubDate>Wed, 18 Jul 2012 23:04:21 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[geography]]></category>
		<category><![CDATA[public opinion]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=400</guid>
		<description><![CDATA[At the upcoming 2012 summer meeting of the Society of Political Methodology, I will be presenting a poster on Isarithmic Maps of Public Opinion. Since last posting on the topic, I have made major improvements to the code and robustness of the modeling approach, and written a tutorial that illustrates the production of such maps. This&#160;&#8230; <a href="http://dsparks.wordpress.com/2012/07/18/mapping-public-opinion-a-tutorial/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=400&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://dsparks.files.wordpress.com/2012/07/2008-cces-ideological-self-placement-leveled-copy.png"><img class="aligncenter size-full wp-image-401" title="2008 CCES Ideological Self-Placement" src="http://dsparks.files.wordpress.com/2012/07/2008-cces-ideological-self-placement-leveled-copy.png?w=640" alt=""   /></a>At the upcoming <a href="http://polmeth.web.unc.edu/">2012 summer meeting</a> of the Society of Political Methodology, I will be presenting a poster on <a href="http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/">Isarithmic Maps of Public Opinion</a>. Since last posting on the topic, I have made major improvements to the code and robustness of the modeling approach, and written a tutorial that illustrates the production of such maps.</p>
<p>This tutorial is in a very rough draft form, but I will post it here when it is finalized. (An earlier draft had some errors, and so I have taken it down.)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/400/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/400/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=400&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2012/07/18/mapping-public-opinion-a-tutorial/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2012/07/2008-cces-ideological-self-placement-leveled-copy.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2012/07/2008-cces-ideological-self-placement-leveled-copy.png?w=150" medium="image">
			<media:title type="html">2008 CCES Ideological Self-Placement</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2012/07/2008-cces-ideological-self-placement-leveled-copy.png" medium="image">
			<media:title type="html">2008 CCES Ideological Self-Placement</media:title>
		</media:content>
	</item>
		<item>
		<title>Isarithmic Maps of Public Opinion Data</title>
		<link>http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/</link>
		<comments>http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 06:00:48 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[geography]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[public opinion]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=376</guid>
		<description><![CDATA[As a follow-up to my isarithmic maps of county electoral data, I have attempted to experiment with extending the technique in two ways. First, where the electoral maps are based on data aggregated to the county level, I have sought to generalize the method to accept individual responses for which only zip code data is&#160;&#8230; <a href="http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=376&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>As a follow-up to my <a href="http://dsparks.wordpress.com/2010/11/15/isarithmic-history-of-the-two-party-vote/">isarithmic maps of county electoral data</a>, I have attempted to experiment with extending the technique in two ways. First, where the electoral maps are based on data aggregated to the county level, I have sought to generalize the method to accept individual responses for which only zip code data is known. Further, since survey respondents are not distributed uniformly across the geographic area of the United States (tending to be concentrated in more populous states and around cities), I have attempted to convey a sense of uncertainty or data sparsity through transparency. Some early products of this experimentation can be seen below.</p>
<div id="attachment_377" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-black.png"><img class="size-full wp-image-377" title="CCES 2008, Party Identification (black)" src="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-black.png?w=640&#038;h=360" alt="Party Identification" width="640" height="360" /></a><p class="wp-caption-text">Isarithmic map of party identification from the 2008 CCES. Click to enlarge.</p></div>
<p style="text-align:left;"><span id="more-376"></span></p>
<p style="text-align:left;">This map is produced from over 30,000 individual responses to the standard 7-point party identification question. I generate dense grid of points across the map, and calculate a distance-weighted mean value for each point, as well as a distance-weighted response density for each point. This grid is then smoothed through interpolation via the <a href="http://cran.r-project.org/web/packages/akima/index.html">akima package</a> and plotted with Hadley Wickham&#8217;s excellent <a href="http://had.co.nz/ggplot2/">ggplot2</a>. I use a blue-red diverging color scale to encode mean values, and a transparency/alpha parameter to encode local density (similar to <a href="http://www.axismaps.com/blog/2008/11/a-new-kind-of-election-map/">this approach</a> for choropleth maps). Thus, in the northwestern U.S., from which relatively few responses were collected, the colors can be seen to &#8220;fade to black.&#8221; The same process, with a white background, is illustrated below.</p>
<div id="attachment_382" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-white.png"><img class="size-full wp-image-382" title="CCES 2008, Party Identification (white)" src="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-white.png?w=640&#038;h=360" alt="CCES 2008, Party Identification (white)" width="640" height="360" /></a><p class="wp-caption-text">Same approach as above, but with a white background. Click to enlarge.</p></div>
<p style="text-align:left;">The feedback I have gotten thus far suggests that the black background has better  æsthetics, but the white background is more clearly interpreted. I would be very interested in hearing your impressions of the relative merits of both.</p>
<p style="text-align:left;">The party identification maps above show the benefit of this ZIP code-based approach. First, unlike the <a href="http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/">choropleth</a> approach, local political-geographic features are preserved without being obscured by the shape of boundary lines, such as county borders. For example, there is a clear difference between Atlanta and surrounding, more suburban areas, as well as within Miami, where the southern end of the city stands out as more Republican-leaning than the rest. Additionally, unlike choropleth maps in which variable/color values can change abruptly at boundaries which may be unfamiliar to the viewer, the distance smoothing employed here makes color-encoded information very clear around easily-identifiable major communities.</p>
<p style="text-align:left;">The other major benefit of this approach is that it can take as input any public opinion data for which some rough information is known about respondent location. Here I use ZIP codes, which are sufficiently granular to offer a nuanced view, but not so specific as to identify respondents. While it unsurprisingly works best with a large number of respondents, as seen here, I have also used a sample of 1,000 respondents, with useful results.</p>
<p style="text-align:left;">Here is a map of a variable of much current debate &#8212; family income. High income levels are concentrated along the coasts and around major cities. Again, compare the white and black backgrounds.</p>
<div id="attachment_383" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/10/cces-2008-family-income-black.png"><img class="size-full wp-image-383" title="CCES 2008, Family Income (black)" src="http://dsparks.files.wordpress.com/2011/10/cces-2008-family-income-black.png?w=640&#038;h=360" alt="CCES 2008, Family Income (black)" width="640" height="360" /></a><p class="wp-caption-text">Isarithmic map of the distribution of family income levels. Click to enlarge.</p></div>
<div id="attachment_384" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/10/cces-2008-family-income-white.png"><img class="size-full wp-image-384" title="CCES 2008, Family Income (white)" src="http://dsparks.files.wordpress.com/2011/10/cces-2008-family-income-white.png?w=640&#038;h=360" alt="CCES 2008, Family Income (white)" width="640" height="360" /></a><p class="wp-caption-text">The distribution of family income levels, with a white background to indicate response density. Click to enlarge.</p></div>
<p style="text-align:left;">These maps of abortion attitudes, as is the case with many interesting variables, fairly closely mirror the map of party identification. If you have data that you would like to see mapped in this way, especially with variables that don&#8217;t correlate so well with party identification or ideology, please get in touch with me.</p>
<div id="attachment_385" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/10/cces-2010-abortion-attitudes-black.png"><img class="size-full wp-image-385" title="CCES 2010, Abortion Attitudes (black)" src="http://dsparks.files.wordpress.com/2011/10/cces-2010-abortion-attitudes-black.png?w=640&#038;h=360" alt="CCES 2010, Abortion Attitudes (black)" width="640" height="360" /></a><p class="wp-caption-text">Map of abortion attitudes. I should emphasize here that the legend illustrates color values describing local means, and the legend text list possible survey responses. Click to enlarge.</p></div>
<div id="attachment_386" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/10/cces-2010-abortion-attitudes-white.png"><img class="size-full wp-image-386" title="CCES 2010, Abortion Attitudes (white)" src="http://dsparks.files.wordpress.com/2011/10/cces-2010-abortion-attitudes-white.png?w=640&#038;h=360" alt="CCES 2010, Abortion Attitudes (white)" width="640" height="360" /></a><p class="wp-caption-text">Abortion attitudes, with white background. Click to enlarge.</p></div>
<p style="text-align:left;"><strong>On color</strong></p>
<p style="text-align:left;">Identifying optimal color schemes has been a challenge with these maps. I generally prefer to use a diverging palette to maximize color variance and the ease with which value gradations can be discerned. However, the excellent <a href="http://colorbrewer2.org/">ColorBrewer</a> diverging palettes tend to pass through white, which becomes indistinguishable from areas with low data density. As such, I have used analogous color palettes which span about 150 degrees around the hue spectrum, and tend to work well with varying alpha values over both black and white. Here again, I would be interested in hearing ideas about optimal color schemes when transparency is used to encode an additional data dimension.</p>
<p style="text-align:left;">
<p style="text-align:left;"><strong>Edit</strong>: The code as it stands right now is embarrassingly ugly and convoluted. Once I am able to incorporate any feedback, and clean up the code, I will be happy to share.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/376/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=376&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2011/10/isarithmic-thumbnail.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2011/10/isarithmic-thumbnail.png?w=150" medium="image">
			<media:title type="html">Isarithmic Thumbnail</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-black.png" medium="image">
			<media:title type="html">CCES 2008, Party Identification (black)</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-white.png" medium="image">
			<media:title type="html">CCES 2008, Party Identification (white)</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/10/cces-2008-family-income-black.png" medium="image">
			<media:title type="html">CCES 2008, Family Income (black)</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/10/cces-2008-family-income-white.png" medium="image">
			<media:title type="html">CCES 2008, Family Income (white)</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/10/cces-2010-abortion-attitudes-black.png" medium="image">
			<media:title type="html">CCES 2010, Abortion Attitudes (black)</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/10/cces-2010-abortion-attitudes-white.png" medium="image">
			<media:title type="html">CCES 2010, Abortion Attitudes (white)</media:title>
		</media:content>
	</item>
		<item>
		<title>Ideological extremity in social networks</title>
		<link>http://dsparks.wordpress.com/2011/03/22/ideological-extremity-in-social-networks/</link>
		<comments>http://dsparks.wordpress.com/2011/03/22/ideological-extremity-in-social-networks/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 19:51:06 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[behavior]]></category>
		<category><![CDATA[congress]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=352</guid>
		<description><![CDATA[Update: Make sure to read Joshua Brustein&#8217;s nice write-up of our research at the New York Times, as well as Dr. Seth Masket&#8217;s impressions. ﻿At the upcoming meeting of the Midwest Political Science Association, Aaron King, Frank Orlando, and I will be presenting a paper that investigates the determinants of success in Senate primary elections. We&#160;&#8230; <a href="http://dsparks.wordpress.com/2011/03/22/ideological-extremity-in-social-networks/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=352&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><span style="color:#cc4542;"><strong>Update</strong></span>: Make sure to read Joshua Brustein&#8217;s nice write-up of our research at the <a href="http://bits.blogs.nytimes.com/2011/03/21/on-twitter-conservative-by-association/">New York Times</a>, as well as Dr. Seth Masket&#8217;s <a href="http://enikrising.blogspot.com/2011/04/dw-tweetinate.html">impressions</a>.</p>
<p>﻿At the upcoming meeting of the Midwest Political Science Association, Aaron King, Frank Orlando, and I will be presenting a paper that investigates the determinants of success in Senate primary elections. We are primarily interested in whether voters are best modeled as voting by ideological proximity, or whether primary electorates strategically select candidates who offer a better chance of victory in the general election. Essentially, we are trying to identify whether ideological extremity is an advantage or a hindrance to primary electoral success.</p>
<div class="wp-caption aligncenter" style="width: 382px"><a href="http://dl.dropbox.com/u/83576/Joint%20Prediction-colored%20Graph%20Layout%20%28small%29.pdf"><img title="bigger network thumb" src="http://dsparks.files.wordpress.com/2011/03/bigger-network-thumb.png?w=372&#038;h=228" alt="" width="372" height="228" /></a><p class="wp-caption-text">Click for PDF version of the network graph (may be slow to load)</p></div>
<p style="text-align:left;">Unfortunately, estimating the ideology of many of these candidates can be problematic, given that many, for example, have not cast a roll-call vote which could be used in a NOMINATE-like scaling. Absent a more explicitly political record, we turn to the social networking/microblogging site Twitter, and collect data on the connections between elected officials and the mass public of Twitter users.</p>
<p style="text-align:left;">We use a nonmetric multidimensional scaling algorithm to estimate a space which represents users&#8217; Twitter behavior, and find that the second dimension of that space correlates very well with Poole and Rosenthal&#8217;s NOMINATE scores for Senators and Representatives. Our main results can be seen in the figure below, and the paper is now available for download <a href="http://goo.gl/ULvJ1">here</a>.</p>
<div id="attachment_356" class="wp-caption aligncenter" style="width: 650px"><a href="http://goo.gl/UOm3V"><img class="size-full wp-image-356 " title="Full thumbnail" src="http://dsparks.files.wordpress.com/2011/03/full-thumbnail.png?w=640&#038;h=404" alt="" width="640" height="404" /></a><p class="wp-caption-text">Click for PDF version of the estimate summary dotplot.</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/352/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=352&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2011/03/22/ideological-extremity-in-social-networks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2011/03/bigger-network-thumb.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2011/03/bigger-network-thumb.png?w=150" medium="image">
			<media:title type="html">bigger network thumb</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/03/bigger-network-thumb.png" medium="image">
			<media:title type="html">bigger network thumb</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/03/full-thumbnail.png" medium="image">
			<media:title type="html">Full thumbnail</media:title>
		</media:content>
	</item>
		<item>
		<title>Choropleth tutorial and regression coefficient plots</title>
		<link>http://dsparks.wordpress.com/2011/02/21/choropleth-tutorial-and-regression-coefficient-plots/</link>
		<comments>http://dsparks.wordpress.com/2011/02/21/choropleth-tutorial-and-regression-coefficient-plots/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 14:56:10 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[geography]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=320</guid>
		<description><![CDATA[About two weeks ago, I gave short talk at Duke, wherein I presented a brief tutorial on creating choropleth maps in R using ggplot2. Since the code is already written, and the data and shapefiles already hosted online, I thought I would share the tutorial more widely. A .ZIP file containing all the files necessary&#160;&#8230; <a href="http://dsparks.wordpress.com/2011/02/21/choropleth-tutorial-and-regression-coefficient-plots/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=320&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>About two weeks ago, I gave short talk at Duke, wherein I presented a brief tutorial on creating choropleth maps in R using <a href="http://had.co.nz/ggplot2/coord_map.html">ggplot2</a>. Since the code is already written, and the data and shapefiles already hosted online, I thought I would share the tutorial more widely.</p>
<p>A .ZIP file containing all the files necessary to follow the tutorial is available at: <a href="http://goo.gl/UrvQo">http://goo.gl/UrvQo</a>.</p>
<p>The script goes very briefly through the loading of shapefiles and presidential election returns, and ends with the production of the choropleth below.</p>
<div id="attachment_325" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/02/2008-choropleth.png"><img class="size-full wp-image-325" title="2008 Choropleth" src="http://dsparks.files.wordpress.com/2011/02/2008-choropleth.png?w=640&#038;h=360" alt="" width="640" height="360" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p style="text-align:left;">I don&#8217;t get into further customization of the map, as there are other <a href="http://had.co.nz/ggplot2/">more authoritative and complete</a> sources for that. Further, much more detailed instruction on reading shape files are available from <a href="http://csiss.org/">CSISS</a> and <a href="http://www.nceas.ucsb.edu/scicomp/usecases/ReadWriteESRIShapeFiles">NCEAS</a>.</p>
<p style="text-align:left;">Included at the very end of the script is a brief example of a regression coefficient plot, something like a ggplot2 version of the coefplot() in <a href="http://www.stat.columbia.edu/~gelman/blog/">Andrew Gelman</a>&#8216;s <a href="http://cran.r-project.org/web/packages/arm/arm.pdf">arm package</a>.</p>
<p style="text-align:left;">I decided to develop the example into a function that takes as input a list() of model objects, and returns a ggplot2 object, which can be further modified by the user if so desired.</p>
<div id="attachment_328" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/02/cp.png"><img class="size-full wp-image-328 " title="CP" src="http://dsparks.files.wordpress.com/2011/02/cp.png?w=640&#038;h=360" alt="" width="640" height="360" /></a><p class="wp-caption-text">A coefficient plot comparing three models.</p></div>
<p style="text-align:left;">The script for the above plot can be found <a href="https://gist.github.com/818976">here</a>. I also wrote a function that eschews arbitrarily discrete confidence bounds, instead attempting to suggest a sense of our confidence in the estimate without choosing a specific interval, since the difference between significance and insignificance is <a href="http://www.stat.columbia.edu/~gelman/research/published/signif4.pdf">not itself significant</a>. Code for the function is available <a href="https://gist.github.com/818997">here</a>, and an example can be seen below.</p>
<div id="attachment_335" class="wp-caption aligncenter" style="width: 650px"><a href="http://dsparks.files.wordpress.com/2011/02/scp.png"><img class="size-full wp-image-335" title="SCP" src="http://dsparks.files.wordpress.com/2011/02/scp.png?w=640&#038;h=640" alt="" width="640" height="640" /></a><p class="wp-caption-text">Smoothed standard error coefficient plots</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=320&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2011/02/21/choropleth-tutorial-and-regression-coefficient-plots/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2011/02/deep-south.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2011/02/deep-south.png?w=150" medium="image">
			<media:title type="html">Deep South</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/02/2008-choropleth.png" medium="image">
			<media:title type="html">2008 Choropleth</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/02/cp.png" medium="image">
			<media:title type="html">CP</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2011/02/scp.png" medium="image">
			<media:title type="html">SCP</media:title>
		</media:content>
	</item>
		<item>
		<title>High Dimension Visualization in Political Science</title>
		<link>http://dsparks.wordpress.com/2011/01/24/high-dimension-visualization-in-political-science/</link>
		<comments>http://dsparks.wordpress.com/2011/01/24/high-dimension-visualization-in-political-science/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 14:36:24 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[methods]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=303</guid>
		<description><![CDATA[Last Friday, I gave a talk illustrating some examples of high-dimension visualization in Political Science. I structured the talk around three arbitrary categories of information visualization: infographics (factoid-packed, inefficient), statistical graphics (argument-making, minimal), and data displays (multidimensional, deep). The slides below are long on examples and short on text, but should be mostly self-explanatory. Header&#160;&#8230; <a href="http://dsparks.wordpress.com/2011/01/24/high-dimension-visualization-in-political-science/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=303&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Last Friday, I gave a talk illustrating some examples of high-dimension visualization in Political Science. I structured the talk around three arbitrary categories of information visualization: infographics (factoid-packed, inefficient), statistical graphics (argument-making, minimal), and data displays (multidimensional, deep). The slides below are long on examples and short on text, but should be mostly self-explanatory.</p>
<iframe class="scribd_iframe_embed" src="http://www.scribd.com/embeds/47458971/content?start_page=1&view_mode=slideshow&access_key=key-mlfvt04ahwk269yk8or" data-auto-height="true" scrolling="no" id="scribd_47458971" width="100%" height="500" frameborder="0"></iframe>
<div style="font-size:10px;text-align:center;width:100%"><a href="http://www.scribd.com/doc/47458971">View this document on Scribd</a></div>
<p><em>Header image from <a href="http://bibliodyssey.blogspot.com/2009/12/victorian-infographics.html">BibliOdyssey</a>.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/303/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=303&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2011/01/24/high-dimension-visualization-in-political-science/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2011/01/victorian-mountain-infographics.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2011/01/victorian-mountain-infographics.png?w=150" medium="image">
			<media:title type="html">Victorian Mountain Infographic</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>
	</item>
		<item>
		<title>Electoral Marimekko Plots</title>
		<link>http://dsparks.wordpress.com/2010/12/06/electoral-marimekko-plots/</link>
		<comments>http://dsparks.wordpress.com/2010/12/06/electoral-marimekko-plots/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 12:29:38 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[behavior]]></category>
		<category><![CDATA[geography]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=280</guid>
		<description><![CDATA[To be reductive, visual displays of quantitative information might be reasonably categorized on a continuum between &#8220;data display&#8221; and &#8220;statistical graphics.&#8221; By statistical graphics, I mean a plot that displays some summary of or relationship amongst several variables, likely having undergone some processing or analysis. This may be as simple as a scatterplot of a&#160;&#8230; <a href="http://dsparks.wordpress.com/2010/12/06/electoral-marimekko-plots/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=280&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>To be reductive, visual displays of quantitative information might be reasonably categorized on a continuum between &#8220;data display&#8221; and &#8220;statistical graphics.&#8221; By statistical graphics, I mean a plot that displays some summary of or relationship amongst several variables, likely having undergone some processing or analysis. This may be as simple as a scatterplot of a primary independent variable and the dependent variable, a boxplot, or a <a href="http://www.stat.columbia.edu/~cook/movabletype/archives/2007/12/trends_in_votin.html">graphical regression table</a>.</p>
<p>In this reductive scheme, then, &#8220;data displays&#8221; present variables in raw form &#8212; for use in exploratory data analysis, or perhaps just to offer the viewer access to all of the data. Where &#8220;statistical graphics&#8221; might be best served by simplicity and minimalism in design, such that a single idea might be conveyed clearly, &#8220;data displays&#8221; will tend to be inherently complex, and require effort from both the creator and viewer to parse meaning from the available information.</p>
<p>Where statistical graphics are ideal for presenting conclusions, data displays are useful for generating ideas, and optimally, permitting the relatively rapid identification of relationships between multiple variables. On top of this, I might add that many of the more well-regarded data displays of recent note offer macro-level insight as well as the opportunity to ascertain specific details (for this, interactivity is often valuable, as in the internet-classic <a href="http://www.nytimes.com/interactive/2008/02/23/movies/20080223_REVENUE_GRAPHIC.html">New York Times box office visualization</a>).</p>
<p>As <a title="Regionalization via network-constrained clustering" href="http://dsparks.wordpress.com/2010/05/30/regionalization-via-network-constrained-clustering/">several</a> <a title="Choropleth Maps of Presidential Voting" href="http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/">recent</a> <a title="Isarithmic History of the Two-Party Vote" href="http://dsparks.wordpress.com/2010/11/15/isarithmic-history-of-the-two-party-vote/">posts</a> suggest, I am interested in finding ways to successfully and clearly convey multidimensional data, and have been focusing on political data as it varies across geopolitical units and time. Here I offer an approach which departs from the spatial basis of other recent efforts in favor of allowing the position of graphical objects to convey other variables.</p>
<div id="attachment_282" class="wp-caption aligncenter" style="width: 650px"><a href="http://picasaweb.google.com/dsparks/ElectoralMarimekkoPlotsTurnout#slideshow/5547399922928066226"><img class="size-full wp-image-282 " title="County Vote Spinogram (Turnout), 1992" src="http://dsparks.files.wordpress.com/2010/12/county-vote-spinogram-turnout-1992.png?w=640&#038;h=426" alt="County Vote Spinogram (Turnout), 1992" width="640" height="426" /></a><p class="wp-caption-text">County Vote Marimekko Plot, 1992, sorted by votes cast. Click for slideshow.</p></div>
<p>This type of plot is called, variously, a <a href="http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=117">spinogram</a>, a <a href="http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/mosaicplot.html">mosaic plot</a>, or a <a href="http://learnr.wordpress.com/2009/03/29/ggplot2_marimekko_mosaic_chart/">marimekko</a> &#8212; and is not dissimilar from a <a href="http://vizlab.nytimes.com/page/Treemap.html">treemap</a> with a different organizational structure (<a href="http://arbitrarian.wordpress.com/2008/04/25/choosing-the-mvp-geometrically/">other</a> <a href="http://arbitrarian.wordpress.com/boxscores/">examples</a>). The utility of this plot type is that it can spatially convey four numeric variables (x position, y position, height, width), and color can be added to incorporate up to three additional variables (R, G, B). Further, there is a straightforward geometric interpretation of each cell: the areas of each (in this case, width/state turnout ×height/county proportion of state turnout) are directly comparable.</p>
<p>Unlike a stacked bar plot, the width of each column conveys information, permitting height to convey proportion rather than count. Further, columns and cells within columns can be sorted to express the ordering of variables of interest. In some ways, these can be seen as extreme reinterpretations of <a href="http://www.ncgia.ucsb.edu/projects/Cartogram_Central/types.html">(Dorling) cartograms</a>, in which not only the size and shape of political boundaries, but also their position, are distorted by other variables.</p>
<div id="attachment_286" class="wp-caption aligncenter" style="width: 650px"><a href="http://picasaweb.google.com/dsparks/ElectoralMarimekkoPlotsDem2PV#slideshow/5547399144404648210"><img class="size-full wp-image-286 " title="County Vote Spinogram (Dem 2PV), 1924" src="http://dsparks.files.wordpress.com/2010/12/county-vote-spinogram-dem-2pv-1924.png?w=640&#038;h=426" alt="County Vote Spinogram (Dem 2PV), 1924" width="640" height="426" /></a><p class="wp-caption-text">County Vote Marimekko Plot, 1924, sorted by Democratic share of the two-party vote. Click for slideshow.</p></div>
<p>In the plots above, cells are colored according to the strength of Democratic (blue), Republican (red), and other party (green) support, and counties whose turnout represents greater than 1% of the total turnout in an election are labeled.</p>
<p>I present two different layouts for the cells in each plot. The first arrays states left-to-right in order of the number of votes cast in an election, and sorts counties bottom-to-top in the same order. Thus, more populous states are on the right, and more populous counties are at the top of the plot. This arrangement allows the viewer to observe the effects of population density both within and across states, and may better facilitate tracking changes in county or state politics over time.</p>
<p>The second layout sorts states left-to-right, and counties bottom-to-top in order of the Democratic share of the two party vote (Dem Votes / (Dem Votes + Rep Votes)). Thus, more Democratic-leaning (relative to Republican) states are on the right, and counties that were more supportive of Democratic candidates are at the top. I believe that this arrangement makes it easier to discern overall trends in partisanship across time, as the total &#8220;sum&#8221; of red within a diagram is relatively easy to compare to the total &#8220;sum&#8221; of blue (and green).</p>
<p>I have attempted to make my R code fairly general, and it is available for download <a href="http://goo.gl/oEwix">here</a>, although it will obviously require some modifications for other applications. Our approaches differ, but another instructive example can be found at <a href="http://learnr.wordpress.com/2009/03/29/ggplot2_marimekko_mosaic_chart/">Learning R</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=280&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2010/12/06/electoral-marimekko-plots/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2010/12/2008-marimekko.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2010/12/2008-marimekko.png?w=150" medium="image">
			<media:title type="html">2008 County Voting Marimekko</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/12/county-vote-spinogram-turnout-1992.png" medium="image">
			<media:title type="html">County Vote Spinogram (Turnout), 1992</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/12/county-vote-spinogram-dem-2pv-1924.png" medium="image">
			<media:title type="html">County Vote Spinogram (Dem 2PV), 1924</media:title>
		</media:content>
	</item>
		<item>
		<title>Isarithmic History of the Two-Party Vote</title>
		<link>http://dsparks.wordpress.com/2010/11/15/isarithmic-history-of-the-two-party-vote/</link>
		<comments>http://dsparks.wordpress.com/2010/11/15/isarithmic-history-of-the-two-party-vote/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 07:00:05 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[geography]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=255</guid>
		<description><![CDATA[A few weeks ago, I shared a series of choropleth maps of U.S. presidential election returns, illustrating the relative support for Democratic, Republican, and third Party candidates since 1920. The granularity of these county level results led me to wonder whether it would be possible to develop an isarithmic map of presidential voting using the&#160;&#8230; <a href="http://dsparks.wordpress.com/2010/11/15/isarithmic-history-of-the-two-party-vote/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=255&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A few weeks ago, I shared a series of <a href="http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/">choropleth maps</a> of U.S. presidential election returns, illustrating the relative support for Democratic, Republican, and third Party candidates since 1920. The granularity of these county level results led me to wonder whether it would be possible to develop an isarithmic map of presidential voting using the same data.</p>
<p>Isarithmic maps are essentially <a href="http://en.wikipedia.org/wiki/Topographic_map">topographic</a> or <a href="http://www.weather.gov/forecasts/graphical/sectors/conus.php?element=T">contour</a> maps, wherein a third variable is represented in two dimensions by color, or by contour lines, indicating gradations. I had never seen such a map depicting political data &#8212; certainly not election returns, and thus sought to create them.</p>
<p>There is a trade-off between an isarithmic depiction versus a choroplethic depiction, in which a third variable is shown within discrete political boundaries. Namely, that though a politically-delineated presentation better facilitates the connection of the variable of interest to the level at which it was measured, the superimposition of geographically arbitrary political boundaries may cloud the existence of more general regional patterns.</p>
<p>Election-year maps can be seen in a slideshow <a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#slideshow/5538441124502946498">here</a> (and compared to the three-color choropleth maps <a href="http://picasaweb.google.com/dsparks/ChoroplethMapsOfPresidentialVotingByCounty19202008#slideshow/5534284533404643266">here</a>). The isarithmic depiction does an excellent job of highlighting several broad patterns in modern U.S. political history.</p>
<p style="text-align:left;"><a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#5538441832859184658"><img class="aligncenter size-full wp-image-266" title="2008 Isarithmic Map" src="http://dsparks.files.wordpress.com/2010/11/2008-00.png?w=640&#038;h=360" alt="2008 Isarithmic Map" width="640" height="360" /></a>First, it does a good job of depicting local &#8220;peaks&#8221; and &#8220;valleys&#8221; of partisan support clustered around urban areas. In the <a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#5538441832859184658">2008 map</a>, for example, Salt Lake City, Denver, Chicago, Miami, Memphis, and many other cities stand apart from their surrounding environs, highlighted by a relatively intense concentration of voters with distinct partisan leanings. In <a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#5538441733136220914">1980</a>, this method shows that though Reagan enjoyed broad support in California, the revolution was not felt in the Bay Area.</p>
<p style="text-align:left;">Comparison of these maps across time also underscores well-known political trends, but offers more resolution than state-level choropleths and greater clarity than county-level choropleths. Note the nearly inverted maps for <a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#5538441124901923010">1924</a> and <a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#5538441832858423874">2004</a>, between which elections the Solid South went from solidly Democratic to solidly Republican. Interestingly, though that particular regional pattern has been remarkably consistent since <a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#5538441736523119282">1984</a>, the South favored a Democratic candidate as recently as <a href="http://picasaweb.google.com/dsparks/IsarithmicMapsOfTheTwoPartyPresidentialVote19202008#5538441733136220914">1980</a>.</p>
<p>These patterns over time are even better observed in motion. Interpolating support between elections, I have generated a video in which these maps shift smoothly from one election year to the next. The result is the story of 20th century presidential politics on a grand scale, condensed into a little 0ver a minute of data visualization.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/k4h62jRiUcc?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;hd=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>The video can also be seen at <a href="http://www.youtube.com/watch?v=k4h62jRiUcc&amp;fmt=22">YouTube</a> (I recommend the &#8220;expanded&#8221; or &#8220;full screen&#8221; view), or at <a href="http://vimeo.com/16732494">Vimeo</a>. The images were rendered at 1280 x 720 pixels, to allow the video to be seen in HD.</p>
<p>This animated interpretation accentuates certain phenomena: the breadth and duration of support for <a href="http://www.youtube.com/watch?v=k4h62jRiUcc&amp;fmt=22#t=11s">Roosevelt</a>, the shift from a Democratic to a Republican South, <a href="http://www.youtube.com/watch?v=k4h62jRiUcc&amp;fmt=22#t=50s">the move</a> from an ostensibly east-west division to the contemporary coasts-versus-heartland division, and the stability of the latter.</p>
<p>More broadly, this video is a reminder that what constitutes &#8220;politics as usual&#8221; is always in flux, shifting sometimes abruptly. The landscape of American politics is constantly evolving,  as members of the <a href="http://www.jstor.org/stable/1962968">two great parties</a> battle for electoral supremacy.</p>
<p><strong>Appendix on creating the visualization</strong></p>
<p>Using county-level presidential returns from the <a href="http://library.cqpress.com/elections/index.php">CQ Press Voting and Elections Collection</a>, I associated each county&#8217;s support in a given election year for the Democratic and Republican candidates with an approximation of that county&#8217;s centroid in degrees latitude and longitude, using the shapefiles loaded with the package <a href="http://cran.r-project.org/web/packages/mapdata/index.html">mapdata</a>.</p>
<p>I then used simple linear interpolation to create a smoothed transition from election-to-election, creating 99-interelectoral estimates of partisanship for each county. Using a custom function and the interp function from <a href="http://cran.r-project.org/web/packages/akima/index.html">akima</a>, I created a spatially smoothed image of interpolated partisanship at points other than the county centroids.</p>
<p>This resulted in inferred votes over the Gulf of Mexico, the Atlantic and Pacific Oceans, the Great Lakes, Canada and Mexico &#8212; so I had to clip any interpolated points outside of the U.S. border using the very handy pinpoly function from the <a href="http://cran.r-project.org/web/packages/spatialkernel/index.html">spatialkernel</a> package.</p>
<p>Finally, I created a custom color palette, a modification of the RdBu scheme from <a href="http://colorbrewer2.org/">Colorbrewer</a>, using colorRampPalette(), and plotted the interpolated data along with state borders using the excellent <a href="http://had.co.nz/ggplot2/">ggplot2</a>.</p>
<p>I would like to note that I would have preferred using the <a href="http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers">Albers Equal Area Conic projection</a>, but settled on the default Mercator projection, as drawing the Albers map with ggplot2 was prohibitively time-consuming, given that I was generating 2,201 individual frames.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=255&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2010/11/15/isarithmic-history-of-the-two-party-vote/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2010/11/1980-00.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2010/11/1980-00.png?w=150" medium="image">
			<media:title type="html">1980.00</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/11/2008-00.png" medium="image">
			<media:title type="html">2008 Isarithmic Map</media:title>
		</media:content>
	</item>
		<item>
		<title>Choropleth Maps of Presidential Voting</title>
		<link>http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/</link>
		<comments>http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 07:00:11 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[geography]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=169</guid>
		<description><![CDATA[Having always appreciated the red and blue cartograms and cartographs of geographic electoral preferences, such as those made available by Mark Newman, I sought to produce similar maps, but include information about support for non-&#8221;state-sponsored&#8221; parties, and to extend the coverage back in time. I was able to find county-level presidential election returns going as&#160;&#8230; <a href="http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=169&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Having always appreciated the red and blue cartograms and cartographs of geographic electoral preferences, such as those made available by <a href="http://www-personal.umich.edu/~mejn/election/2008/">Mark Newman</a>, I sought to produce similar maps, but include information about support for <a href="http://mungowitzend.blogspot.com/2006/05/my-speech-from-nc-libertarian-state.html">non-&#8221;state-sponsored&#8221; parties</a>, and to extend the coverage back in time.</p>
<p>I was able to find county-level presidential election returns going as far back as 1920, thanks to the <a href="http://library.cqpress.com/elections/index.php">CQ Press Voting and Elections Collection</a> (gated). I converted the proportion of the vote garnered by Democratic, Republican, and &#8220;Other&#8221; parties&#8217; candidates to coordinates in three-dimensional RGB color space, and used shapefiles from the <a href="http://cran.r-project.org/web/packages/mapdata/index.html">mapdata</a> package to plot these results as choropleth maps with <a href="http://cran.r-project.org/web/packages/ggplot2/index.html">ggplot</a>.</p>
<p style="text-align:center;"><a href="http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/#gallery-169-1-slideshow">Click to view slideshow.</a></p>
<p>It is interesting to observe these maps in a series, which gives historical context to the <a href="http://en.wikipedia.org/wiki/Red_states_and_blue_states">Red State/Blue State</a> narrative. Most obviously, there is a significant shift in the geographic center of Democratic support, from a concentration in the southeast to the present equilibrium, localized on each coast and near the Great Lakes.</p>
<p>Among these 23 elections, landslide victories, such as <a href="http://picasaweb.google.com/lh/photo/cDmiUlqcHB8c7cyEISEpRQ?feat=directlink">Roosevelt over Landon in 1936</a>, <a href="http://picasaweb.google.com/lh/photo/wbM5yyAkBSUAF-IQvaM12A?feat=directlink">Johnson over Goldwater in 1964</a>, <a href="http://picasaweb.google.com/lh/photo/dNWXpPSSh6GG2SGlZsQoHQ?feat=directlink">Nixon over McGovern in 1972</a>, and <a href="http://picasaweb.google.com/lh/photo/a-v8xScqbgRQeTpfPpP1pg?feat=directlink">Reagan over Mondale in 1984</a>, tend to stand out for their monochromaticity.</p>
<p>Also intriguing are the elections featuring substantial support for third-party candidates. Most of these are individuals who were had a strong support base in a specific region of the country, such as <a href="http://picasaweb.google.com/lh/photo/XQQZz1QK4uuO2tOwFoMaKQ?feat=directlink">La Follette in the northwest</a>, and <a href="http://picasaweb.google.com/lh/photo/eUH_XhA7zYgY6BlaHI7QvA?feat=directlink">Thurmond </a>and <a href="http://picasaweb.google.com/lh/photo/aCsaVb4kZa0Rt00GPJFNTQ?feat=directlink">Wallace </a>in the deep south. Ross Perot&#8217;s run in 1992 is unique here, as his relatively broad geographic base of support results in a <a href="http://picasaweb.google.com/lh/photo/o3v_Ab_DBT5HnuqfS-TL9A?feat=directlink">map that runs the gamut</a> to a greater degree than any others.</p>
<p>Click on the image below to see a full screen version of the slideshow above, or to download any of the individual maps as PNGs.</p>
<p style="text-align:center;"><a href="http://picasaweb.google.com/dsparks/ChoroplethMapsOfPresidentialVotingByCounty19202008#slideshow/5534284533404643266"><img class="aligncenter size-thumbnail wp-image-228" title="1964" src="http://dsparks.files.wordpress.com/2010/10/three-color-chloropleth1.png?w=150&#038;h=91" alt="Goldwater" width="150" height="91" /></a> <em><a href="http://picasaweb.google.com/dsparks/ChoroplethMapsOfPresidentialVotingByCounty19202008#slideshow/5534284533404643266">Click for slideshow/download</a></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=169&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2010/11/01/choropleth-maps-of-presidential-voting/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2010/10/three-color-chloropleth1.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2010/10/three-color-chloropleth1.png?w=150" medium="image">
			<media:title type="html">1964</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>
	</item>
		<item>
		<title>K-Means Redistricting</title>
		<link>http://dsparks.wordpress.com/2010/10/18/k-means-redistricting/</link>
		<comments>http://dsparks.wordpress.com/2010/10/18/k-means-redistricting/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 23:37:59 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[congress]]></category>
		<category><![CDATA[geography]]></category>
		<category><![CDATA[institutions]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=61</guid>
		<description><![CDATA[U.S. Congressional districts are today drawn with the aim of maximizing the electoral advantage of the state&#8217;s majority party, subject to some constraints, including compactness (which can be measured in numerous ways) and a &#8220;one person, one vote&#8221; standard. What if, instead of minimizing population variance across districts, we aimed to minimize the mean distance between&#160;&#8230; <a href="http://dsparks.wordpress.com/2010/10/18/k-means-redistricting/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=61&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>U.S. Congressional districts are today drawn with the aim of maximizing the electoral advantage of the state&#8217;s majority party, subject to some constraints, including compactness (which can be measured in <a href="http://www.jstor.org/stable/490799">numerous ways</a>) and a <a href="http://laws.findlaw.com/us/376/1.html">&#8220;one person, one vote&#8221;</a> standard. What if, instead of minimizing population variance across districts, we aimed to minimize the mean distance between each resident and their district center?</p>
<p>To do so would be to employ something very much like <a href="https://docs.google.com/viewer?url=http://www-m9.ma.tum.de/foswiki/pub/WS2010/CombOptSem/kMeans.pdf">k-means clustering</a>, and produces some interesting results.</p>
<p>Using the population and latitude and longitude coordinates of the centroid of each (2000) census tract (a block-level reproduction was deemed too computationally intensive for the present purposes), I produced a geospatial k-means clustering for several states. Each tract was represented by its centroid as a point, weighted by population (which required a custom function, as the default <a href="http://svn.r-project.org/R/trunk/src/library/stats/R/kmeans.R">kmeans()</a> function in R does not appear to permit weighted points.</p>
<p>Since each run of the k-means algorithm begins with a random set of points, I replicated the function several thousand times, attempting to find a maximum inverse <a href="http://www.jstor.org/stable/1818582">Herfindahl-Hirschman</a> index of district population &#8212; the &#8220;effective number of districts,&#8221; as it were. For North Carolina, as shown below, I was able to find a maximum END of 12.17 for thirteen districts, which is a fairly even distribution of population.</p>
<p><a href="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-district-colors.png"><img class="alignnone size-full wp-image-77" style="display:block;margin-left:auto;margin-right:auto;" title="NC Cluster Redistricting, district colors" src="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-district-colors.png?w=640&#038;h=201" alt="" width="640" height="201" /></a></p>
<p style="text-align:center;"><em>Click to enlarge</em></p>
<p>Interestingly, there is still substantially wider variation in population than would be permitted under the current system. The least populous district houses fewer than 400,000 individuals, and the most populous, nearly a million. These figures are much more extreme than the extant least- (Wyoming) and most- (Montana) populous districts.</p>
<p>Population by district:</p>
<pre>#  Population
1  398492
4  398896
8  423710
10 525860
2  533812
13 537417
3  618040
6  662092
11 676221
12 767249
7  785668
5  786448
9  935408</pre>
<p>However, the district boundaries (here hastily drawn by use of chull()) are not characterized by the ragged edges and elongated shapes often seen in the <a href="http://www.govtrack.us/congress/findyourreps.xpd?state=NC">existing plans</a>.</p>
<p>I was interested in what the k-means-based plan would do to district partisanship, and decided to use population density as a rough proxy for local party affiliation. The distribution of population per square mile for each North Carolina census tract is shown below, with a vertical line indicating the median.</p>
<p style="text-align:center;"><a href="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-pop-density-density.png"><img class="size-full wp-image-79 aligncenter" title="NC Cluster Redistricting, pop density density" src="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-pop-density-density.png?w=640" alt=""   /></a></p>
<p>I decided to characterize any tract with greater-than-median population density as Democratic, and less-dense tracts as Republican. This resulted in the following proportion of Democrats residing in each district as plotted above:</p>
<pre>#  % Dem.
1  0.253
4  0.265
10 0.336
8  0.350
6  0.383
7  0.474
13 0.510
3  0.589
11 0.615
9  0.628
12 0.671
2  0.673
5  0.837</pre>
<p>As the table indicates, full turnout under such a plan would result in the election of 6 Republicans and 7 Democrats. Below, I plot &#8220;Democratic&#8221; tracts in blue and &#8220;Republican&#8221; tracts in red, scaled according to their population. Urban centers are easily identifiable. Note the difference between this plan and the current actual plan, which <a href="http://www.govtrack.us/congress/findyourreps.xpd?state=NC&amp;district=12">draws a single elongated district</a> (the twelfth) parallel to Interstate 85.</p>
<p style="text-align:center;"><a href="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-partisanship.png"><img class="size-full wp-image-78 aligncenter" title="NC Cluster Redistricting, partisanship" src="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-partisanship.png?w=640&#038;h=204" alt="" width="640" height="204" /></a></p>
<p style="text-align:center;"><em>Click to enlarge</em></p>
<p>Below, I replicate the same process for the state of Texas, generating 32 districts. One problem with the k-means algorithm is that larger states, or those with greater variance in population density, tend to generate districts with wide variations in population and inequalities of representation. The Texas plan below depicts a district with fewer than 200,000 residents and one with over 2 million. The Effective Number of Districts (maximum after 100 attempts) is a mere 21.58. Interestingly, the the district &#8220;partisanship&#8221; split is 22/10 majority Republican/Democrat &#8212; not far from the current 20/12 split. In this simulated redistricting, there are 10 districts in which the majority of residents live in higher-than-the-state-median density areas: four each in Houston and Dallas-Fort Worth, one each around San Antonio and Austin.</p>
<p style="text-align:center;"><a href="http://dsparks.files.wordpress.com/2010/10/tx-cluster-redistricting-partisanship.png"><img class="size-full wp-image-92 aligncenter" title="TX Cluster Redistricting, partisanship" src="http://dsparks.files.wordpress.com/2010/10/tx-cluster-redistricting-partisanship.png?w=640&#038;h=522" alt="" width="640" height="522" /></a></p>
<p style="text-align:center;"><em>Click to enlarge</em></p>
<p>The slideshow below depicts the incremental steps of the weighted k-means algorithm toward convergence around alternate districts for Ohio, beginning with set of random centers, and eventually minimizing collective distances from local centroids.</p>
<p style="text-align:center;"><iframe class="scribd_iframe_embed" src="http://www.scribd.com/embeds/38721849/content?start_page=1&view_mode=slideshow&access_key=key-wmc7mycmkf0ggyq48l3" data-auto-height="true" scrolling="no" id="scribd_38721849" width="100%" height="500" frameborder="0"></iframe>
<div style="font-size:10px;text-align:center;width:100%"><a href="http://www.scribd.com/doc/38721849">View this document on Scribd</a></div></p>
<p>Finally, I used the same algorithm to investigate what a the continental United States would look like if states were partitioned according to the k-means rule. Clicking on the image below will bring you to an interactive, scalable map of the U.S. with 48 alternate states and inferred partisanship. Instead of initializing with random centers, I started the k-means algorithm with the population centroids of the actual states, and allowed the algorithm to converge to a minimizing partition. Many of these alternative states are more compact but familiar versions of the originals, although this new plan does realize <a href="http://www.marxists.org/reference/archive/plunkett-george/tammany-hall/#s16">Plunkitt&#8217;s Fondest Dream</a>.</p>
<p style="text-align:center;"><a href="http://zoom.it/6KdF#full"><img class="size-full wp-image-160 aligncenter" title="New England, New States" src="http://dsparks.files.wordpress.com/2010/10/new-england-new-states.png?w=640" alt=""   /></a></p>
<p style="text-align:center;"><em>Click to enlarge</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=61&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2010/10/18/k-means-redistricting/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-feature.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-feature.png?w=150" medium="image">
			<media:title type="html">NC Cluster Redistricting (feature)</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-district-colors.png" medium="image">
			<media:title type="html">NC Cluster Redistricting, district colors</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-pop-density-density.png" medium="image">
			<media:title type="html">NC Cluster Redistricting, pop density density</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/10/nc-cluster-redistricting-partisanship.png" medium="image">
			<media:title type="html">NC Cluster Redistricting, partisanship</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/10/tx-cluster-redistricting-partisanship.png" medium="image">
			<media:title type="html">TX Cluster Redistricting, partisanship</media:title>
		</media:content>

		<media:content url="http://dsparks.files.wordpress.com/2010/10/new-england-new-states.png" medium="image">
			<media:title type="html">New England, New States</media:title>
		</media:content>
	</item>
		<item>
		<title>Dimensionality in Congress</title>
		<link>http://dsparks.wordpress.com/2010/09/03/dimensionality-in-congress/</link>
		<comments>http://dsparks.wordpress.com/2010/09/03/dimensionality-in-congress/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 23:59:29 +0000</pubDate>
		<dc:creator>d sparks</dc:creator>
				<category><![CDATA[congress]]></category>
		<category><![CDATA[institutions]]></category>
		<category><![CDATA[methods]]></category>

		<guid isPermaLink="false">http://dsparks.wordpress.com/?p=110</guid>
		<description><![CDATA[Update: A revised version of this paper, given as a poster at the 2011 Summer Meeting of the Society for Political Methodology, is available here (PDF). &#160; In collaboration with Jacob Montgomery and John Aldrich, I am interested in understanding the relationship between observed (measured) and unobserved (true) dimensionality in Congress. In an ongoing project,&#160;&#8230; <a href="http://dsparks.wordpress.com/2010/09/03/dimensionality-in-congress/">Read&#160;more</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=110&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Update: A revised version of this paper, given as a poster at the 2011 Summer Meeting of the Society for Political Methodology, is available <a title="PolMeth paper on Dimensionality" href="http://dsparks.files.wordpress.com/2010/09/aldrich-montgomery-sparks.pdf">here</a> (PDF).</p>
<p>&nbsp;</p>
<p>In collaboration with <a href="http://www.duke.edu/~jmm61/">Jacob Montgomery</a> and <a href="http://www.duke.edu/~aldrich/">John Aldrich</a>, I am interested in understanding the relationship between observed (measured) and unobserved (true) dimensionality in Congress. In an ongoing project, we employ Monte Carlo simulations of legislative voting behavior, followed by dimensionality-reducing scaling techniques, to identify the parameters under which we might observe roll-call scalings similar to those we find in empirical data. Our findings suggest that the typical account of the dimensionality of ideology in Congress, &#8220;one-and-a-half dimensions,&#8221; may arise under a large variety of &#8220;true&#8221; dimensionality settings.</p>
<p>One of our papers, given at the 2010 APSA, is available for viewing or download <a title="Aldrich, Montgomery, Sparks 2010" href="http://dsparks.files.wordpress.com/2010/10/aldrich-montgomery-and-sparks-apsa.pdf" target="_blank">here</a> [PDF].</p>
<p>The slides from our paper presentation may be seen below.</p>
<iframe class="scribd_iframe_embed" src="http://www.scribd.com/embeds/38785077/content?start_page=1&view_mode=slideshow&access_key=key-apd457c4w5c6az2chc9" data-auto-height="true" scrolling="no" id="scribd_38785077" width="100%" height="500" frameborder="0"></iframe>
<div style="font-size:10px;text-align:center;width:100%"><a href="http://www.scribd.com/doc/38785077">View this document on Scribd</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dsparks.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dsparks.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dsparks.wordpress.com&#038;blog=5850314&#038;post=110&#038;subd=dsparks&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dsparks.wordpress.com/2010/09/03/dimensionality-in-congress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://dsparks.files.wordpress.com/2010/10/pseparation-v-gamma.png?w=150" />
		<media:content url="http://dsparks.files.wordpress.com/2010/10/pseparation-v-gamma.png?w=150" medium="image">
			<media:title type="html">Dimensionality Reduction, Party Separation v Gamma</media:title>
		</media:content>

		<media:content url="http://2.gravatar.com/avatar/2d0d981936042d6cea0f71ecdb187b1f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rapidadverbssuck</media:title>
		</media:content>
	</item>
	</channel>
</rss>
