New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Morisita index error in vegdist #444
Comments
Yes, this can happen. I have known this since implementing the function in 2001, and I thought I had warned about this in the help page, but there seems to be no warning. I'll add a warning. If you have (several) species with only one occurrence, the correction term (λ) with x (x-1) becomes zero and you end up with a division with zero, and that's NaN. It is just written in the formula so it is the destiny, and you cannot use Morisita index for such data. |
A reproducible way of triggering this behaviour is library(vegan)
data(BCI)
m <- as.matrix(BCI)
vegdist(pmax(m-24, 0), "morisita") |
I cannot reproduce the problem with your data: library(vegan)
m <- matrix(c(0,0,1,4,3,3,0,2,1,1,1,6), 3, 4)
m
# [,1] [,2] [,3] [,4]
#[1,] 0 4 0 1
#[2,] 0 3 2 1
#[3,] 1 3 1 6
vegdist(m, "morisita") ## this will be OK:
# 1 2
#2 0.0000000
#3 0.2941176 0.1326531 I know Morisita will fail sometimes (just look at its formula: it must fail sometimes), but it works with your example. |
I am trying to calculate a Morisita index using vegdist, using a species abundance matrix that looks like so:
When I run distm<-vegdist(df, method='morisita') I get the following error:
"Warning message: In vegdist(x, method = "morisita", na.rm = TRUE) : missing values in results "
The output looks like so:
summary(distm) says that all values in the distance matrix generated are NAs:
Checks so far:
Happy to share the real data if anyone is interested - I'm really confused as to what could be causing this error.
The text was updated successfully, but these errors were encountered: