# rjags

February 5, 2012
By

(This article was first published on Rrasch, and kindly contributed to R-bloggers)

Running 64 bit R, JAGS and rjags on EC2

Winbugs and Jags free Item Response Theory from the dot matrix plots of proprietary software and open up a multicoloured world of posterior predictive model checking. Fitting IRT models using brute force is not for the impatient, however. That’s why, just as early psychometricians shipped off their calculations to teams of monks. I’ve shipped off my model fitting to the West Coast of Ireland (seems apt considering the number of monasteries there) so that I can use my computer to do more important things. Like write about why I’ve shipped off my model fitting to the West Coast of Ireland.

Configuration of rjags for 64-bit R is a little tricky - so here’s how I did it.

Warning 1!

If you want to run JAGS in the cloud it’ll probably cost you a few bob. That’s because on the EC2 micro instances JAGS models tend to trigger the CPU limit and grind to a halt. If you want to run odd jobs then I’d suggest setting up JAGS on an official Ubuntu EC2 Large image, shutting it down, saving the image, then running it at a spot price. That means for a you’ll be paying about $0.38 during set up and$0.144 per hour when it is running. If you want an image that is always running I’d suggest you check out monthly hosting rates with other cloud services which can be cheaper than EC2. If you don’t want to use R or JAGS then heroku is tremendous for ease of deployment of web projects.

Warning 2!

Don’t try and set this up on ubuntu’s new image Precise unless you want to haunt the LAPACK and BLAS message boards for the next six months…

Warning 3!

If none of this means anything to you I’d recommend playing about with EC2 micro instances and ensuring you can get into and out of them using SSH. As my main computer is Windows based I use putty and FileZilla. FileZilla allows you to configure a default text editor so it is fine for writing most programming languages.

I like ubuntu - it makes life easy and the documentation is usually helpful.

Step 0:

Step 1: Install ubuntu:

Current Time 09:32
Soundtrack: Ligeti, Atmospheres

Official ubuntu AMIS are here. Enter region and ubuntu builds into the filter. I chose an oneiric image on a 64 bit platform with ebs:

eu-west-1 oneiric amd64 ebs 20120108 ami-09e3dc7d

For the initial set up I chose Large as the installation is much quicker… Again a few dimes involved…

So, here goes. Choose defaults, your SSH security group which I assume you’ve set up, and away we go…

Step 2: Install R

Current Time 09:44
Soundtrack: Study for Player Piano Number 9

Step 3: Coda package and JAGS Current Time: 10:02

Soundtrack: Treeline

Step 4: RJAGS Current Time: 10:13

Soundtrack: De Staat

The final hurdle, one on which many eyeballs have bled. Configuring RJAGS for 64 bit R. Pity poor Martyn Plummer who is doomed to wandering the bulletin boards helping lost souls in search of their .so

Luckily, I wrote down how to do this the last time I was in purgatory. Now, let me see… Where is it… Please… No… Oh, the horror…

Found it!

Step 5: Test it! Current Time: 10:23

Soundtrack: De Staat

Try, for example: www.johnmyleswhite.com

Step 6: Stop the instance and save the image on AWS. Then, when you are ready to run your job you can request a spot instance and pay for only the time it takes to run your job.

Current Time: 10:32

Soundtrack: De Staat

Total Time: 1 hour (including at least ten minutes interrogating my fish as to where I had saved my instructions for configuring RJAGS)

Total Cost: \$0.38

Final warning: If you are SSHing into your instance don’t forget to set your analysis going using the nohup command, otherwise your analysis will be terminated as soon as you log out.