Skip to content
Prev 87498 / 398500 Next

Maximally independent variables

Gabor Grothendieck <ggrothendieck <at> gmail.com> writes:
Have you considered finding the combination with maximum generalized variance of
three scaled variables (i.e. the maximum determinant of the correlation matrix
of three variables)?

You can vectorize this calculation as follows:

z <- combinations(ncol(DF), 3)

cormat <- cor(DF)

det3 <- function(ra,rb,rc) 1 - ra*ra - rb*rb - rc*rc + 2*ra*rb*rc

res <- det3( cormat[z[,1:2]],cormat[z[,c(1,3)]],cormat[z[,c(2,3)]] )

z[which.max(res),]
[rest deleted]