tooltips in R graphics; nytR package

Monday December 28, 2009

Filed under: politics,R,statistics — jackman @ 8:20 pm

At Doug Rivers’ suggestion, I started investigating tooltips as a way to label points in R graphs. An example appears at the top of my blog, where I plot the ideal points (revealed preferences) of the (current) 111th U.S. House of Representatives against Obama vote share in their district in 2008 (SVG).

I’m using the RSVGTipsDevice package in R for this, which seems to be the only way to get tooltips into R graphics output. SVG is a reasonable enough vehicle when pushing output to the web, but PDF would be preferable.

As far as I can tell, (a) the “raw” PDF one needs to generate a tooltip isn’t difficult, and there are lots of examples out there to copy from (e.g., the various tooltip packages for pdftex), but (b) there is no way to push arbitrary PDF to a PDF device from R. Hacking/re-writing the pdf device in R might be one way to go, but I’m not going to do that. Post-processing the PDF with a program with decent PDF support might be another way to attack this (maybe python).

In other R-for-polisci news, Shane Conway told me about a R package he has but together for getting NYTimes data into R. The NYTimes has APIs letting you get into their in-house data, such as roll call data from the U.S. Congress. Shane’s package is essentially a R interface to to the NYTimes API for the Congressional data. Nice, although you’ll need a NYTimes API key for this. See also the R code snippet for NYTimes scraping from Stanford’s own Claudia Engel.

I use my own readKH function in pscl to hit Jeff Lewis’ site; Jeff scrapes the Congressional web sites in close to real time, but the NYTimes has some nice contextual data as well.

Comments (1)

malapportionment in the U.S. Senate

Wednesday December 23, 2009

Filed under: politics,R,statistics — jackman @ 4:29 am

The 40 Republican senators currently in the U.S. senate represent 36% of the U.S population. See the graph below (click on the thumbnail for PDF).

This is something I’ve been meaning to compute for a while now, mapping the cumulative distribution of senators’ ideal points onto the cumulative distribution of state population (each state counts twice, once for each senator, and of course we exclude DC and PR from the calculation of the total population).

With the relatively high degree of partisan polarization in roll call voting we place all 40 Republicans to the right of the Democratic senators. And — as recent roll calls on the health care issue have made clear — in the current 111th Senate the Democrats plus Sanders and Lieberman constitute 60 votes, with the most conservative Democrat (Nelson, NE) the “veto pivot”. Between them, the 60 Dems represent 64% of the population.

My prior expectation was for more “small state” bias pushing that 64% higher, but (a) Dems represent some small states (e.g., VT, ND, DE, MT, RI, HI have 2 Dem senators); (b) Republicans have the 2 TX and GA senators, and the OH/FL/NC Senate delegations are split.

The “bias” is a little more pronounced at the chamber median threshold: i.e., the 50 “most liberal” (Democratic) senators represent 57% of the population.


Comments (1)

Empirical Implications of Theoretical Models

Saturday December 19, 2009

Filed under: general,politics,statistics — jackman @ 6:57 pm

I’m teaching at EITM at STL again this coming summer. The announcement from Steve Smith just went out on PolMeth:

The Washington University Summer Institute on the Empirical Implications of Theoretical Models is an NSF-sponsored program to train junior faculty and graduate students on the problems of testing formal models of politics. This summer’s institute meets June 14-July 1, 2010. The application deadline is February 19, 2010.
The program website is http://wc.wustl.edu/eitm.html. You will find seminar listings, application information, and housing information on the website. Five seminars will be held next summer.

Calvert and Martin (WashU), Theoretical and Methodological Foundations
Fey (Rochester), Random Utility Models and Strategic Choice
Jackman (Stanford), Operationalizing the Spatial Model
Wilson (Rice) and Haptonstahl (Davis), Experimental Applications
Roberts (UNC), Issues in Testing Theories of Legislative Politics
Walker (WashU), International Relations Applications

Participants selected for this program will receive a $1,500 stipend. This will be used to cover their travel, room, and board. Up to 25 subsidies are available for full-time participants currently attending U.S. universities. Participants shall be responsible for any and all costs of living expenses in St. Louis for the three-week long institute. Funding is provided by the National Science Foundation.

Comments Off on Empirical Implications of Theoretical Models

afs, Kerberos, cron

Monday December 14, 2009

Filed under: computing — jackman @ 2:38 pm

Another computing note, mainly for myself.

Problem: backing up server assets to /afs space via a cron job. How does one get afs credentials “headlessly”?

Solution: the k5start program. This connects to a Kerberos server, gets a v5 ticket while a job runs, then lets the ticket go. I built k5start locally, after building the supporting programs remctl and wallet. All of these programs are developed and maintained by Stanford’s own Russ Allbery, fwiw (Stanford makes a lot of use of afs & Kerberos).

In my wallet build I set a configure flag to point the program at Stanford’s wallet.stanford.edu:

./configure –with-wallet-server=wallet.stanford.edu

Other steps:
I asked the Stanford IT people to create a “service principal” for me. This took just a couple of hours for them to do. You then download the keytab using wallet. I used

wallet -f <localKeytabFile> -u <sunetid> get keytab service/<principal>


Make sure you have a Stanford-issued /etc/krb5.conf  

You also need the right acl on the part of afs you want this to write to. e.g., if we want to write to /afs/<path> then you’ll need to set

