Category Archives: Packages

Some belated spring cleaning

A very busy spring has transitioned into a very busy summer, so let me recap a few topics that probably deserve more time than I’ll give them here. Here are the things I’m overdue on, in no particular order:

Publications

In the March edition of the Journal of Risk, Kris Boudt, Brian Peterson and I published a paper titled Asset allocation with conditional value-at-risk budgets. You can also see a pre-publication version on SSRN. It was nice to see this finally hit paper – many thanks to my co-authors for all their work on an interesting topic.

Equal CVaR Concentration

Panel 3 of Figure 4 shows the weights through time and contribution of CVaR for a minimum CVaR concentration portfolio.

Dirk Eddelbuettel’s book is finally out. Congrats to him – that’s a nice accomplishment! I tried to steal the pre-print at the R/Finance conference, but Dirk made me buy my own copy.

R/Finance 2013

R/Finance 2013 went very well. This event has already been covered here and here – even with an article in the R Journal – but I thought I’d briefly mention a few highlights.

I thought the keynote speakers were fantastic. Every time I see Atillio Meucci speak, I learn something new about a topic I thought I already knew pretty well. This time, Atillio pulled out several animimated visualizations that were very thoughtfully designed – each presented a huge amount of information in a linked way that showed relationships between measures and how they changed dynamically through time. Each of the animations served to underscore the (sometimes simple) intuition behind the complex math. “A quant presentation without equations,” he said. Exceptionally well done – developing the intuition behind these concepts is a significant challenge, even in a room full of quants. No slides, but more on that later.

Revolution’s blog did more justice to Ryan Sheftel’s talk than I’m going to do here. Ryan did an excellent job describing the implementation issues within a large organization, providing a strong dose of reality that I think was appreciated by the audience of practitioners.

Sanjiv Das hit one out of the park as well. Flip through his slides when you have a chance – it was a nice demonstration of how he’s used R in very different projects related to finance. He’s a polymath. I particularly enjoyed his talk on network analysis usig SEC and FDIC filings to identify banks that pose systematic risk – a talk that echoed one given by Michael Gordy, a senior economist in the FRB, in 2012.

I have to plump for the hometown, as well. Ruey Tsay always has something interesting up his sleeve, and this presentation was no different. He warned that this is work in progress, but with Y. Hu he’s developing Principal Volatility Components as a way to identify common volatility components among financial assets. That struck me as work that is well worth tracking.

That was more than I had intended to write on the topic, but a few other presentations stood out to me as well: David Matteson’s talk on change points was accompanied by an excellent paper; Samantha Azzarello’s presentation on a Baysian interpretation of the Taylor Rule was as well; Thomas Harte gave another from-the-trenches viewpoint; David Ardia; Ronald Hochreiter; Alexios Ghalanos, and many others – there were a number of excellent sessions. We were also glad to have several returning speakers – Doug Martin, Kris Boudt, Bernhard Pfaff, Jiahan Li, Bryan Lewis. Lightning talks were also well received, particularly Winston Chang’s demonstration of Shiny. Jan Humme and Brian Peterson did a very nice overview of quantstrat in the pre-conference tutorials. All of the slides for the 2013 conference are here. Great stuff – take a look. Then pencil in the 2014 conference in May of next year…

Other R Conferences

Continuing on the topic of finance-related R conferences, congratulations go to Markus Gesman and Cass Business Scool for organizing the inagural R in Insurance conference this year. If you missed it, as I did, check out the presentations here and plan your travel accordingly for next year.

On the other side of the ledger, this was the last year that Diethelm Wuertz’s R-Metrics conference is to be held in Meielesalp. I didn’t make this one, but I’ve since heard that next year’s will be held in Paris.

Google Summer of Code 2013

GSOC 2013 has not only started, but is well underway. Of the nineteen R projects going on, six are finance-related. In no particular order:

All this activity is resulting in a tremendous amount of code covering a variety of topics and projects. Thanks to all who are participating – both mentors and students – and to Google for supporting open source! I’ll try to provide more detailed project wrap-ups at the end of the summer.

Packages

