My Stat Bytes talk, with slides and code

On Thursday of last week I gave a short informal talk to Stat Bytes, the CMU Statistics department's twice a month computing seminar.

Quick tricks for faster R code: Profiling to Parallelism

I will present a grab bag of tricks to speed up your R code. Topics will include: installing an optimized BLAS, how to profile your R code to find which parts are slow, replacing slow code with inline C/C++, and running code in parallel on multiple cores. My running example will be fitting a 2PL IRT model with a hand coded MCMC sampler. The idea is to start with naive, pedagogically clear code and end up with fast, production quality code.

The slides are here. Code is here.

This was an informal talk. If you would like to dig into these topics more, some more references:

Update: 6/25/2013 For the Windows users out there, Felix Reidel has some notes about upgrading your BLAS. It is easier than I thought!

Update: 7/9/2013 Felix pointed out that OpenBLAS is faster than ATLAS. He is right. See my new blog post for details and proof.

5 thoughts on “My Stat Bytes talk, with slides and code

  1. Felix

    Regarding "Installing an optimized BLAS":

    1) you should point out that using OpenBLAS can significantly speed up operations on large matrices. In my experience ATLAS is not the fastest BLAS around.

    2) Changing the BLAS DLL under Windows is trivial: you only have to replace the Rblas.dll with a different one.

  2. Pingback: For faster R use OpenBLAS instead: better than ATLAS, trivial to switch to on Ubuntu | Nathan VanHoudnos

  3. tleitch

    Put a lot of effort into figuring out incompatibility between R 'parallel' and 'foreach' package with openBlas. O saw similar results to those in the posting, but when I ran multi machine 'foreach' with ubuntu the behavior was random, hanging at the end of the 'foreach' most times. Switched to Atlas cured the hanging 'foreach'. If you want to use multi core in R, either use openBlas implicitly or 'parallel' explicitly, but not both.


Leave a Reply