JohnsonHsieh / iNEXT

R package for interpolation and extrapolation
https://JohnsonHsieh.github.com/iNEXT
57 stars 25 forks source link

In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. #22

Open mhepner90 opened 7 years ago

mhepner90 commented 7 years ago

@JohnsonHsieh I am a graduate student at USF studying reef fish biodiversity in the FL keys. I have computed richness, shannon, and simpson using the VEGAN package but am having trouble computing the same indices with your iNEXT package. I keep getting a returned error saying my sites have only one species when in there are many.

"iNEXT.Rmd" code

7 stratas by 348 species

str(spec_by_strata) 'data.frame': 348 obs. of 7 variables: $ FDLR: Factor w/ 147 levels " 0"," 0",..: 4 40 47 86 49 35 101 93 87 86 ... ..- attr(, "names")= chr "ABU SAXA" "ACA ASPE" "ACA BAHI" "ACA CHAP" ... $ FMLR: Factor w/ 182 levels " 0"," 0"," 20",..: 31 20 121 160 92 104 12 85 178 44 ... ..- attr(, "names")= chr "ABU SAXA" "ACA ASPE" "ACA BAHI" "ACA CHAP" ... $ FSLR: Factor w/ 141 levels " 0"," 10",..: 92 120 104 93 62 91 18 28 106 93 ... ..- attr(, "names")= chr "ABU SAXA" "ACA ASPE" "ACA BAHI" "ACA CHAP" ... $ HRRF: Factor w/ 158 levels " 0"," 0",..: 139 57 77 64 30 97 11 76 111 64 ... ..- attr(, "names")= chr "ABU SAXA" "ACA ASPE" "ACA BAHI" "ACA CHAP" ... $ INPR: Factor w/ 111 levels " 6"," 0",..: 48 56 28 85 45 53 36 36 36 85 ... ..- attr(, "names")= chr "ABU SAXA" "ACA ASPE" "ACA BAHI" "ACA CHAP" ... $ MCPR: Factor w/ 145 levels " 0"," 28",..: 71 116 64 81 46 70 22 22 96 81 ... ..- attr(, "names")= chr "ABU SAXA" "ACA ASPE" "ACA BAHI" "ACA CHAP" ... $ OFPR: Factor w/ 136 levels " 0"," 2",..: 55 57 78 94 43 74 57 17 107 94 ... ..- attr(*, "names")= chr "ABU SAXA" "ACA ASPE" "ACA BAHI" "ACA CHAP" ... spec_by_strata FDLR FMLR FSLR HRRF INPR MCPR OFPR ABU SAXA 102 6340 9924 43312 1542 6272 3606 ACA ASPE 2 4 20 8 2 22 4 ACA BAHI 2476 31736 13690 12130 580 5306 6256 ACA CHAP 0 6 0 0 0 0 0 ACA CHIR 2610 19988 4940 3368 1308 2452 2728 ACA COER 1666 24444 9380 15520 1792 6252 5796 ACA MARI 14 2 0 0 0 0 4 ACA POLY 12 18 2 12 0 0 0 ACA QUAD 10 92 14 20 0 14 14 ACA SOLA 0 0 0 0 0 0 0 ACA SPIN 0 0 0 0 0 0 0 iNEXT(spec_by_strata, q = 0, datatype = "abundance") Error in FUN(newX[, i], ...) : invalid data structure In addition: Warning messages: 1: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. 2: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. 3: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. 4: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. 5: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. 6: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. 7: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. @JohnsonHsieh why am I getting this error when I have several species per community?

JohnsonHsieh commented 7 years ago

Hi mhepner90

  1. Try to use data.frame (species by site) as the input of iNext().
  2. It seem that some site has only one observed species.
mhepner90 commented 7 years ago

@JohnsonHsieh thank you for responding. I tried as an "as.data.frame" but still received the same error. All of my 7 sites have more then one observed species. Any other thoughts?

