Monday, February 22, 2010

Time Series Calendar Heat Maps Using R

I came across an interesting blog that showcased Charting time series as calendar heat maps in R . It is based upon a great algorithm created by Paul Bleicher,CMO of Humedica. I'll let you link to the other blog to see more details on the background and original source code.

I made a very small modification to allow %daily changes, rather than price values.

calendarHeat($Date[1:length($Date)-1], stock.dailychange, varname="SPY daily % changes(CL-CL)")

Fig 1. Calendar Heat Map for SPY time series 2005-Present

What's interesting is you can see how unusual events tend to Cluster (heteroscedasticity) , and a preponderance of low change days (as would be expected in close to Gaussian distributions). Using the regions of clustering might help warn of impeding catastrophic regimes (as seen in late 08), similar to using VIX as a proxy. In addition, the 10,000 foot bird's eye view, might allow you to spot pockets of order for further evaluation.


  1. The things I really like about R is the ease of getting, wrangling, modeling and charting financial time series data ;-)

  2. Definitely,

    And there are plenty of great packages available for trading, such as QuantMod.

    In addition to time series plotting, there are a wealth of fantastic statistics tools as well.

  3. Yes, Quantmod + IBrokers = getting, wrangling, modeling, charting and trading ;-)