Warning: DOMDocument::loadXML(): Opening and ending tag mismatch: hr line 5 and body in Entity, line: 6 in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 149

Warning: DOMDocument::loadXML(): Opening and ending tag mismatch: body line 3 and html in Entity, line: 7 in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 149

Warning: DOMDocument::loadXML(): Premature end of data in tag html line 1 in Entity, line: 8 in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 149

Warning: Invalid argument supplied for foreach() in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 160

Warning: DOMDocument::loadXML(): Opening and ending tag mismatch: hr line 5 and body in Entity, line: 6 in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 149

Warning: DOMDocument::loadXML(): Opening and ending tag mismatch: body line 3 and html in Entity, line: 7 in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 149

Warning: DOMDocument::loadXML(): Premature end of data in tag html line 1 in Entity, line: 8 in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 149

Warning: Invalid argument supplied for foreach() in /home/clients/d6bcc13f01d956648e26ee7f6a76facd/blog/wp-content/plugins/wordpress-amazon-associate/APaPi/AmazonProduct/Result.php on line 160
Quantitative Finance and Computer Science: quick comparison between R and MATLAB – Jérémie Smaga's personal blog

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.

MATLAB vs R

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!


Comments

2 responses to “Quantitative Finance and Computer Science: quick comparison between R and MATLAB”

  1. Florent Avatar

    I would add that the standard edition of Matlab is limited to 8 workers, therefore you can parallelize your code on maximum 8 cores. If you need more cores, you need to buy another license… not cool!

    I suggest to look at scripting languages such as Python which works very well. In addition it has this “plus” (such as list comprehension) that functional languages have. I’m sure you’ll find libraries for financial applications.

  2. Thanks for the heads-up on the cores issue, I didn’t know about that. Besides, I think that R handles parallelization quite well. Besides, R is a functional language in its essence.
    I was thinking about discussing Python with the rest of the “standard” programming languages, but I don’t know much about it, especially in terms of mathematical libraries.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.