mhepner90 commented 7 years ago

Here is my code (https://github.com/mhepner90/RVC/blob/master/iNEXT.Rmd) I'd appreciate if you can take a look and try and fix my error.

JohnsonHsieh commented 7 years ago

Show me a screenshot by using View(spec_by_strata), thx.

mhepner90 commented 7 years ago

I sent you an email euler96@gmail.com with a csv file because I have over 300 species, you would not be able to see entire dataset with View.

LDalby commented 6 years ago

Hi

Seeing similar error here. Were you able to solve this?

Best, Lars

LDalby commented 6 years ago

I'm getting the same warning as @mhepner90 reports.

I'm seeing this error both on the latest CRAN version (2.0.12) and the github version (2.0.14).

Any idea why this happens?

Best Lars

library(iNEXT)                                                

inext_input <- data.frame("site_1" = c(1,18,1,13,0,1,2,0,7,3),
"site_2" = c(0,0,0,0,3,0,0,1,0,3),                            
row.names = paste("sp", 1:10, sep = "_"))                     

iNEXT(inext_input,                                            
q = 0,                                                        
datatype = "abundance",                                       
endpoint = NULL,                                              
se = TRUE,                                                    
conf = 0.95) -> inext_output                                  
#> Warning in EstiBootComm.Ind(Spec): This site has only one species.
#> Estimation is not robust.
#> Warning in BootstrapFun.abun(x = x, FunName, datatype, B): This site has
#> only one species. Estimation is not robust.

#> Warning in BootstrapFun.abun(x = x, FunName, datatype, B): This site has
#> only one species. Estimation is not robust.

# Verify that all sites have more than one species            
inext_input[inext_input > 0]  <- 1                            
colSums(inext_input)                                          
#> site_1 site_2 
#>      8      3
Session info ``` r devtools::session_info() #> Session info ------------------------------------------------------------- #> setting value #> version R version 3.4.2 (2017-09-28) #> system x86_64, linux-gnu #> ui X11 #> language en_US:en #> collate en_US.UTF-8 #> tz Europe/Copenhagen #> date 2017-11-22 #> Packages ----------------------------------------------------------------- #> package * version date source #> backports 1.1.1 2017-09-25 CRAN (R 3.4.2) #> base * 3.4.2 2017-10-28 local #> colorspace 1.3-2 2016-12-14 CRAN (R 3.4.2) #> compiler 3.4.2 2017-10-28 local #> datasets * 3.4.2 2017-10-28 local #> devtools 1.13.4 2017-11-09 CRAN (R 3.4.2) #> digest 0.6.12 2017-01-27 CRAN (R 3.4.2) #> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.2) #> ggplot2 2.2.1.9000 2017-11-22 Github (tidyverse/ggplot2@505e4bf) #> graphics * 3.4.2 2017-10-28 local #> grDevices * 3.4.2 2017-10-28 local #> grid 3.4.2 2017-10-28 local #> gtable 0.2.0 2016-02-26 CRAN (R 3.4.2) #> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.2) #> iNEXT * 2.0.12 2016-11-12 CRAN (R 3.4.2) #> knitr 1.17 2017-08-10 CRAN (R 3.4.2) #> lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.2) #> magrittr 1.5 2014-11-22 CRAN (R 3.4.2) #> memoise 1.1.0 2017-04-21 CRAN (R 3.4.2) #> methods * 3.4.2 2017-10-28 local #> munsell 0.4.3 2016-02-13 CRAN (R 3.4.2) #> plyr 1.8.4 2016-06-08 CRAN (R 3.4.2) #> Rcpp 0.12.13 2017-09-28 CRAN (R 3.4.2) #> reshape2 1.4.2 2016-10-22 CRAN (R 3.4.2) #> rlang 0.1.4 2017-11-05 CRAN (R 3.4.2) #> rmarkdown 1.8 2017-11-17 CRAN (R 3.4.2) #> rprojroot 1.2 2017-01-16 CRAN (R 3.4.2) #> scales 0.5.0.9000 2017-10-09 Github (hadley/scales@d767915) #> stats * 3.4.2 2017-10-28 local #> stringi 1.1.6 2017-11-17 CRAN (R 3.4.2) #> stringr 1.2.0 2017-02-18 CRAN (R 3.4.2) #> tibble 1.3.4 2017-08-22 CRAN (R 3.4.2) #> tools 3.4.2 2017-10-28 local #> utils * 3.4.2 2017-10-28 local #> withr 2.1.0.9000 2017-11-22 Github (jimhester/withr@fe81c00) #> yaml 2.1.14 2016-11-12 CRAN (R 3.4.2) ```
andbeck commented 6 years ago

There seems to be some overlapping issues about warning messages (I've just posted to the newest #31 - sorry. I provided this internal spider example. The warnings seem to be linked to the presence or absence of at least one species with an abundance of 1.

library(iNEXT)

# data
data(spider)

# create 7 vectors with various 1 and 0 entries
spiderG1 <- spider$Girdled # OK
spiderG2 <- spider$Girdled[spider$Girdled>1]  # Incorrect Warning
spiderG3 <- c(spider$Girdled[spider$Girdled>1],1,1)  # OK
spiderG4 <- c(spider$Girdled[spider$Girdled>1],1) # OK
spiderG5 <- c(spider$Girdled[spider$Girdled>1],1,0) # Oddly OK
spiderG6 <- c(spider$Girdled[spider$Girdled>1],0) # Incorrect Warning
spiderG7 <- c(spider$Girdled[spider$Girdled>1],0,0) # Incorrect Warning

# run iNEXT
iNEXT(spiderG1)
iNEXT(spiderG2)
iNEXT(spiderG3)
iNEXT(spiderG4)
iNEXT(spiderG5)
iNEXT(spiderG6)
iNEXT(spiderG7)
BelindaCannell commented 6 years ago

Hi there, I am also getting the same warning. I made sure that I removed the column that had the names of the species, then made a new data set with these as the row names. I also made sure that the structure of my data frame was the same as that for the bird data set. When I run iNEXT on bird I don't get an error. Can you please tell me what is going wrong. Thanks Belinda

d<-read.table (file ="iNEXT_2014-2016.csv", header=TRUE,sep=",") list(d) [[1]] X Y.2014 Y.2015 Y.2016 1 Atherinidae 8 3 12 2 Caringidae 9 102 11 3 Chirocentridae 0 19 0 4 Clupeidae 15 138 218 5 Engraulidae 538 2056 3660 6 Exocoetidae 6 11 7 7 Hemiramphidae 1 4 0 8 Mollusca 1 11 12 9 Mugilidae 0 1 0 10 Scombridae 0 0 1 11 Terapontidae 0 44 0 12 Tetraodontidae 0 1 0

d2<-d[,-1] rownames(d2)<-d[,1] out1 <- iNEXT(d2, q=0, datatype="abundance") Warning messages: 1: In EstiBootComm.Ind(Spec) : This site has only one species. Estimation is not robust. 2: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust. 3: In BootstrapFun.abun(x = x, FunName, datatype, B) : This site has only one species. Estimation is not robust. str(d2) 'data.frame': 12 obs. of 3 variables: $ Y.2014: int 8 9 0 15 538 6 1 1 0 0 ... $ Y.2015: int 3 102 19 138 2056 11 4 11 1 0 ... $ Y.2016: int 12 11 0 218 3660 7 0 12 0 1 ... str(bird) 'data.frame': 41 obs. of 2 variables: $ North.site: int 0 0 41 0 3 1 5 4 4 11 ... $ South.site: int 3 18 31 2 1 2 5 1 6 32 ...

lavik17 commented 6 years ago

just saw it was solved in #31