fsr setacl /afs/<path> service.<principal>

After all that, my use of k5start in the cron’d shell-script is

/usr/local/bin/k5start -f <localKeyTabFile> -u service -i <principal> <backUpScriptName>

where backUpScriptName is another shell-script with my actual back commands (e.g., rsync writing to /afs<path>).

One day I’ll figure out how launchctl works and dump cron.

Comments Off on afs, Kerberos, cron

Fake Steve Jobs and Edmund Burke?

Sunday December 13, 2009

Filed under: computing,general — jackman @ 2:33 pm

A great rant from Fake Steve Jobs re iPhone/ATT tension (service lapses in places like NYC and San Francisco on Friday; is it the iPhone hardware, is it the ATT network, is it the fact that there are no bandwidth caps with the ATT iPhone plans as yet, contra just about everywhere else in the world). Fake Steve concludes by noting:

Now there was silence again. This time I was the one not talking. There was this weird lump in my throat, this tightness in my chest. I had this vision of the future — a ruined empire, run by number crunchers, squalid and stupid and puffed up with phony patriotism, settling for a long slow decline.

Those sentences remind me of Edmund Burke in Reflections on the Revolution in France:

…the age of chivalry is gone.

That of sophisters, economists; and calculators has succeeded; and the glory of Europe is extinguished forever.

I hate to say it, but hard bandwidth caps might be the answer (versus the soft bandwidth cap you get when the ATT network falters in high density areas).

Comments Off on Fake Steve Jobs and Edmund Burke?

the coolest stars

Friday December 11, 2009

Filed under: general — jackman @ 5:00 pm

Deliciously ambiguous press release from NASA, as reported on CNN:

Screen shot 2009-12-11 at 4.58.09 PM.jpg
Comments Off on the coolest stars

Roy & HG hiatus

Filed under: Australian Politics,general — jackman @ 1:42 am

The winter chill has really set in, here in the Northern Hemisphere…. Roy & HG off-air until sometime in the New Year. Ugh.

Screen Shot 2009-12-11 At 1.34.46 Am

Comments Off on Roy & HG hiatus

ESS, Aquamacs, R-Devel

Tuesday December 8, 2009

Filed under: computing,statistics — jackman @ 10:58 pm

ESS got a version bump so it plays better with R-devel (currently 2.11), which has some subtle changes to the help functions.

I’m now running the following:

Screen Shot 2009-12-08 At 10.53.57 Pm

Screen Shot 2009-12-08 At 10.52.24 Pm

The install of ESS 5.7.1 was very easy. svn checkout, and then changing some variables in Makeconf: e.g.,

## Section 1
## Installation variables for your emacs variant
## Variable Description
## EMACS use emacs for GNU Emacs, xemacs for XEmacs
## EMACSBATCH emacs/xemacs command for compiling elisp files
## LISPDIR Destination of compiled elisp files
## INFODIR Destination of info files
## ETCDIR Destination of script and icon files
## Specify either PREFIX or DESTDIR to over-ride /usr/local
## GNU Emacs
ETCDIR =$(PREFIX)/ess-mode/etc

Then make and make install.

Comments Off on ESS, Aquamacs, R-Devel

ABC Online is great, but…

Filed under: Australian Politics,computing — jackman @ 1:40 pm

ABC Online is great, especially for the ex-pat crowd chasing news and current affairs from Australia.

Offshore, we can’t see iView, and rely on either web sites of individual shows or iTunes offerings; Lateline and the ABC Fora offerings are two popular iTunes vodcasts in our household.

The ABC’s iTunes publishing latter seems very hit-or-miss, depending on the show, which would seem to suggest that publishing to iTunes isn’t being handled in a centralized manner at the ABC. Another sign that this may be the case is the variation in naming schemes for the different XML feeds across the different shows.

The 7.30 Report sometimes briefly works in iTunes, but usually not: e.g.,

Screen Shot 2009-12-08 At 12.46.00 Pm

And Insiders has no iTunes option at all.

I guess if you want to drive eyeballs to the individual program sites, having a broken iTunes setup or none at all is a good way to proceed.

Comments Off on ABC Online is great, but…

subversion on Snow Leopard

Filed under: computing — jackman @ 4:35 am

This took forever to figure out how to do…hence a blog post (a memory prompt for myself, should I ever need it).

I’m using the new (improved?) ServerAdmin tool in OS/X Server Tools 10.6.2. Put the https server on port 443 (as is standard, I used to run 8443 under Leopard, but svn just didn’t want to play ball on 8443, I’ll actually experiment with this again at some point).

Follow the directions here, on the Apple site. That is, all the auth stuff is coming from OpenDirectory etc. I defined a “realm” via ServerAdmin, naming it “svn_realm”. All nice and easy.

I have multiple subversion repositories at <path>/svn, so the hand-hack in the site-specific httpd.conf file for the virtual site on port (8)443 is in my case:

<Location /svn/>
DAV svn
SVNParentPath <path>/svn
AuthName "svn_realm"
AuthType Basic
Require user <userid>

In addition: do not have a symlink from DocumentRoot to the svn repos named svn. This will confuse apache as documented here.

Permissions/mode check on the repos.

Seperate logs for the (8)443 site handling the svn queries etc are helpful for better diagnosing errors.

Comments Off on subversion on Snow Leopard
Next Page »

Powered by WordPress