vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
436 stars 95 forks source link

"betadisper" _Negative values_ add=lingoes #624

Closed QianxinJiang closed 3 months ago

QianxinJiang commented 3 months ago

Hello guys! I'm trying to use "betadisper" to do works, but it kept showing that my "dissimilarities 'd'" had negative values. So I set "add" to "lingoes" or "cailliez", but it still reported an error saying it had negative values. How could I do? I have already set up "add". Sad...... Thanks in advance!

111

jarioksa commented 3 months ago

I guess this means that your dissimilarities have negative values. We assume that smallest possible dissimilarity is zero (points are identical) and there are no negative dissimilarities (points are more similar than identical). Why do you have those negative dissimilarities? Which of your dissimilarities are negative? After you sort out this and get rid of negative dissimilarities you can proceed.

The add argument has nothing to do with negative input dissimilarities. It only handles non-metric dissimilarities in weird ways.

QianxinJiang commented 3 months ago

I guess this means that your dissimilarities have negative values. We assume that smallest possible dissimilarity is zero (points are identical) and there are no negative dissimilarities (points are more similar than identical). Why do you have those negative dissimilarities? Which of your dissimilarities are negative? After you sort out this and get rid of negative dissimilarities you can proceed.

The add argument has nothing to do with negative input dissimilarities. It only handles non-metric dissimilarities in weird ways.

Thank you for your answer! These dissimilarities contained negative values, and it was accurate. I checked the Function Arguments and Usage, it said that "add: Add a constant to the non-diagonal dissimilarities such that all eigenvalues are non-negative". I dont know what to do....

gavinsimpson commented 3 months ago

Dissimilarities cannot be negative; they measure how different two things are and you can't be less than 0 different from something.

add refers to eigenvalues and has nothing to do with your dissimilarities. It is a correction for negative eigenvalues in the PCoA of the matrix of dissimilarities, which occur when the underlying dissimilarity measure is not metric.

You can't run an analysis of dissimilarities that contains negative values. These are not accurate and you will need to fix how those were computed before proceeding.

QianxinJiang commented 3 months ago

Dissimilarities cannot be negative; they measure how different two things are and you can't be less than 0 different from something.

add refers to eigenvalues and has nothing to do with your dissimilarities. It is a correction for negative eigenvalues in the PCoA of the matrix of dissimilarities, which occur when the underlying dissimilarity measure is not metric.

You can't run an analysis of dissimilarities that contains negative values. These are not accurate and you will need to fix how those were computed before proceeding.

Thank you for your answer! You are right. The distance matrix I calculated is the standardized effect size value compared to the null model, so there will be negative numbers. Is it not acceptable to use this betadisper analysis?

jarioksa commented 3 months ago

It sounds that you do not have distances/dissimilarities at all, but you have raw data. In raw or rectangular data you have observations (rows) and variables (columns) whereas in distances / dissimilarities you have symmetric square data where both dimensions correspond to observations. Dissimilarities are between observations. At the moment I do not understand what you try achieve with betadisper and therefore I do not give any further advice (although technically it would be easy).

QianxinJiang commented 3 months ago

It sounds that you do not have distances/dissimilarities at all, but you have raw data. In raw or rectangular data you have observations (rows) and variables (columns) whereas in distances / dissimilarities you have symmetric square data where both dimensions correspond to observations. Dissimilarities are between observations. At the moment I do not understand what you try achieve with betadisper and therefore I do not give any further advice (although technically it would be easy).

Thank you very much for your help! The "beta_nri_dist" is a distance matrix. image image

gavinsimpson commented 3 months ago

I don't mean to keep harping on about this, but that categorically is not a distance or dissimilarity matrix. By definition, you can't have something that is a negative amount different from something else. Think about it; what would that even mean?

You might have an object of class "dist", but as far as the math goes that simply can't be used with anything in vegan that expects a dissimilarity matrix that actually follows the rules of distance and dissimilarity measures.

I'm going to close this because the discussion is futile and going round in circles, and beside there is nothing wrong with vegan. The error here is all yours. You can ask again as a question in the Discussions (see the discussion tab in the menu towards the top), but if you do, please start that discussion by accepting that what you have isn't a distance or a dissimilarity matrix and actually spell out what you are trying to do.

QianxinJiang commented 3 months ago

I don't mean to keep harping on about this, but that categorically is not a distance or dissimilarity matrix. By definition, you can't have something that is a negative amount different from something else. Think about it; what would that even mean?

You might have an object of class "dist", but as far as the math goes that simply can't be used with anything in vegan that expects a dissimilarity matrix that actually follows the rules of distance and dissimilarity measures.

I'm going to close this because the discussion is futile and going round in circles, and beside there is nothing wrong with vegan. The error here is all yours. You can ask again as a question in the Discussions (see the discussion tab in the menu towards the top), but if you do, please start that discussion by accepting that what you have isn't a distance or a dissimilarity matrix and actually spell out what you are trying to do.

Thanks very much again. I will check my data.