I’ve made some changes to blotter recently for handling account-level transactions, such as additions and withdrawals (rev. 1485). That should improve the package’s functionality for cash reconciliation. The functionality is pretty rudimentary, but it appears to work. Let me know if you see opportunities for improvement. Blotter is pretty close to CRAN-ready at this point, but requires a final push that is incongruous with good weather.

A very belated thanks to Brian Peterson for pushing out version 1.1 of PerformanceAnalytics to CRAN early this year. I’ve been intending to go over some of the significant changes in that version for months now, but we might have another version out before I get the posting done. Never mind.

Writing from R to Excel with xlsx

Paul Teetor, who is doing yeoman’s duty as one of the organizers of the Chicago R User Group (CRUG), asked recently if I would do a short presentation about a “favorite package”.  I picked xlsx, one of the many packages that provides a bridge between spreadsheets and R.  Here are the slides from my presentation last night; the script is below.

I’ll be honest with you – I use more than one package for reading and writing spreadsheets. But this was a good opportunity for me to dig into some unique features of xlsx and I think the results are worth recommending.

A key feature for me is that xlsx uses the Apache POI API, so Excel isn’t needed.  Apache POI is a mature, separately developed API between Java and Excel 2007.  That project is focused on creating and maintaining Java APIs for manipulating file formats based on the Office Open XML standards (OOXML) and Microsoft’s OLE 2 Compound Document format (OLE2).  As xlsx uses the rJava package to link Java and R, the heavy lifting of parsing XML schemas is being done in Java rather than in R.
Continue reading

xts and GSOC 2012

Josh Ulrich and Jeff Ryan mentored a Google Summer of Code (GSOC) project this summer focused on experimental functionality for xts in collaboration with R. Michael Weylandt, a student in operations research and financial engineering from Princeton. You might recognize Michael from his presentation at R/Finance this year, where he gave a talk entitled “A Short Introduction to Real-Time Portfolio/Market Monitoring with R“.

There were three main objectives of this GSOC project. One was to extend the plotting functionality of xts – to replace the existing plot.xts function with something much more generally useful and to add a barchart.xts primitive that handles stacked bars for time series with negative values. The proof of concept for both of these graphics come from chart functions in PerformanceAnalytics, but a variety of other improvements were also discussed.

Another objective was to experiment with supporting multiple data types within the same object for time series. The concept here is something like a data.frame, which allows class-specific list elements, aligned on an index. Michael wrote a prototype and definitely moved the ball forward here. Fuller functionality will require more test cases to be written to validate the approach and flush out bugs, as well as to add a number of utility functions such as rbind, cbind, etc.

The third objective was to provide ‘bridge’ functionality to convert xts objects to methods that assume a regular time series, such as AR/ARIMA, Holt Winters, or VAR methods, using something like the the zooreg subclass and some translations. Michael provides a number of these for arima, acf, pacf, HoltWinters, and others. These are convenience wrappers for xts users that manage the xts data into the underlying functions, then as appropriate with the results (such as residuals in the case of arima) are coerced back to xts objects.

The result is contained in a supplementary package called xtsExtra, which Michael constructed as a side-pocket for newly developed functionality, any or all of which may end up in the xts package at some point. Beyond Jeff and Josh, Michael opened up to the broader r-sig-finance community to get feedback on xtsExtra, which resulted in several helpful conversations with Jonathan Cornelison, Eric Zivot, Rob Hyndman, Stuart Greenlee, Kenton Russell, Brian Peterson and me.

I want to step back to the first objective for a moment to talk for a moment about plot.xts. klr at TimelyPortfolio immediately took to the code and exercised it well – here is a particularly good chart. Here’s another. And another. Oh, and this one! These were great examples, and I think they are suggestive of how the function could be extended even further, perhaps simplifying the interface and extending the panel functionality. That might require some significant re-work, but I think the results will be well worth it. I think Jeff Ryan might have some tricks up his sleeve as well…

We’ll see where some of this speculation goes, but I want to thank Michael again for his commendable efforts this summer! His has been a considerable effort to extend and improve xts in some very useful ways, and I’m looking forward to his continued involvement in this and perhaps other endevors.