Hello all,
I need to calculate the 30-day historical (realized) correlation between 45 different stocks i and j, based on the log Returns of the stocks which are in a 1400x45 matrix, so 1400 rows with the data for different dates, t=0...1400 and 45 columns, namely the data for every stock.
As far as I know, Matlab doesn't provide a function to calculate the historical correlation in such a way, based on x day stock data and instead of between 2 stocks, between x stocks.
Does anyone have an idea how to do this?? I am trying to program it manually but to do so I need so many loops that it becomes extremely cumbersome to do this relevatively 'standard' calculation.
http://en.wikipedia.org/wiki/Correlation_and_dependence
---> sample correlation
Help would be highly appreciated because I have been trying all day!!! :-)
Of course this is just about the correlation between different variables, not specificaly on stocks....