Correlation Chart

trixs

Recycles dryer sheets
Joined
Nov 8, 2005
Messages
165
Not to bug you guys but I am curious if this chart looks alright and makes sense:

Index Fund Correlation

Here is part of the code used to generate the correlation data:

PHP:
// Correlation Calculation
      public function correlation($x, $y) {

          //Correlation = NSXY - (SX)(SY) / Sqrt([NSX2 - (SX)2][NSY2 - (SY)2])
          
          $Ex;
          $Ey;
          $Exy;
          $Exx;
          $Eyy;

          $xy = array();
          $xx = array();
          $yy = array();

          $num = count($x);

          for ($i = 0; $i < count($x); $i++) {
             array_push($xy, $x[$i]*$y[$i]);
             array_push($xx, $x[$i]*$x[$i]);
             array_push($yy, $y[$i]*$y[$i]);
          }
          
          $Ex = array_sum($x);
          $Ey = array_sum($y);
          $Exy = array_sum($xy);
          $Exx = array_sum($xx);
          $Eyy = array_sum($yy);

          if ($Ex != 0) {   // Make sure we are not dividing by 0
             $corr = (($num * $Exy) - ($Ex * $Ey)) / sqrt( (($num * $Exx) - pow($Ex,2)) * (($num * $Eyy) - pow($Ey,2)) );
          }
          $corr = round($corr, 4);
          return $corr;
      }
 
hi trixs
Nice website. The correlation stuff makes sense - nothing that looks obviously wrong. I was playing with your backtester and I have a couple of suggestions.
1. would it be possible to add a box with the running total at the bottom of the backtester page ie as I enter % for each asset class the total increases and will give an error if it does not add up to 100%
2. Can you also add some notes for the Yaxis in the drawdown chart?

Thanks
-h
 
hi trixs
Nice website. The correlation stuff makes sense - nothing that looks obviously wrong. I was playing with your backtester and I have a couple of suggestions.
1. would it be possible to add a box with the running total at the bottom of the backtester page ie as I enter % for each asset class the total increases and will give an error if it does not add up to 100%
2. Can you also add some notes for the Yaxis in the drawdown chart?

Thanks
-h

Thanks for looking! Opinions from you guys are the best because you have an idea what is actually be displayed. I ask a friend and they have no idea what they are looking at.

1. Yes I intend add a total percentage box. However it requires Java and I have yet to learn Java .:rolleyes:

2. Hmm - I overlooked that - Good idea!
 
It's a great utility you're working on and something that's of interest to a lot of us, thanks.

Edit (I didn't notice the matrix at first): Your correlation matrix looks right, but IMHO your backtest doesn't seem to be working properly. If that's not finished, no need to read further.

I developed a spreadsheet for my own use to gauge correlation based on the methodology in (what I consider) a great article on IndexUniverse, The Benefits of Low Correlation by Craig Israelsen, you may have seen it. My calcs tie out exactly with theirs so I'm confident I understand the calcs, and I have modified my AA to take advantage of more low correlation assets. If you're interested: The Benefits of Low Correlation -

They use the 37 year period from 1970-2006 (almost the same as yours). The AA of interest in the article is based on seven assets, but since your model only allows whole integers, I plugged in the five-asset* example from the article. Returns and SD are about the same as yours, but they show a correlation of .211 whereas your backtest shows 0.91? They show the benchmarks for their assets and your model seems to have equivalents which I used - even if they're not exactly the same, the discrepancy should not be so dramatic.

I also plugged in a 50/50 LCB/Commodities, and got a much higher correlation than I believe to be correct (based on the same article). Edit: It should match your matrix and it does not.

So I'm puzzled. But yours would be superior by virtue of available asset classes and weighting if you can get it all working. FWIW...

*20% each of Large US Equity (S&P), Small US Equity (SCB), Non US Equity (EAFE), US Int Term Bonds (Tot Bond) & Cash (MM)
 
Last edited:
Taking a look - Look's like I have some bug finding.

Thank You

EDIT:

I went ahead and read that article and found where the discrepancy is coming into play. (btw, good article!) In the article they are using an aggregate correlation. First of all they start off with small cap blend and LCB. These two correlate together at about .75, which checks. Next they add other asset classes and get the aggregate correlation.

The correlation model that I used on the site is checking the total portfolio correlation vs the US Market - In this case the S&P 500. I will change this to clearly state what data source. Also, 50/50 LCB/Commodities correlates with the US market( S&P 500) at .60 . When comparing the two distinct data sequences, LCB and Commodities, they correlate together at -0.17.

My plan of action - Allow people to use decimal points!
 
Last edited:
>:D :cool: :bat: :uglystupid: :eek: :2funny: :crazy: :cool:

Like these?

Seriously, what you're doing is great and we look forward to seeing the finished product.
 
Back
Top Bottom