JAGS and rjags for Fedora 13 64 bit

May 30, 2010

Unfortunately, JAGS is not in the Fedora repositories. However, it is very easy to install. This is a short how-to for installing JAGS and rjags for Fedora 13 64 bit and it should work for any 64 bit UNIX based OS. As a prerequisite, make sure you have the dependencies for JAGS installed (this is for Fedora only).

yum install R R-devel libblas-devel

Next thing you’ll want to do is to download the tarball and unpack it .

tar xvzf JAGS*

Next you need to tell it to install the libraries in /usr/local/lib64 otherwise you’ll need to tell rjags where to look for JAGS.

./configure --libdir=/usr/local/lib64
sudo make install

Next you can test that JAGS installed properly by typing:


Once this is done, fire up R and install rjags like any other package and that’s it.



GNU IceCat for Debian Squeeze 64 bit

May 25, 2010

I decided that I wanted a newer version of Firefox than 3.5.9 that was presently in Debian Squeeze. I read elsewhere that this would be the version that Squeeze would be shipping (Iceweasel 3.5.x) with and not Firefox 3.6.x. So I decided to roll my own. Rather then roll out the newer version of Iceweasel, I thought I would try GNU IceCat. I packaged up 3.6.3 for Squeeze 64 bit and if you’re interested you can download the 64 bit package here. I plan to continue to update this package if people are interested. Please let me know if you find it useful.


MCMC CFA talk and update

May 21, 2010

As promised, here is my talk on how to run a Markov Chain Monte Carlo confirmatory factor analysis model in JAGS. Click here to download the talk. The talk is pretty complete. It provides a brief background on Bayesian, MCMC, CFA, and then some JAGS code. It also includes my tested model (using graphviz).

Feel free to leave comments on the talk.

This summer I am in the process of going through and reading Gelman’s Bayesian textbook. Last summer I worked through Bradley Carlin’s book and a few other books. I plan to adapt his code, especially the hierarchical modeling code, from BUGS to JAGS and I may post it here.

Also, it should be noted that all of my materials presented on this blog, including attachments, are released under a Creative Commons license or GNU GPL 3. Feel free to modify and distribute my materials as specified under the terms of these licenses.


Profile Analysis in R

May 7, 2010

I recently wrote a few functions to perform a profile analysis in R. These functions are used to identify the criterion pattern and run a cross-validation (see Davision & Davenport, 2002). I’ve thought about getting serious about this and trying to clean up my code, add some new features (such as MCMC), and submit it to CRAN. Please test the script (& documentation) and if you do profile analysis let me know what you think and if you think I should add some other features. I’d be happy to do it but since I am primarily interested in Bayesian statistics, multilevel modeling, and latent modeling, I don’t have a lot of interest in maintaining and developing a profile analysis R package unless their is interest from the community as it’s not my own research interest.

This script is available here and the manual is available here .

The script contains two functions:



And you should source the script at the start of a R session:


JAGS 2.0.0 for Ubuntu 10.04

April 29, 2010

I built a package of JAGS 2.0.0 for Ubuntu 10.04 64 bit. This was just a quick rebuild from the upstream Debian Sid source. It seems to work fine. It is available here . Please let me know if you have any issues with it. I plan on tracking Ubuntu 10.04 64 bit on my laptop until Squeeze is released and then moving back to Debian. Until then I plan to keep this package up-to-date for Ubuntu.

EDIT: rjags has not yet been updated for JAGS 2.0.0, so if you want to continue to use rjags, you should hang tight with JAGS 1.0.4 for the time being.

2nd EDIT: I already got sick of Ubuntu and am back on Debian testing (and will be until Squeeze becomes stable then I will follow stable). So while I won’t be pulling my JAGS package, I won’t be updating it either. Sorry.

Also, I’ve noticed a lot of people seem to be coming here to figure out how to set up WinBUGS or OpenBUGS on their Mac. If possible, I’d like to encourage you to use JAGS. It really does work great, is cross-platform, and open source.

3rd EDIT (May 7th 2010): JAGS 2.0.0 has now hit Squeeze and this means that rjags on CRAN is presently broken. However, you can grab the rjags tarball from sourceforge here and install it by running the following code.

R CMD INSTALL rjags_2.0.0-2.tar.gz

Restart R and you can now load the rjags library again. Thanks to Dirk Eddelbuettel for the tip that a compatible version of rjags was living on Sourceforge.

4th EDIT (May 21st, 2010): JAGS 2.1.0 and rjags 2.1.0 have been released. rjags 2.1.0 is now on CRAN so you no longer need to install rjags from Sourceforge. I will not be updating the package for Ubuntu, as I am on Debian testing, sorry.


Bayesian Multilevel Talk

April 28, 2010

As promised, I am posting my Bayesian multilevel talk. You can get it here . It briefly introduces Bayesian, MCMC, and Bayesian multilevel modeling. The presentation was created in beamer (.tex file is available upon request) and I used JAGS, rjags, and MCMCglmm to run my models. The presentation includes syntax for running Bayesian models in these programs.

Next week I will post a new presentation on Bayesian CFA. The analysis will be performed in rjags again.

Please feel free to comment and let me know what you think. I am specifically interested in knowing if something is unclear or just plain wrong.

Finally, I again this summer plan to go through another Bayesian textbook (Gelman’s book) and will attempt to publish more code on this website. I am going to focus primarily on regression and multilevel models as I know these techniques a lot better than latent models. If you’re interested in seeing a model written in JAGS syntax for rjags let me know. Also, if interest exists I might put together a how-to with JAGS.

Finally, I will only be publishing code for the JAGS language as it’s the only multi-platform opensource Gibbs sampler and all code you will see written here from now on will only be written if it’s a computational solution to a problem for Windows, Mac, and Linux users (The *BSDs and OpenSolaris too I guess). No Windows only stuff.

One other thing: COMMENTING IS WHAT LETS ME KNOW YOU FIND THIS USEFUL AND THAT I SHOULD KEEP DOING THIS. Unless you leave comments I have no way of knowing that this is useful and that I’m not wasting my time. The purpose of this blog is to be didactic not pedantic. So if you find this useful please let me know.


Image Analysis

April 14, 2010

Although I’ve been absent from this blog for well over a month, I haven’t abandoned it. I have been busy working on a few projects that are using Bayesian methods and have been very busy with school work. The projects that I have been working on are the multilevel ZIP project that I’ve been discussing on this blog for a while and the other one is a confirmatory factor analysis project. I will be giving presentations on both of these approaches on the 27th of April and will post PDFs of these talks. The latter talk, on CFA, will also include code for rjags, a package to call JAGS from R. I’ve been playing around with this particular Gibbs Sampler a little bit and I think it’s a good option for Linux and Mac users. So I will be posting some code on here, similar to my SEM code, but this time it will be JAGS and rjags syntax and therefore can be used on all platforms without the need of wine.

On a related note, I recently gave a talk on Guttman’s image analysis for a seminar on factor analysis. Image analysis seems to be pretty interesting and able to overcome many of the issues associated with factor analysis, including factor score indeterminancy and factorial invariance. However, there are still issues of rotational indeterminancy. Basically image analysis breaks manifest variables into two chunks: Images and partial anti-images. The images are the parts of a variable that are shared with the other manifest variables, while the anti-image is the part that is unique. Further, images are similar to common factors and the anti-image is similar to unique factors. If you are interested in factor analysis, please read my image analysis talk (by clicking here) and let me know what you think. I am not an expert on image analysis but am happy to host a discussion on the topic and will try to answer questions.