> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Takatsugu Kobayashi > > I am struggling to come up with an efficient vectorized way to convert > 20Kx20K covariance matrix to a Euclidian distance matrix as a surrogate for > dissimilarity matrix. Hopefully I can apply multidimensional scaling for > mapping these 20K points (commercial products). > > I understand that Distance(ij) = sigma(i) + sigma(j) - 2cov(ij).
I suspect there's a typo or two in here. sigma(i)^2 + sigma(j)^2 - 2cov(ij) would be the variance of a difference x[i ]- x[j]. That's not in the same units as the difference itself, so one might well want the standard deviation of the difference, that is, sqrt(sigma(i)^2 + sigma(j)^2 - 2cov(ij)). I don't envy your attempt to work with 20k*20k matrices, though. That's about 3Gbytes per object, and a lot of distances for MDS to optimise. If it's just about visual display, perhaps prcomp on the original data would provide (visually) similar results without the overhead of a large covariance matrix? S Ellison ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}} ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.