Quantitative Finance and Computer Science: quick comparison between R and MATLAB

Hi everybody,

It’s a few weeks without a post and I apologize for that; I am at the moment looking for a job in Geneva, and it’s a bit time consuming as you would imagine.

Anyway, I kept working a bit on different projects and I had the idea to create this post. What encouraged me was several e-mails I received from some former classmates and some questions I recently had to ask. I noticed that, most of us, “quants”, “analysts” or whatever you call your job, are usually wondering what technology to use for in specific situations.

Most of the time, we end up using programming languages we know best. For example, students used to MATLAB will use it instead of R, programmers used to .Net (C#, Visual Basic) will use it instead of the JVM (Java). If you have next to you a whole desk of hugely experimented people, then you might have good hints to guide you in your technology decisions, but here are a few remarks I gathered during my work.


First of all, R is free and open-source as opposed to MATLAB which has an initial fee, plus additional cost for each additional package.

R being open-source, you can browse the Comprehensive R Archive Network (CRAN) to fit the packages you like and start using them. However, you will sometimes find that the documentation is not very clear and hence you might have to ask several questions on the R mailing lists which are not very user-friendly themselves.

Using MATLAB however, you will get packages about different subject (such as Fixed Income, Derivatives, Data Handling and so on) which are quite complete and have a pretty good documentation. I’d say that in term of support, it’s money well spent.

If you wish to integrate this technology within one of your software, I’ve heard (but not tried) that integration is pretty easy. This might allow you to spare some time you’d have spent on handling data marshaling or library implementation in the native language.

As far as R is concerned you will find some very useful packages such as XTS for time series handling. You will also be able to find handy financial packages to perform computations on bond pricing. However, you might have some problems finding the package that suits your need. There is a trade-off between the number of packages available and their quality. However, once you’ve found what you need, you’ll be pretty happy. In terms of integration, I have to tackle the problem myself, and I’d say that Dirk Eddelbuettel’s blog and libraries will help you a lot. If you wish to use R withing Excel, you can use RExcel from Statcon which is pretty easy to work. The following book might help you handle:

R Through Excel: A Spreadsheet Interface for Statistics, Data Analysis, and Graphics (Use R)

For those of you who wish to dig deep into R foundations, the following book is excellent:

Software for Data Analysis: Programming with R (Statistics and Computing)

In terms of performance, I’d say that MATLAB seems to be quicker to find optimization results. Again, this might be due to the fact that I did not find the right R package, but who cares? After my different researches, and especially for the game-theoretic approach on ice hockey penatlies, I had to use MATLAB to get the program to converge before loosing patience.

That’s all from now, but I’ll soon be back to compare the JVM and the .Net framework for finance computations and MATLAB or R integrations.

Until then,

Have fun!