Even though the route might be circuitous, my seemingly random journeys all seem to lead back to finance. My fun with rCharts sankey diagrams (Exploring Networks with Sankey) has led me into an exploration of the PIMCO network. Although PIMCO is best known for its fixed income products, PIMCO has broadened its product offerings beyond bonds. This shift away from bonds goes back much farther than the highly publicized moves in 2009-2010 (Risk.net “Interview: Bill Gross, PIMCO”) to the 2002 launches of the PIMCO CommodityRealReturn Strategy (“Pimco Dreams Up Funds to Overcome The Nightmare of Inflation”) and PIMCO All Asset Fund ( “PIMCO, Arnott team to offer an ‘unusual’ TAA mutual fund”, “Investing Without Blinders” and “PIMCO All Asset Shies From Stocks”).
The PIMCO All Asset funds are managed by Research Affiliates Robert Arnott and invest only in other PIMCO mutual funds rather than individual securities, so in many ways the fund’s success is dependent on the quality and breadth of other PIMCO funds. Since it sounds slightly incestuous, I thought it would be a good subject for my new tools—sankey diagrams and basic network analysis.
Excel to Edgelist with Old-school VBA
Since PIMCO (and nobody else for that matter) doesn’t provide holdings in an igraph readable edgelist, I decided to revive some fond memories and use VBA to convert the spreadsheet into a 3 column edgelist (source, target, value). Even though I am embarrassed by my VBA code, I will show it below.
<br />Sub getedgelist()<br /> Dim clInfo As Range, clWrite As Range, tempcl As Range<br /> Dim offsetamt As Integer<br /> <br /> 'this will be used throughout to indicate columns to offset for desired date<br /> 'watch out for hidden rows<br /> offsetamt = 15<br /> <br /> 'clInfo will be the cell with our reference information<br /> Set clInfo = ThisWorkbook.ActiveSheet.Range("a9")<br /> 'clWrite will be the cell where we write the info that we gather<br /> Set clWrite = ThisWorkbook.ActiveSheet.Range("u9")<br /> <br /> Do Until clInfo = "Total Gross Asset Allocation"<br /> 'looking at formatting is probably the easiest way to determine if group or fund<br /> 'I chose indent to determine if group or fund<br /> 'IndentLevel = 0 for groups and 1 for funds<br /> If clInfo.IndentLevel = 0 Then<br /> 'if we are on a group write in clWrite the group and each fund within the group<br /> 'with group as source and fund as target<br /> 'we will loop until we are at the next group<br /> Set tempcl = clInfo<br /> 'write mutual fund as source, group as target, and weight<br /> clWrite.Value = ThisWorkbook.ActiveSheet.Range("e6").Value<br /> clWrite.Offset(0, 1).Value = clInfo.Value<br /> clWrite.Offset(0, 2).Value = clInfo.Offset(0, offsetamt).Value<br /> Set clWrite = clWrite.Offset(1, 0)<br /> Do Until tempcl.Offset(1, 0).IndentLevel = 0<br /> 'now loop through each fund in group<br /> 'write group as source, held fund as target, and weight<br /> clWrite.Value = clInfo.Value<br /> clWrite.Offset(0, 1).Value = tempcl.Offset(1, 0).Value<br /> clWrite.Offset(0, 2).Value = tempcl.Offset(1, offsetamt).Value<br /> 'next cell down<br /> Set tempcl = tempcl.Offset(1, 0)<br /> Set clWrite = clWrite.Offset(1, 0)<br /> Loop<br /> Set clInfo = clInfo.Offset(1, 0)<br /> Else<br /> <br /> End If<br /> 'if we are on a group write in clWrite the group and each fund within the group<br /> 'with group as source and fund as target<br /> Debug.Print (clInfo)<br /> Set clInfo = clInfo.Offset(1, 0)<br /> Loop<br />End Sub<br />
Now we have everything we need to do the sankey diagram in R.
<br />#sankey of PIMCO All Asset All Authority holdings<br />#data source http://investments.pimco.com/ShareholderCommunications/External%20Documents/PIMCO%20Bond%20Stats.xls<br /><br /><br />require(rCharts)<br /><br />#originally read the data from clipboard of Excel copy<br />#for those interested here is how to do it<br />#read.delim(file = "clipboard")<br /><br />holdings = read.delim("holdings.txt", skip = 3, header = FALSE, stringsAsFactors = FALSE)<br />colnames(holdings) <- c("source","target","value")<br /><br />#get rid of holdings with 0 weight or since copy/paste from Excel -<br />holdings <- holdings[-which(holdings$value == "-"),]<br />holdings$value <- as.numeric(holdings$value)<br /><br />#now we finally have the data in the form we need<br />sankeyPlot <- rCharts$new()<br />sankeyPlot$setLib('.')<br />sankeyPlot$setTemplate(script = "layouts/chart.html")<br /><br />sankeyPlot$set(<br /> data = holdings,<br /> nodeWidth = 15,<br /> nodePadding = 10,<br /> layout = 32,<br /> width = 750,<br /> height = 500,<br /> labelFormat = ".1%"<br />)<br /><br />sankeyPlot<br />
Blogger makes it hard to incorporate d3 directly into this post, so click here or on the screenshot below, to engage and interact with the sankey.
Just for good measure, here is the default plot from igraph.
Of course we could also plot the data a little more traditionally with a ggplot2 bar chart.
Any way we look at it, we can see that PIMCO now has way more than just bonds and the fund All Asset All Authority uses almost everything.