Skip to content

manipulation of list of matrices

1 message · murali.menon at uk.abnamro.com

#
Folks,

I have a list of correlation matrices of equities, say, and I need to 
manipulate each matrix: I weight each equity by its median absolute 
correlation against all the other equities, such that the equity with the 
least such correlation gets the highest weight. Something like min(over 
all average correlations) / average correlation of equity

So I do the following:
= 1), ncol = 45); diag(b) <- 1; b})

I write the following function:

constructCorrelationWeights <- function(rollCorr, FUN = median)
{
    corWt <- sapply(rollCorr,
                    function(corMat)
                    {
                        wt <- apply(corMat, 1, function(x) FUN(abs(x)))
                        min(wt) / wt
                    })
    t(corWt)
}
[1] 33.42 18.03 79.55

Is there a more efficient and cleverer way to accomplish this? 

Many thanks,

Murali


---------------------------------------------------------------------------
This message (including any attachments) is confidential...{{dropped:3}}