Articles by Lee

Integrating PHP and R

August 18, 2010 | Lee

“How can I integrate PHP and R?” I know I’m not the only one who’s asked this question. After all, with great content management systems like Drupal, it would very cool to be able to drop an R module into some PHP code and instantly have a web ... [Read more...]


August 13, 2010 | Lee

After a month of on-again, off-again coding, I’ve finally completed a web site geared towards calculating the Value at Risk of the average investor’s portfolio. The site is The big idea was to combine the statistical and visualization tools of R (especially ggplot2) with the web ... [Read more...]

Save R plot as a BLOB

July 30, 2010 | Lee

I recently posed a question on stackoverflow on whether anyone knew an efficient way to save an R plot to a MySQL database as a BLOB. My plan was to use my personal desktop to perform R routines and save them to a web server, where they could then be ... [Read more...]

The only thing smiling today is Volatility

May 21, 2010 | Lee

With the stock market freaking out and all, I figured I should take a look at how volatility was being priced in the option market. The CBOE generously provides snapshots of market data for anyone interested to download. By using this data, we can calculate the markets ‘implied volatility’, or ...
[Read more...]

Basket Option Pricing: Step by Step

May 8, 2010 | Lee

I find options fascinating because they deal with the abstract ideas of volatility and correlation, both of which are unobservable and can often seem like wild animal spirits (take the current stock market as an example). Understanding these subtle concepts is never easy, but it is essential in pricing some ... [Read more...]

5 Minute Analysis in R: Case-Shiller Indices

April 29, 2010 | Lee

The Case-Shiller Home Price Indices measure residential home values for 20 cities in the US, with some indices going all the way back to the 80s. With housing prices all the rage these days, we should perform a quick-and-dirty analysis using R to see what we can glean from this rich ...
[Read more...]

Fun with the Vasicek Interest Rate Model

April 22, 2010 | Lee

A common model used in the financial industry for modelling the short rate (think overnight rate, but actually an infinitesimally short amount of time) is the Vasicek model. Although it is unlikely to perfectly fit the yield curve, it has some nice properties that make it a good model to ... [Read more...]

R Command Line

April 16, 2010 | Lee

I am an R user! And I see a whole army of R users, here in defiance of tyranny. You’ve come to use R as free men… and free men you are. What will you do with that freedom? Will you use R? Use R and you may use ...
[Read more...]

Gravity Game in R

April 8, 2010 | Lee

So why should R only be used for ’serious’ stuff? No longer! I’ve written the following code in R which executes a little gravitational physics game. The goal of the game is simple. You supply a velocity and direction to a spaceship with the goal of getting the ship ... [Read more...]

CLT Standard Normal Generator

April 2, 2010 | Lee

I’ve found this standard normal random number generator in a number of places, one of which being from one of Paul Wilmott’s books. The idea is that we can use the Central Limit Theorem (CLT) to easily generate values distributed according to a standard normal distribution by using ... [Read more...]

Code Highlights in WordPress

March 26, 2010 | Lee

I’ve come across a very useful plugin for WordPress which highlights code in posts using GeSHi called WP-Syntax. This plugin is easy to use and adds highlights simply by putting the appropriate tags around code blocks. For instance, we can make the following R code much more readable by ... [Read more...]

Robert Brown and Pollen Particles

March 15, 2010 | Lee

In 1827, the botanist Robert Brown was studying pollen particles as they floated in water. When viewed through a microscope, he observed that the particles seemed to move around as if the were alive. Although he couldn’t have known at the time, the seemingly random motion was caused by the ... [Read more...]

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)