Skip to content
Prev 7478 / 15274 Next

Trading system correlation?

On Wed, Feb 9, 2011 at 3:38 PM, Brian G. Peterson <brian at braverock.com> wrote:
<SNIP>
Brian,
   Thanks for the detailed response. It's good info and if I was
building a portfolio of these systems to trade then I'd likely do
something similar.

   None the less, off of StackOverflow I received a nice enough
solution, shown below in case it helps others looking for similar
solutions. (I take no credit other than for asking the question.) ;-)

Cheers,
Mark

x<-matrix(runif(100),10,10)
cor<-cor(x)
l <- length(cor)
l1 <- length(cor[cor<1])

#the actual high and low correlation indexes
corHigh <- order(cor)[(l1-4):l1]
corLow <- order(cor)[1:5]
#(if you just want to view the correlations cor[corLow] or
cor[corHigh] works fine)

#isolate them in the matrix so you can see where they came from easily
corHighView <- cor
corHighView[!1:l %in% corHigh] <- NA
corLowView <- cor
corLowView[!1:l %in% corLow] <- NA

#look at your matrix with your target correlations sticking out like a
sore thumb
options(digits=2)
cor

corLowView

corHighView