I'm trying to obtain diversity indices/estimators and dissimilarity measures for a community abundance matrix comprised of samples taken from multiple assemblages. Specifically, I'm running Anne Chao's function:
SimilarityMult
(estimating various similarity indices among N communities). Both richness and abundance-based N-community similarity indices are included" --Anne Chao's SpadeR
package.
I use packages:
library(devtools)
install_github('AnneChao/SpadeR')
library(SpadeR)
library(vegan)
ISSUE
My community abundance matrix set-up: 108 species in rows, 144 sites/samples in columns.
I run:
SimilarityMult(bugs,"abundance",q=1,nboot=200,"relative")
which yields:
ERROR CODE "Error in rmultinom(nboot, sum(X2), p[, 2]) : NA in probability vector"
I run:
SimilarityMult(bugs,"abundance",q=2,nboot=200,"relative")
which yields:
ERROR CODE "Error in rmultinom(1, ni[k], p[, k]) : NA in probability vector"
Below I provide the information from which my data matrix can be recreated and used to run problematic code to find sources of error. I share a subset of my data which includes the first 20 rows and first 25 columns.
I run:
dput(bugs[1:20,c(1:25)])
Output:
bugs <- structure(list(V1 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 8L, 0L, 0L, 12L, 0L, 0L, 0L), V2 = c(0L, 0L, 0L,
7L, 0L, 1L, 0L, 5L, 0L, 0L, 0L, 0L, 2L, 235L, 0L, 0L, 453L, 8L,
0L, 0L), V3 = c(0L, 0L, 0L, 13L, 0L, 0L, 0L, 2L, 2L, 0L, 0L,
1L, 0L, 82L, 0L, 0L, 60L, 1L, 8L, 0L), V4 = c(0L, 0L, 0L, 4L,
0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1051L, 0L, 0L, 48L, 58L,
0L, 0L), V5 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 47L, 0L, 0L, 5L, 3L, 0L, 0L), V6 = c(0L, 0L, 0L, 18L, 0L,
3L, 0L, 7L, 5L, 0L, 0L, 3L, 1L, 271L, 0L, 0L, 176L, 21L, 0L,
0L), V7 = c(0L, 1L, 0L, 16L, 0L, 21L, 0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 0L, 0L, 0L, 0L, 0L, 0L, 10L, 0L, 0L, 14L, 26L,
0L, 0L), V20 = c(0L, 0L, 0L, 6L, 0L, 2L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 18L, 0L, 0L, 2L, 12L, 0L, 0L), V21 = c(0L, 0L,
0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 41L, 0L, 0L,
13L, 0L, 0L, 0L), V22 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 101L, 0L, 0L, 15L, 5L, 0L, 0L), V23 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 15L, 0L,
0L, 17L, 0L, 1L, 0L), V24 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 2L, 0L, 0L), V25 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 7L, 0L, 0L, 0L, 0L, 134L, 0L,
0L, 19L, 0L, 0L, 0L)), row.names = c("1", "2", "3", "4",
"5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20"), class = "data.frame")
Produce dataframe
bugs
Input dataframe 'bugs' into SimilarityMult
functions above.
I do not understand why the code fails. What can I do to make the function work properly? Any solution/advice on the matter would be greatly appreciated.
Thank you!