Hi Coline, 

Actually the test would be: 

any(is.complex(mat_dissim_Eucl)) 

And you may also test: 

isSymmetric(as.matrix(mat_dissim_Eucl)) 

But it'd very surprising this 2nd test returns FALSE. 

So if your matrix is real and symmetric, I don't see why you have complex 
eigenvalues from its decomposition. 

Best, 

Emmanuel 

----- Le 6 Avr 20, à 21:16, Coline Boonman <c.boon...@science.ru.nl> a écrit : 





Dear Emmanual, 



Thank you for your email. I have been trying to understand what is going on and 
if your suggestion is correct. However, if I test for complex numbers in my 
dissimilarity matrix (converted to a matrix: 
is.complex(as.matrix(mat_dissim_Eucl)) ) R gives me the result FALSE. That 
means that there are no complex numbers in the input for the pcoa, right? 



I hope you or someone else has another suggestion on why I get this error. 



Kind regards, 

Coline 




From: Emmanuel Paradis [mailto:emmanuel.para...@ird.fr] 
Sent: Thursday, 2 April 2020 07:43 
To: Coline Boonman <c.boon...@science.ru.nl> 
Cc: r-sig-phylo <r-sig-phylo@r-project.org> 
Subject: Re: [R-sig-phylo] Question on min(D.eig$values) in pcoa function of 
ape in R 





Hi Coline, 





This is strange: you calculate a distance matrix with daisy(), so the 
as.matrix() operation should return a symmetric matrix. Symmetric (real) 
matrices have all their eigenvalues real numbers. Maybe some complex values 
were produced by daisy()? 





Best, 





Emmanuel 





----- Le 30 Mar 20, à 22:58, Coline Boonman < [ mailto:c.boon...@science.ru.nl 
| c.boon...@science.ru.nl ] > a écrit : 


BQ_BEGIN


Dear reader, 



I am working with the pcoa function of ape in R and I got the error message: 
“min(D.eig$values) : invalid 'type' (complex) of argument” . 

My input data is a distance matrix, which pcoa first converts to a matrix in 
the first line within the code of the function. The error occurs when it wants 
to check for negative eigenvalues at the line ‘ min.eig <- min(D.eig$values)’ 

I checked D.eig$values and indeed they are complex numbers (imaginary numbers). 
What I don’t understand is why these are created. I never had any issues with 
the pcoa function before, and now I change my dataset and this happens. The 
distance matrix values range from 0 to 47 and I have species names as rownames 
and column names. In the attachment I include a small piece of the dataset and 
the code I run. I checked when the error occurs, and I don’t see why the extra 
line (2063) gives the error. 



I hope someone can help me. 



Kind regards, 

Coline Boonman 

-- 

PhD student 

Department of Environmental Science 

Faculty of Science 

Radboud University Nijmegen 



P.O. Box 9010, NL-6500 GL Nijmegen 

E: [ mailto:c.boon...@science.ru.nl | c.boon...@science.ru.nl ] 

T: + 31 (0)243653270 / + 31 (0)243653281 (secr.) 



[ http://www.ru.nl/environmentalscience | http://www.ru.nl/environmentalscience 
] 










_______________________________________________ 
R-sig-phylo mailing list - [ mailto:R-sig-phylo@r-project.org | 
R-sig-phylo@r-project.org ] 
[ https://stat.ethz.ch/mailman/listinfo/r-sig-phylo | 
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo ] 
Searchable archive at [ http://www.mail-archive.com/r-sig-phylo@r-project.org/ 
| http://www.mail-archive.com/r-sig-phylo@r-project.org/ ] 




BQ_END



        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to