Visualizing relationships between dynamic variables, part ii

Mathematica’s Correlation[] tool is handy. I created a wrapper that adds labels and makes it a bit more convenient with the sort of data I use.

msCorrelationMatrix[allChNF3sA, "noisy" -> False]

I often like to consider correlation together with r^2, p-value and criticality tests. The following function runs these things simultaneously for convenience.

msCorrelationMatrix[allChNF3sA, "noisy" -> False]

These functions can also weigh recent events more highly than events in the distant past, which is typically how I use them, though this is not demonstrated above.

When sharing results with others, I find Weighted Adjacency Graphs to be useful, and I will often create tools that allow the user to scroll through time, watching given securities change what other instruments they most resemble. It can be particularly interesting to see ostensibly market-neutral hedge funds start to track the equity markets as their managers take on more beta. This often happens as assets under management increase and/or the markets have been performing well.

Here are three “snapshots” from such a tool for the securities above. You can see that at first, equity hedge funds are a sort of island that don’t track the performance of anything else in the graph. Then in 2005 we enter a regime in which equity hedge funds track the S&P, which in turn resembles other equity series, but credit and commodities follow their own path. The graph continues to evolve (I show only a few states below), but by the end we are in the current world of nearly all risky assets moving together, and nearly everything cross-correlating.

timePasses = Table[Map[msChangeChar[#, "data" -> EventSeries[Take[#["Path"], UpTo[i]]]] &, allChNF3sA], {i, 100, Length[allChNF3sA[[1]]["Path"]], 10}];
wags = Map[msWeightedAdjacencyGraph[#, .3, "time weights" -> Automatic, PlotLabel -> #[[1]]["LastDate"], ImageSize -> Large] &, timePasses];
Manipulate[wags[[i]], {i, 1, Length[wags], 1}]

Dec 2004

Jan 2008

May 2008

July 2012

It stays like that to the current day.

Tomorrow, principal component analysis.

Leave a Reply