Steve.Pawson@forestresearch.co.nz
2004-Dec-10 04:11 UTC
[R] How to circumvent negative eigenvalues in the capscale function
Dear All I am trying to do a partial canonical analysis of principal coordinates using Bray-Curtis distances. The capscale addin to R appears to be the only way of doing it, however, when I try and calculate a Bray-Curtis distance matrix either using Capscale or Vegedist (capscale I understand uses Vegedist anyway to calculate its distance matrix), R uses up all available memory on the computer, stops and then comes back with errors regarding negative eigenvalues. I must admit to being a very very basic R user so this is starting to go over my head. I tried using the distpcoa program of Legendre and Anderson that can supposedly output a Bray-Curtis distance matrix corrected for the problem of negative eigenvalues (i.e., trying to circumvent the first steps in Capscale) but have had no success as my datamatrix is larger than what their program can handle. Just wondering if anyone can suggest a way of sorting what I am finding to be a tricky little problem. look forward to peoples thoughts. Regards Steve Pawson PhD Student School of Biological Sciences & School of Forestry, University of Canterbury Address: Forest Research Institute P.O. Box 29237 Fendalton Christchurch Ph 03 3642949 Ext 7831 -------------------------------------------------------------------------------------------- This email is confidential and may be legally privileged. If received in error please destroy and immediately notify us.
Jari Oksanen
2004-Dec-10 06:27 UTC
[R] How to circumvent negative eigenvalues in the capscale function
On Fri, 2004-12-10 at 06:11, Steve.Pawson at forestresearch.co.nz wrote:>> I am trying to do a partial canonical analysis of principal coordinates > using Bray-Curtis distances. The capscale addin to R appears to be the only > way of doing it, however, when I try and calculate a Bray-Curtis distance > matrix either using Capscale or Vegedist (capscale I understand uses > Vegedist anyway to calculate its distance matrix), R uses up all available > memory on the computer, stops and then comes back with errors regarding > negative eigenvalues. >The way to avoid negative eigenvalues is to use a ``positive semidefinite'' dissimilarity matrix. This may sound cryptic. In simple words: the underlying functions in capscale assume that your dissimilarities are like (Euclidean) distances, meaning that the shortest route between two points is a straight line, and you cannot find a shorter route by going via a third point. This is possible with Bray-Curtis index, and as its symptom, you get negative eigenvalues (which are ignored in capscale, and only the dimensions with positive eigenvalues are used). Were negative eigenvalues your problem, you could avoid them by using another dissimilarity index with better metric properties. Jaccard dissimilarity is rank-order similar to Bray-Curtis, but it should be positive semidefinite. However, I don't think think that negative eigenvalues and memory problems are coupled. I guess that you simply have memory problems, and negative eigenvalues are unrelated. So you need more memory or an operating system with better memory handling. You may try with some Linux live-cd (such as Quantian) where you can use R in Linux without installing Linux in your hard drive. cheers, jari oksanen -- Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland email jari.oksanen at oulu.fi, homepage http://cc.oulu.fi/~jarioksa/