--- title: "Plant diversity accurately predicts insect diversity in two tropical landscapes" author: "Kai Zhang" date: "Friday, February 5, 2015" output: html_document --- ## __step__ 1. alpha diverdity level: using the plant model to predict insect OTU (Operational Taxonomic Unit) richness 2. beta diversity level: Procrustes test between plant and insect communities ```{r, echo=FALSE, message=FALSE} rm(list=ls()) options(digits=2) library(rmarkdown) library(vegan) library(BAT) library(plotrix) ``` ### Input the data #### _Yinggeling, Hainan_ ```{r input Yinggeling data} # # read the tree data Tree <- read.csv("YGL_treedensity.csv", row.names=1, header=T) # 371 species # str(Tree) # # get subset of data to minimize pseudo-replication # 2009 plots (10): they distributed in three clusters, randomly choose one plot from 11 12 (cluster I) and from 7 9 10 (cluster II), and drop 1 2 3 4 6 (cluster III) which is close to 15 survied in 2011; # 2011 plots (19): include all, including 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 # sample(c(11,12), size=1, replace=F) # 11 # sample(c(7,9,10), size=1, replace=F) # 10 row.names(Tree) Tree <- Tree[c(2,3,5:8,10:19,21:25), ] # # # read the metabarcoding arthropod data # # edit the YGL_merged_otu97_table_withtax_arthropoda_NonSingleRead_delete.txt, which comes from the bioinformatic pipeline: delete # constructed from biom file, replace # OTU ID as row.names, replace ConsensusLineage as taxonomy # MBCar <- read.table("YGL_merged_otu97_table_withtax_arthropoda_NonSingleRead_delete.txt", header=TRUE, sep="\t", row.names=1, na.strings="NA", dec=".", strip.white=TRUE) # write.csv(MBCar, 'MBCar_YGL.csv') # # edit the MBCar_YGL.csv file, and pay attention to the blank!!! # # split taxonomy column to refer to different taxonomic levels MBCar <- read.csv('MBCar_YGL.csv', row.names=1, header=T) # 2519 OTUs # str(MBCar) # colnames(MBCar) # get subset of the data # class, 38 OTUs (1.5%) not identified summary(MBCar$Class) # 1. Arachnida 52 MBCsp <- MBCar[MBCar$Class=="Arachnida",] # sp = spider # Arachnida order, small sample size summary(MBCsp$Order) # largest order Araneae 15 # 2. Insecta 2285 MBCin <- MBCar[MBCar$Class=="Insecta",] # head(MBCin) # Insecta order, 211 OTUs (9.2%) not identified summary(MBCin$Order) # 1.1 Coleoptera 271 OTUs MBCcole <- MBCin[MBCin$Order=='Coleoptera',] # 1.2 Diptera 993 MBCdi <- MBCin[MBCin$Order=='Diptera',] # 1.3 Hemiptera 233 MBChe <- MBCin[MBCin$Order=='Hemiptera',] # 1.4 Hymenoptera 186 MBChy <- MBCin[MBCin$Order=='Hymenoptera',] # 1.5 Lepidoptera 289 MBCle <- MBCin[MBCin$Order=='Lepidoptera',] # # # family level, 1608 (70.4%) OTUs not identified, abandoned # summary(MBCin$Family) # prepare the subset data colnames(MBCsp) MBCsp <- MBCsp[,c(-30,-31,-32,-33,-34,-35,-36)] MBCin <- MBCin[,c(-30,-31,-32,-33,-34,-35,-36)] MBCcole <- MBCcole[,c(-30,-31,-32,-33,-34,-35,-36)] MBCdi <- MBCdi[,c(-30,-31,-32,-33,-34,-35,-36)] MBChe <- MBChe[,c(-30,-31,-32,-33,-34,-35,-36)] MBChy <- MBChy[,c(-30,-31,-32,-33,-34,-35,-36)] MBCle <- MBCle[,c(-30,-31,-32,-33,-34,-35,-36)] MBCsp <- data.frame(t(MBCsp)) MBCin <- data.frame(t(MBCin)) MBCcole <- data.frame(t(MBCcole)) MBCdi <- data.frame(t(MBCdi)) MBChe <- data.frame(t(MBChe)) MBChy <- data.frame(t(MBChy)) MBCle <- data.frame(t(MBCle)) # convert to presence/absence MBCsp[MBCsp>0] <- 1 MBCin[MBCin>0] <- 1 # str(MBCin) MBCcole[MBCcole>0] <- 1 MBCdi[MBCdi>0] <- 1 MBChe[MBChe>0] <- 1 MBChy[MBChy>0] <- 1 MBCle[MBCle>0] <- 1 # get the subset data MBCsp <- MBCsp[row.names(Tree), ] MBCin <- MBCin[row.names(Tree), ] MBCcole <- MBCcole[row.names(Tree), ] MBCdi <- MBCdi[row.names(Tree), ] MBChe <- MBChe[row.names(Tree), ] MBChy <- MBChy[row.names(Tree), ] MBCle <- MBCle[row.names(Tree), ] # remove the empty columns Tree <- Tree[ ,specnumber(Tree, MARGIN=2)>0] # 371->297 MBCsp <- MBCsp[ ,specnumber(MBCsp, MARGIN=2)>0] # 52->42 MBCin <- MBCin[ ,specnumber(MBCin, MARGIN=2)>0] # 2285->1995 MBCcole <- MBCcole[ ,specnumber(MBCcole, MARGIN=2)>0] # 271->239 MBCdi <- MBCdi[ ,specnumber(MBCdi, MARGIN=2)>0] # 993->848 MBChe <- MBChe[ ,specnumber(MBChe, MARGIN=2)>0] # 233->205 MBChy <- MBChy[ ,specnumber(MBChy, MARGIN=2)>0] # 186->163 MBCle <- MBCle[ ,specnumber(MBCle, MARGIN=2)>0] # 289->263 ``` #### _Mengsong, Yunnan_ We sampled insects at two seasons: 1) the end of wet season, 2) the end of dry season, and in three habitats: mature forest (MF), regenerating forest (RF) and open land (OL) ```{r input Mengsong data} # # read the plant data n=28 Plant <- read.csv("MS_Plant_output.csv", header=TRUE, row.names = 1) # 807 species # head(Plant) # str(Plant) Plant[Plant>0] <- 1 # convert to incidence data, as herbs are measured by coverage but trees by individuals # head(Plant) # # # read the metabarcoding arthropod data # # edit the MSall_merged_otu97_table_withtax_arthropoda_NonSingleRead_R.txt, which comes from the bioinformatic pipeline: delete # constructed from biom file, replace # OTU ID as row.names, replace ConsensusLineage as taxonomy # # MBCar <- read.table("MSall_merged_otu97_table_withtax_arthropoda_NonSingleRead_R.txt", header=TRUE, sep="\t", row.names=1, na.strings="NA", dec=".", strip.white=TRUE) # head(MBCar) # write.csv(MBCar,"MBCar_MS.csv") # # edite the MBCar_MS.csv, and pay attention to the blank space # # split taxonomy column to refer to different taxonomic levels # # the order level contains 2 "others", and I change them (Diptera_sp._KMGHap_88, Eupodoidea_sp._AMUEnv017) # # MBCar <- read.csv('MBCar_MS.csv', row.names=1, h=T) # 3214 # head(MBCar) # str(MBCar) # colnames(MBCar) # # # sequence the colnames # Colnames <- colnames(MBCar)[-c(58,59,60,61,62,63,64)] # Colnames <- Colnames[order(Colnames)] # MBCar_notax <- MBCar[,Colnames] # MBCar <- data.frame(MBCar_notax, MBCar[,c(58,59,60,61,62,63,64)]) # # # delete MS1PLOT251, which we no longer use # colnames(MBCar) # MBCar <- MBCar[,-19] # # check the empty OTUs, 18 OTUs removed # MBCar <- MBCar[which(apply(MBCar[,-c(57,58,59,60,61,62,63)],MARGIN=1,FUN=sum)>0),] # 3196 # # # convert to presence/absence # MBCar_notax <- MBCar[,-c(57,58,59,60,61,62,63)] # colnames(MBCar_notax) # MBCar_notax[MBCar_notax>1] <- 1 # summary(MBCar_notax) # MBCar <- data.frame(MBCar_notax, MBCar[,c(57,58,59,60,61,62,63)]) # summary(MBCar) # # ## 1 sample at the end of wet season # MBCar1 <- MBCar[,c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,57,58,59,60,61,62,63)] # colnames(MBCar1) # # write.csv(MBCar1,"MBCar_MS1.csv") # check the taxonomy infor # # ## 2 sample at the end of dry season # MBCar2 <- MBCar[,c(29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63)] # colnames(MBCar2) # # write.csv(MBCar2,"MBCar_MS2.csv") # check the taxonomy infor #### prepare taxa dataset for sample at the end of wet season MBCar1 <- read.csv("MBCar_MS1.csv", head=T, row.names=1) # ar: Arthropoda # head(MBCar1) ## remove the empty OTUs MBCar1 <- MBCar1[specnumber(MBCar1[, -c(29,30,31,32,33,34,35)], MARGIN=1)>0,] # 2260 OTUs # get subset of the data summary(MBCar1$Class) # 1.2% not identified # 1. Arachnida 84 OTUs MBCsp1 <- MBCar1[MBCar1$Class=="Arachnida",] # sp = spider # Arachnida order, small sample size summary(MBCsp1$Order) # largest order Araneae 31 # 2. Insecta 2073 OTUs MBCin1 <- MBCar1[MBCar1$Class=="Insecta",] # head(MBCin1) summary(MBCin1$Order) # 8.3% not identified MBCcole1 <- MBCin1[MBCin1$Order=="Coleoptera",] # 375 OTUs MBCdi1 <- MBCin1[MBCin1$Order=="Diptera",] # 414 MBChe1 <- MBCin1[MBCin1$Order=="Hemiptera",] # 435 MBChy1 <- MBCin1[MBCin1$Order=="Hymenoptera",] # 409 MBCle1 <- MBCin1[MBCin1$Order=="Lepidoptera",] # 78 MBCps1 <- MBCin1[MBCin1$Order=="Psocoptera",] # 71 # summary(MBCin1$Family) # 57.0% not identified, abandoned # prepare the data for analysis colnames(MBCsp1) MBCsp1 <- MBCsp1[,-c(29,30,31,32,33,34,35)] MBCin1 <- MBCin1[,-c(29,30,31,32,33,34,35)] MBCcole1 <- MBCcole1[,-c(29,30,31,32,33,34,35)] MBCdi1 <- MBCdi1[,-c(29,30,31,32,33,34,35)] MBChe1 <- MBChe1[,-c(29,30,31,32,33,34,35)] MBChy1 <- MBChy1[,-c(29,30,31,32,33,34,35)] MBCle1 <- MBCle1[,-c(29,30,31,32,33,34,35)] MBCps1 <- MBCps1[,-c(29,30,31,32,33,34,35)] MBCsp1 <- data.frame(t(MBCsp1)) MBCin1 <- data.frame(t(MBCin1)) MBCcole1 <- data.frame(t(MBCcole1)) MBCdi1 <- data.frame(t(MBCdi1)) MBChe1 <- data.frame(t(MBChe1)) MBChy1 <- data.frame(t(MBChy1)) MBCle1 <- data.frame(t(MBCle1)) MBCps1 <- data.frame(t(MBCps1)) # make sure the row.names are same! row.names(Plant);row.names(MBCsp1) #### prepare taxa dataset for sample at the end of dry season MBCar2 <- read.csv("MBCar_MS2.csv", head=T, row.names=1) # head(MBCar2) # colnames(MBCar2) ## remove the empty OTUs MBCar2 <- MBCar2[specnumber(MBCar2[, -c(29,30,31,32,33,34,35)], MARGIN=1)>0,] # 2412 OTUs # get subset of the data summary(MBCar2$Class) # 1.1% not identified # 1. Arachnida 83 OTUs MBCsp2 <- MBCar2[MBCar2$Class=="Arachnida",] # sp = spider # Arachnida order, small sample size summary(MBCsp2$Order) # largest order Araneae 30 # 2. Class==Insecta 2215 MBCin2 <- MBCar2[MBCar2$Class=="Insecta",] # head(MBCin2) summary(MBCin2$Order) # 8.2% not identified # 1.1 Order==Coleoptera 603 # 1.3 Order==Diptera 413 # 1.4 Order==Hemiptera 370 # 1.5 Order==Hymenoptera 360 # 1.6 Order==Lepidoptera 95 # 1.7 Order==Psocoptera 63 MBCcole2 <- MBCin2[MBCin2$Order=="Coleoptera",] # 603 OTUs MBCdi2 <- MBCin2[MBCin2$Order=="Diptera",] # 413 MBChe2 <- MBCin2[MBCin2$Order=="Hemiptera",] # 370 MBChy2 <- MBCin2[MBCin2$Order=="Hymenoptera",] # 360 MBCle2 <- MBCin2[MBCin2$Order=="Lepidoptera",] # 95 MBCps2 <- MBCin2[MBCin2$Order=="Psocoptera",] # 63 # summary(MBCin2$Family) # 56.7% not identified, abandoned # prepare the data for analysis colnames(MBCsp2) MBCsp2 <- MBCsp2[,-c(29,30,31,32,33,34,35)] MBCin2 <- MBCin2[,-c(29,30,31,32,33,34,35)] MBCcole2 <- MBCcole2[,-c(29,30,31,32,33,34,35)] MBCdi2 <- MBCdi2[,-c(29,30,31,32,33,34,35)] MBChe2 <- MBChe2[,-c(29,30,31,32,33,34,35)] MBChy2 <- MBChy2[,-c(29,30,31,32,33,34,35)] MBCle2 <- MBCle2[,-c(29,30,31,32,33,34,35)] MBCps2 <- MBCps2[,-c(29,30,31,32,33,34,35)] MBCsp2 <- data.frame(t(MBCsp2)) MBCin2 <- data.frame(t(MBCin2)) MBCcole2 <- data.frame(t(MBCcole2)) MBCdi2 <- data.frame(t(MBCdi2)) MBChe2 <- data.frame(t(MBChe2)) MBChy2 <- data.frame(t(MBChy2)) MBCle2 <- data.frame(t(MBCle2)) MBCps2 <- data.frame(t(MBCps2)) # make sure the row.names are same! row.names(Plant);row.names(MBCsp2) #### prepare taxa dataset for two habitats: forests(mature forest + regenerating forest) and open land MSenv <- read.csv('MSenv.csv', header=T, row.names=1) # Mengsong environmental variables data #### forests (f, mature forest + regenerating forest) ### plant data Plantf <- Plant[MSenv$HAB!='OL',] Plantf <- Plantf[,(specnumber(Plantf,MARGIN=2)>0)] # 807-->747 ### Arachnida data MBCsp1f <- MBCsp1[MSenv$HAB!='OL',] MBCsp1f <- MBCsp1f[,(specnumber(MBCsp1f,MARGIN=2)>0)] # 84-->79 MBCsp2f <- MBCsp2[MSenv$HAB!='OL',] MBCsp2f <- MBCsp2f[,(specnumber(MBCsp2f,MARGIN=2)>0)] # 83-->73 ### Insecta and orders data MBCin1f <- MBCin1[MSenv$HAB!='OL',] MBCin1f <- MBCin1f[,(specnumber(MBCin1f,MARGIN=2)>0)] # 2073-->1780 MBCcole1f <- MBCcole1[MSenv$HAB!='OL',] MBCcole1f <- MBCcole1f[,(specnumber(MBCcole1f,MARGIN=2)>0)] # 375-->323 MBCdi1f <- MBCdi1[MSenv$HAB!='OL',] MBCdi1f <- MBCdi1f[,(specnumber(MBCdi1f,MARGIN=2)>0)] # 414-->363 MBChe1f <- MBChe1[MSenv$HAB!='OL',] MBChe1f <- MBChe1f[,(specnumber(MBChe1f,MARGIN=2)>0)] # 435-->360 MBChy1f <- MBChy1[MSenv$HAB!='OL',] MBChy1f <- MBChy1f[,(specnumber(MBChy1f,MARGIN=2)>0)] # 409-->360 MBCle1f <- MBCle1[MSenv$HAB!='OL',] MBCle1f <- MBCle1f[,(specnumber(MBCle1f,MARGIN=2)>0)] # 78-->70 MBCps1f <- MBCps1[MSenv$HAB!='OL',] MBCps1f <- MBCps1f[,(specnumber(MBCps1f,MARGIN=2)>0)] # 71-->60 MBCin2f <- MBCin2[MSenv$HAB!='OL',] MBCin2f <- MBCin2f[,(specnumber(MBCin2f,MARGIN=2)>0)] # 2215-->1913 MBCcole2f <- MBCcole2[MSenv$HAB!='OL',] MBCcole2f <- MBCcole2f[,(specnumber(MBCcole2f,MARGIN=2)>0)] # 603-->510 MBCdi2f <- MBCdi2[MSenv$HAB!='OL',] MBCdi2f <- MBCdi2f[,(specnumber(MBCdi2f,MARGIN=2)>0)] # 413-->381 MBChe2f <- MBChe2[MSenv$HAB!='OL',] MBChe2f <- MBChe2f[,(specnumber(MBChe2f,MARGIN=2)>0)] # 370-->293 MBChy2f <- MBChy2[MSenv$HAB!='OL',] MBChy2f <- MBChy2f[,(specnumber(MBChy2f,MARGIN=2)>0)] # 360-->308 MBCle2f <- MBCle2[MSenv$HAB!='OL',] MBCle2f <- MBCle2f[,(specnumber(MBCle2f,MARGIN=2)>0)] # 95-->84 MBCps2f <- MBCps2[MSenv$HAB!='OL',] MBCps2f <- MBCps2f[,(specnumber(MBCps2f,MARGIN=2)>0)] # 63-->59 #### open land (ol) ### plant data Plantol <- Plant[MSenv$HAB=='OL',] Plantol <- Plantol[,(specnumber(Plantol,MARGIN=2)>0)] # 807-->204 ### Arachnida data MBCsp1ol <- MBCsp1[MSenv$HAB=='OL',] MBCsp1ol <- MBCsp1ol[,(specnumber(MBCsp1ol,MARGIN=2)>0)] # 84-->27 MBCsp2ol <- MBCsp2[MSenv$HAB=='OL',] MBCsp2ol <- MBCsp2ol[,(specnumber(MBCsp2ol,MARGIN=2)>0)] # 83-->28 ### Insecta and orders data MBCin1ol <- MBCin1[MSenv$HAB=='OL',] MBCin1ol <- MBCin1ol[,(specnumber(MBCin1ol,MARGIN=2)>0)] # 2073-->1049 MBCcole1ol <- MBCcole1[MSenv$HAB=='OL',] MBCcole1ol <- MBCcole1ol[,(specnumber(MBCcole1ol,MARGIN=2)>0)] # 375-->148 MBCdi1ol <- MBCdi1[MSenv$HAB=='OL',] MBCdi1ol <- MBCdi1ol[,(specnumber(MBCdi1ol,MARGIN=2)>0)] # 414-->228 MBChe1ol <- MBChe1[MSenv$HAB=='OL',] MBChe1ol <- MBChe1ol[,(specnumber(MBChe1ol,MARGIN=2)>0)] # 435-->231 MBChy1ol <- MBChy1[MSenv$HAB=='OL',] MBChy1ol <- MBChy1ol[,(specnumber(MBChy1ol,MARGIN=2)>0)] # 409-->225 MBCle1ol <- MBCle1[MSenv$HAB=='OL',] MBCle1ol <- MBCle1ol[,(specnumber(MBCle1ol,MARGIN=2)>0)] # 78-->38 MBCps1ol <- MBCps1[MSenv$HAB=='OL',] MBCps1ol <- MBCps1ol[,(specnumber(MBCps1ol,MARGIN=2)>0)] # 71-->48 MBCin2ol <- MBCin2[MSenv$HAB=='OL',] MBCin2ol <- MBCin2ol[,(specnumber(MBCin2ol,MARGIN=2)>0)] # 2215-->1079 MBCcole2ol <- MBCcole2[MSenv$HAB=='OL',] MBCcole2ol <- MBCcole2ol[,(specnumber(MBCcole2ol,MARGIN=2)>0)] # 603-->293 MBCdi2ol <- MBCdi2[MSenv$HAB=='OL',] MBCdi2ol <- MBCdi2ol[,(specnumber(MBCdi2ol,MARGIN=2)>0)] # 413-->197 MBChe2ol <- MBChe2[MSenv$HAB=='OL',] MBChe2ol <- MBChe2ol[,(specnumber(MBChe2ol,MARGIN=2)>0)] # 370-->194 MBChy2ol <- MBChy2[MSenv$HAB=='OL',] MBChy2ol <- MBChy2ol[,(specnumber(MBChy2ol,MARGIN=2)>0)] # 360-->186 MBCle2ol <- MBCle2[MSenv$HAB=='OL',] MBCle2ol <- MBCle2ol[,(specnumber(MBCle2ol,MARGIN=2)>0)] # 95-->33 MBCps2ol <- MBCps2[MSenv$HAB=='OL',] MBCps2ol <- MBCps2ol[,(specnumber(MBCps2ol,MARGIN=2)>0)] # 63-->43 ``` ### 1. alpha diverdity level: using plant model to predict insect OTU richness Fitting a function describing the relationship between the cumulative average number of vascular plant/tree species per site (based on randomized site order) and the cumulative average number of insect OTU per site (also based on randomized site order) by the software [CurveExpert](www.curveexpert.net) v1.4. _CurveFinder_ (Tools->CurveFinder) ranks alternative models automatically based on __the goodness of fit of the data (standard error and correlation coefficient)__. Such ranking usually corresponds to that based on AICc, except for analyses in open land (sample size is low: six, and AICc favors two-parameter functions for sure). We applied two approaches to get the plant model: 1. Following Basset et al. (2012), just include linear (y=a+bx), power (y=ax^b) and Weibull (y=a-bexp(-cx^d)) functions as alternative models, and choosing the best function according to AICc. The best function is called the "plant model"; Note that Weibull function (four parameters) applied in _CurveExpert_ is different from that in relevant research (three parameters, y=a(1-exp(-bx^c))) (e.g. Dengler 2009). There might be concern on whether Weibull with three parameters performs better, and pilot analyses detect only one such case out of 14 analyses. Even for the only case, the delaAICc between Weibull with three paramters and with four parameters is only 2 and their curves were almost same. Thus we decided to ignore three-parameter Weibull function. 2. A complex but potentially more accurate way was to chose the plant model from a broader selection of 25 candidates, including ones used in comparable studies (Dengler 2009) and their variants. These alternative candidates include linear (including quadratic fit and 3rd degree polynomial fit), exponential family, power family, growth family, sigmoidal family and rational functions. Statistical arguments relied on the AICc and on the _lowest error of extrapolation_, similar with log error of extrapolation (LEE, Dengler 2009). The idea of applying _lowest error of extrapolation_ is different statistical models may sometimes fit the data equally well, but yield widely different estimates of species richness. Also, statistical models offering a good fit to the data do not necessarily result in a satisfactory species richness estimate (Basset et al. 2012). To calculate _lowest error of extrapolation_, we fitted top 3 functions (chosen based on AICc) to a random subset of data (20 out of 28 for Mengsong, 15 out of 21 for Yinggeling). Then, using the newly parameterized models, we compared the predicted with the actual insect OTU value in the original data set (error of extrapolation). The function with lowest error of extrapolation was chosen as the best function. It proved that approach 2 produced similar results as approach 1. #### __Three alternative functions__ #### _Yinggeling, Hainan_ ```{r alpha_Yinggeling_3_alternative_functions} ### Arachnida not included due to the low sample size (<50) ### Insecta # Pearson correlation test plot(specnumber(MBCin, MARGIN=1)~specnumber(Tree, MARGIN=1), main="Species richness comparison at plot scale (Yinggeling)", xlab="Trees", ylab="Insecta") # no positive relationship cor.test(specnumber(MBCin, MARGIN=1),specnumber(Tree, MARGIN=1), method='p') # r = 0.11 # plant model approach sac.tree <- specaccum(comm=Tree, method="random", permutations=9999) # pilot runs show 9999 permutations give more consistent results in choosing the plant model, compared with 100 (default) and 999 permutations, although plant models between permutations are sometimes not same. sac.in <- specaccum(comm=MBCin, method="random", permutations=9999) plot(sac.in$richness ~ sac.tree$richness, xlab='Trees', ylab='Insect', main='Accumulated species richness comparison (Yinggeling)') # clear relationship # # **you may need to remove the # before below commands and run them yourself # y <- sac.in$richness # x <- sac.tree$richness # curve.in <- data.frame(x=x, y=y) # write.csv(curve.in, 'curve.in.csv', row.names=F) # # **you may need to remove the # before above commands and run them yourself # read the curve.in.csv into CurveExpert # scale x by 0.01 and y by 0.001 as suggested by CurveExpert # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.39323327191E+001 b = 1.38515892171E+001 c = 2.69791795103E-002 d = 1.56512741540E+000 # check the curve xx <- 1:603 # 603 tree species in Yinggeling yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx) # ok # # **you may need to remove the #s before below commands and run the commands yourself # # calculate the AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # n <- 21 # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 4.42363686419E-001 # b = 1.37838423801E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -2.99182781683E-001 # b = 7.47242258371E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.w, AICc.p, AICc.l)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the insect OTU richness from plant model (y.in <- a-b*exp(-c*6.03^d)) # 603 tree species in Yinggeling, 603*0.01=6.03 # # estimate the insect OTU richness separately by non-parametric estimation acc.in <- alpha.accum(comm=MBCin, func="nonparametric", runs=1) (Y.in <- acc.in[21,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of insect OTU richness Y.in/(y.in*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.62 0.84 0.76 1.03 0.73 0.99 #### apply to Insecta orders #### # Pearson correlation test plot(specnumber(MBCcole, MARGIN=1)~specnumber(Tree, MARGIN=1), main="Species richness comparison at plot scale (Yinggeling)", xlab="Trees", ylab="Coleoptera") # no positive relationship cor.test(specnumber(MBCcole, MARGIN=1), specnumber(Tree, MARGIN=1), method='p') # r=0.13 plot(specnumber(MBCdi, MARGIN=1)~specnumber(Tree, MARGIN=1), main="Species richness comparison at plot scale (Yinggeling)", xlab="Trees", ylab="Diptera") # no positive relationship cor.test(specnumber(MBCdi, MARGIN=1), specnumber(Tree, MARGIN=1), method='p') # 0.12 plot(specnumber(MBChe, MARGIN=1)~specnumber(Tree, MARGIN=1), main="Species richness comparison at plot scale (Yinggeling)", xlab="Trees", ylab="Hemiptera") # no positive relationship cor.test(specnumber(MBChe, MARGIN=1), specnumber(Tree, MARGIN=1), method='p') # -0.02 plot(specnumber(MBChy, MARGIN=1)~specnumber(Tree, MARGIN=1), main="Species richness comparison at plot scale (Yinggeling)", xlab="Trees", ylab="Hymenoptera") # no positive relationship cor.test(specnumber(MBChy, MARGIN=1), specnumber(Tree, MARGIN=1), method='p') # 0.14 plot(specnumber(MBCle, MARGIN=1)~specnumber(Tree, MARGIN=1), main="Species richness comparison at plot scale (Yinggeling)", xlab="Trees", ylab="Lepidoptera") # no positive relationship cor.test(specnumber(MBCle, MARGIN=1), specnumber(Tree, MARGIN=1), method='p') # -0.00 # plant model approach sac.cole <- specaccum(MBCcole, "random", permutations=9999) sac.di <- specaccum(MBCdi, "random", permutations=9999) sac.he <- specaccum(MBChe, "random", permutations=9999) sac.hy <- specaccum(MBChy, "random", permutations=9999) sac.le <- specaccum(MBCle, "random", permutations=9999) plot(sac.cole$richness ~ sac.tree$richness, xlab='Trees', ylab='Coleoptera', main='Accumulated species richness comparison') # clear relationship plot(sac.di$richness ~ sac.tree$richness, xlab='Trees', ylab='Diptera', main='Accumulated species richness comparison') # clear relationship plot(sac.he$richness ~ sac.tree$richness, xlab='Trees', ylab='Hemiptera', main='Accumulated species richness comparison') # clear relationship plot(sac.hy$richness ~ sac.tree$richness, xlab='Trees', ylab='Hymenoptera', main='Accumulated species richness comparison') # clear relationship plot(sac.le$richness ~ sac.tree$richness, xlab='Trees', ylab='Lepidoptera', main='Accumulated species richness comparison') # clear relationship #### Coleoptera #### # # **you may need to remove the # before below commands and run the commands yourself # y <- sac.cole$richness # # curve.cole <- data.frame(x=x, y=y) # write.csv(curve.cole, 'curve.cole.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read the curve.cole.csv into CurveExpert # scale x and y by 0.01 as suggested by CurveExpert # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.04852725401E+001 b = 1.03543582791E+001 c = 3.34742069514E-002 d = 1.82069964115E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 4.56691220952E-001 # b = 1.50853971197E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -4.40675182132E-001 # b = 9.07342604248E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the Coleoptera OTU richness from plant model y.cole <- a-b*exp(-c*6.03^d) # # estimate the Coleoptera OTU richness separately by non-parametric estimation acc.cole <- alpha.accum(comm=MBCcole, func="nonparametric", runs=1) Y.cole <- acc.cole[21,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera OTU richness Y.cole/(y.cole*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.64 0.96 0.84 1.25 0.98 1.47 #### Diptera #### # y <- sac.di$richness # # curve.di <- data.frame(x=x, y=y) # write.csv(curve.di, 'curve.di.csv', row.names=F) # read the curve.di.csv into CurveExpert # scale x and y by 0.01 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 3.24563134314E+001 b = 3.20423314259E+001 c = 5.21898054812E-002 d = 1.56897921325E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 2.03627412934E+000 # b = 1.30580853393E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -1.06961227319E+000 # b = 3.12858498345E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera OTU richness from plant model y.di <- a-b*exp(-c*6.03^d) # # estimate the Diptera OTU richness by separately non-parametric estimation acc.di <- alpha.accum(comm=MBCdi, func="nonparametric", runs=1) Y.di <- acc.di[21,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di/(y.di*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.69 0.91 0.84 1.11 0.80 1.06 #### Hemiptera #### # y <- sac.he$richness # # curve.he <- data.frame(x=x, y=y) # write.csv(curve.he, 'curve.he.csv', row.names=F) # read the curve.he.csv into CurveExpert # scale x and y by 0.01 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.33386336366E+001 b = 1.32570260080E+001 c = 2.84305655558E-002 d = 1.58862517562E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 4.46277417531E-001 # b = 1.39590217421E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -3.19740760712E-001 # b = 7.71426908692E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hemiptera OTU richness from plant model y.he <- a-b*exp(-c*6.03^d) # # estimate the Hemiptera OTU richness separately by non-parametric estimation acc.he <- alpha.accum(comm=MBChe, func="nonparametric", runs=1) Y.he <- acc.he[21,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera OTU richness Y.he/(y.he*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.62 0.84 0.76 1.03 0.71 0.97 #### Hymenoptera #### # y <- sac.hy$richness # # curve.hy <- data.frame(x=x, y=y) # write.csv(curve.hy, 'curve.hy.csv', row.names=F) # read the curve.hy.csv into CurveExpert # scale x and y by 0.01 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.41651571419E+000 b = 5.33635949865E+000 c = 5.66669769840E-002 d = 1.65174106074E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 3.73667884762E-001 # b = 1.35243876326E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -2.33492212257E-001 # b = 6.10941429377E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hymenoptera OTU richness from plant model y.hy <- a-b*exp(-c*6.03^d) # # estimate the Hymenoptera OTU richness separately by non-parametric estimation acc.hy <- alpha.accum(comm=MBChy, func="nonparametric", runs=1) Y.hy <- acc.hy[21,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy/(y.hy*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.69 0.90 0.81 1.06 0.70 0.92 #### Lepidoptera #### # y <- sac.le$richness # # curve.le <- data.frame(x=x, y=y) # write.csv(curve.le, 'curve.le.csv', row.names=F) # read the curve.le.csv into CurveExpert # scale x and y by 0.01 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.00848708582E+001 b = 1.99831609899E+001 c = 2.23029376169E-002 d = 1.65228515255E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 5.30654032552E-001 # b = 1.46468102693E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -4.63984954425E-001 # b = 1.00132606387E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Lepidoptera species richness from plant model y.le <- a-b*exp(-c*6.03^d) # # estimate the Lepidoptera species richness separately by non-parametric estimation acc.le <- alpha.accum(comm=MBCle, func="nonparametric", runs=1) Y.le <- acc.le[21,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le/(y.le*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.59 0.84 0.74 1.05 0.72 1.02 #### calculate the fitness #### dat <- data.frame(Insect=c(Y.in[c(2,4,6)],y.in*1000), Cole=c(Y.cole[c(2,4,6)],y.cole*100), Di=c(Y.di[c(2,4,6)],y.di*100), He=c(Y.he[c(2,4,6)],y.he*100), Hy=c(Y.hy[c(2,4,6)],y.hy*100), Le=c(Y.le[c(2,4,6)],y.le*100), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P','plant.model')) # only present P-corrected versions and individual orders dat <- data.frame(t(dat)) #### calculate the R^2 fitted to the y=x model #### options(digits=4) ## Jack1inP yi <- dat[-1, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- dat[-1, ]$plant.model # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9604 ## Jack2inP yi <- dat[-1, ]$Jack2inP ym <- mean(yi) SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9628 ## Chao2P yi <- dat[-1, ]$Chao2P ym <- mean(yi) SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.945 #### calculate the correlations between two estimates #### cor.test(y=dat[-1, ]$Jack1inP, x=dat[-1, ]$plant.model, method='pearson') # r=0.9984 cor.test(y=dat[-1, ]$Jack2inP, x=dat[-1, ]$plant.model, method='pearson') # r=0.9970 cor.test(y=dat[-1, ]$Chao2P, x=dat[-1, ]$plant.model, method='pearson') # r=0.9809 options(digits=2) ``` #### _Mengsong, Yunnan_ There are three habitats in Mengsong, naming mature forest (n=10), regenerating forest (n=12) and open land (n=6). We do the analyses as the following order: 1. all habitats combined 2. forests only (mature forest + regenerating forest) 3. open land only ##### __1. all habitats combined__ ```{r alpha_Mengsong_all_3_alternative_functions} ### Arachnida # Pearson correlation test plot(specnumber(MBCsp1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong_wet)", xlab="Plants", ylab="Arachnida") # no positive relationship plot(specnumber(MBCsp2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong_dry)", xlab="Plants", ylab="Arachnida") # no positive relationship cor.test(specnumber(MBCsp1, MARGIN=1),specnumber(Plant, MARGIN=1), method='pearson') # r = 0.29 cor.test(specnumber(MBCsp2, MARGIN=1),specnumber(Plant, MARGIN=1), method='pearson') # r = 0.21 # Plant model approach sac.plant <- specaccum(comm=Plant, method="random", permutations=9999) sac.sp1 <- specaccum(comm=MBCsp1, method="random", permutations=9999) sac.sp2 <- specaccum(comm=MBCsp2, method="random", permutations=9999) plot(sac.sp1$richness ~ sac.plant$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.sp2$richness ~ sac.plant$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # # **you may need to remove the # before below commands and run the commands yourself # y1 <- sac.sp1$richness; y2 <- sac.sp2$richness # x <- sac.plant$richness # curve.sp1 <- data.frame(x=x, y=y1) # curve.sp2 <- data.frame(x=x, y=y2) # write.csv(curve.sp1, 'curve.sp1.csv', row.names=F) # write.csv(curve.sp2, 'curve.sp2.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read the curve.sp1.csv, curve.sp1.csv into CurveExpert # scale x by 0.01 and y by 0.1 as suggested by CurveExpert ### sample at the end of wet season (hereafter: wet season) ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.43080456893E+001 b = 4.40905960027E+001 c = 1.59794854193E-002 d = 1.22258180177E+000 # check the curve xx <- 1:1700 # max(x.plant) = 1623 yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # n <- 28 # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.58259735820E-001 # b = 1.09295587254E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -3.50507925614E-001 # b = 1.07725660050E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull # # **you may need to remove the # before above commands and run the commands yourself # # estimate the plant species richness by non-parametric estimation (acc.plant <- alpha.accum(comm=Plant, func="nonparametric", runs=1)) (x.plant <- acc.plant[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # predict the spider OTU richness from plant model (y.sp1 <- a-b*exp(-c*(x.plant*0.01)^d)) # # estimate the spider OTU richness separately by non-parametric estimation acc.sp1 <- alpha.accum(comm=MBCsp1, func="nonparametric", runs=1) (Y.sp1 <- acc.sp1[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of Arachnida OTU richness Y.sp1/(y.sp1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 1.03 1.01 1.04 0.97 0.99 ### sample at the end of dry season (hereafter: dry season) ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.68331545898E+001 b = 2.65665778766E+001 c = 2.50125743452E-002 d = 1.27924890949E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.77826524715E-001 # b = 1.07941369883E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -3.08677299640E-001 # b = 1.06771080318E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the spider OTU richness from plant model (y.sp2 <- a-b*exp(-c*(x.plant*0.01)^d)) # # estimate the spider OTU richness separately by non-parametric estimation acc.sp2 <- alpha.accum(comm=MBCsp2, func="nonparametric", runs=1) (Y.sp2 <- acc.sp2[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of Arachnida OTU richness Y.sp2/(y.sp2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 0.99 0.94 0.95 0.84 0.85 ### Insecta # Pearson correlation test plot(specnumber(MBCin1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Insects") # no positive relationship cor.test(specnumber(MBCin1, MARGIN=1),specnumber(Plant, MARGIN=1)) # -0.08 plot(specnumber(MBCin2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Insects") # no positive relationship cor.test(specnumber(MBCin2, MARGIN=1),specnumber(Plant, MARGIN=1)) # 0.04 # Plant model approach sac.in1 <- specaccum(MBCin1, "random", permutations=9999) sac.in2 <- specaccum(MBCin2, "random", permutations=9999) plot(sac.in1$richness ~ sac.plant$richness, xlab='Plants', ylab='Insects', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.in2$richness ~ sac.plant$richness, xlab='Plants', ylab='Insects', main='Accumulated species richness comparison (Mengsong:dry') # clear relationship # # **you may need to remove the # before below commands and run the commands yourself # y1 <- sac.in1$richness; y2 <- sac.in2$richness # x <- sac.plant$richness # # curve.in1 <- data.frame(x=x, y=y1) # curve.in2 <- data.frame(x=x, y=y2) # # write.csv(curve.in1, 'curve.in1.csv', row.names=F) # write.csv(curve.in2, 'curve.in2.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read curve.in1.csv, curve.in2.csv into CurveExpert # scale x by 0.01, and y by 0.001 as suggested by CurveExpert ### sample at the end of wet season (hereafter: wet season) ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.55487850991E+000 b = 5.47191832092E+000 c = 4.50754287875E-002 d = 1.10435105916E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # # calculate AICc by hand # # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 3.22171191561E-001 # b = 8.94141445371E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.13186615061E-001 # b = 2.46365601011E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the insect OTU richness from plant model y.in1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation (acc.in1 <- alpha.accum(comm=MBCin1, func="nonparametric", runs=1)) (Y.in1 <- acc.in1[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of insect OTU richness Y.in1/(y.in1*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 1.03 1.04 0.97 0.98 ### sample at the end of dry season (hereafter: dry season) ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.80629824999E+000 b = 4.70473784299E+000 c = 5.47751492706E-002 d = 1.14403544073E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 3.56366597211E-001 # b = 8.79226234344E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.37879093356E-001 # b = 2.62481405451E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the insect OTU richness from plant model y.in2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation (acc.in2 <- alpha.accum(comm=MBCin2, func="nonparametric", runs=1)) (Y.in2 <- acc.in2[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of insect OTU richness Y.in2/(y.in2*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 1.01 1.02 0.94 0.94 #### apply to Insecta orders #### # Pearson correlation test plot(specnumber(MBCcole1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Coleoptera") # no positive relationship plot(specnumber(MBCcole2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Coleoptera") # no positive relationship cor.test(specnumber(MBCcole1, MARGIN=1),specnumber(Plant, MARGIN=1)) # 0.07 cor.test(specnumber(MBCcole2, MARGIN=1),specnumber(Plant, MARGIN=1)) # 0.04 plot(specnumber(MBCdi1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Diptera") # no positive relationship plot(specnumber(MBCdi2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Diptera") # no positive relationship cor.test(specnumber(MBCdi1, MARGIN=1),specnumber(Plant, MARGIN=1)) # 0.03 cor.test(specnumber(MBCdi2, MARGIN=1),specnumber(Plant, MARGIN=1)) # 0.28 plot(specnumber(MBChe1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Hemiptera") # no positive relationship plot(specnumber(MBChe2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Hemiptera") # no positive relationship cor.test(specnumber(MBChe1, MARGIN=1),specnumber(Plant, MARGIN=1)) # -0.39 cor.test(specnumber(MBChe2, MARGIN=1),specnumber(Plant, MARGIN=1)) # -0.39 plot(specnumber(MBChy1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Hymenoptera") # no positive relationship plot(specnumber(MBChy2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Hymenoptera") # no positive relationship cor.test(specnumber(MBChy1, MARGIN=1),specnumber(Plant, MARGIN=1)) # -0.07 cor.test(specnumber(MBChy2, MARGIN=1),specnumber(Plant, MARGIN=1)) # -0.30 plot(specnumber(MBCle1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Lepidoptera") # no clearly positive relationship plot(specnumber(MBCle2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Lepidoptera") # no positive relationship cor.test(specnumber(MBCle1, MARGIN=1),specnumber(Plant, MARGIN=1)) # 0.23 cor.test(specnumber(MBCle2, MARGIN=1),specnumber(Plant, MARGIN=1)) # 0.29 plot(specnumber(MBCps1, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Psocoptera") # no positive relationship plot(specnumber(MBCps2, MARGIN=1)~specnumber(Plant, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Psocoptera") # no positive relationship cor.test(specnumber(MBCps1, MARGIN=1),specnumber(Plant, MARGIN=1)) # -0.19 cor.test(specnumber(MBCps2, MARGIN=1),specnumber(Plant, MARGIN=1)) # -0.16 # plant model approach sac.cole1 <- specaccum(MBCcole1, "random", permutations=9999) sac.cole2 <- specaccum(MBCcole2, "random", permutations=9999) sac.di1 <- specaccum(MBCdi1, "random", permutations=9999) sac.di2 <- specaccum(MBCdi2, "random", permutations=9999) sac.he1 <- specaccum(MBChe1, "random", permutations=9999) sac.he2 <- specaccum(MBChe2, "random", permutations=9999) sac.hy1 <- specaccum(MBChy1, "random", permutations=9999) sac.hy2 <- specaccum(MBChy2, "random", permutations=9999) sac.le1 <- specaccum(MBCle1, "random", permutations=9999) sac.le2 <- specaccum(MBCle2, "random", permutations=9999) sac.ps1 <- specaccum(MBCps1, "random", permutations=9999) sac.ps2 <- specaccum(MBCps2, "random", permutations=9999) plot(sac.cole1$richness ~ sac.plant$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.cole2$richness ~ sac.plant$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong:dry)') # clear relationship plot(sac.di1$richness ~ sac.plant$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.di2$richness ~ sac.plant$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong:dry)') # clear relationship plot(sac.he1$richness ~ sac.plant$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.he2$richness ~ sac.plant$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong:dry)') # clear relationship plot(sac.hy1$richness ~ sac.plant$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.hy2$richness ~ sac.plant$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong:dry)') # clear relationship plot(sac.le1$richness ~ sac.plant$richness, xlab='Plants', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.le2$richness ~ sac.plant$richness, xlab='Plants', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong:dry)') # clear relationship plot(sac.ps1$richness ~ sac.plant$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.ps2$richness ~ sac.plant$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong:dry)') # clear relationship #### Coleoptera #### # y1 <- sac.cole1$richness; y2 <- sac.cole2$richness # # curve.cole1 <- data.frame(x=x, y=y1) # curve.cole2 <- data.frame(x=x, y=y2) # # write.csv(curve.cole1, 'curve.cole1.csv', row.names=F) # write.csv(curve.cole2, 'curve.cole2.csv', row.names=F) # read curve.cole1.csv, curve.cole2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.19369100024E+001 b = 2.17842969330E+001 c = 1.48369663011E-002 d = 1.19622430589E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 4.20414207941E-001 # b = 1.04720764590E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -7.09099994826E-002 # b = 4.70513730515E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Coleoptera species richness from plant model y.cole1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1, func="nonparametric", runs=1) Y.cole1 <- acc.cole1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole1/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 1.02 1.01 1.03 1.00 1.02 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.28710901607E+001 b = 1.26362449280E+001 c = 5.02841021281E-002 d = 1.19983803196E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.76627672917E-001 # b = 9.28982063693E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.04547964267E-001 # b = 7.35160293743E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Coleoptera species richness from plant model y.cole2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole2 <- alpha.accum(comm=MBCcole2, func="nonparametric", runs=1) Y.cole2 <- acc.cole2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole2/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.01 0.99 1.00 0.90 0.91 #### Diptera #### # y1 <- sac.di1$richness; y2 <- sac.di2$richness # # curve.di1 <- data.frame(x=x, y=y1) # curve.di2 <- data.frame(x=x, y=y2) # # write.csv(curve.di1, 'curve.di1.csv', row.names=F) # write.csv(curve.di2, 'curve.di2.csv', row.names=F) # read curve.di1.csv, curve.di2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.31496568475E+000 b = 7.01103492934E+000 c = 7.76421581610E-002 d = 1.11301511276E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.37030133811E-001 # b = 7.70397258057E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 5.34424919109E-001 # b = 4.60530889218E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera species richness from plant model y.di1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Diptera species richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1, func="nonparametric", runs=1) Y.di1 <- acc.di1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di1/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.02 1.04 1.04 0.96 0.96 ### dry season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.35855308799E+000 b = 6.05053321809E+000 c = 9.24816900352E-002 d = 1.14120084794E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.85474257496E-001 # b = 7.44906065598E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 6.00063071674E-001 # b = 4.54982452047E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera species richness from plant model y.di2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Diptera species richness by non-parametric estimation acc.di2 <- alpha.accum(comm=MBCdi2, func="nonparametric", runs=1) Y.di2 <- acc.di2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di2/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.02 1.02 1.02 0.93 0.93 #### Hemiptera #### # y1 <- sac.he1$richness; y2 <- sac.he2$richness # # curve.he1 <- data.frame(x=x, y=y1) # curve.he2 <- data.frame(x=x, y=y2) # # write.csv(curve.he1, 'curve.he1.csv', row.names=F) # write.csv(curve.he2, 'curve.he2.csv', row.names=F) # read curve.he1.csv, curve.he2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.52633131386E+001 b = 1.51396527382E+001 c = 3.29523802565E-002 d = 1.09955448221E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 6.08742423637E-001 # b = 9.43482221889E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.22288488958E-001 # b = 5.28260238179E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hemiptera species richness from plant model y.he1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1, func="nonparametric", runs=1) Y.he1 <- acc.he1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he1/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 1.02 1.03 0.98 0.99 ### dry season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 9.68735748429E+000 b = 9.52259953842E+000 c = 3.85157069903E-002 d = 1.19217931986E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 5.07420537655E-001 # b = 9.54241108332E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 8.46391667305E-002 # b = 4.52351763388E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hemiptera species richness from plant model y.he2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he2 <- alpha.accum(comm=MBChe2, func="nonparametric", runs=1) Y.he2 <- acc.he2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he2/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.02 1.00 1.01 0.93 0.93 #### Hymenoptera #### # y1 <- sac.hy1$richness; y2 <- sac.hy2$richness # # curve.hy1 <- data.frame(x=x, y=y1) # curve.hy2 <- data.frame(x=x, y=y2) # # write.csv(curve.hy1, 'curve.hy1.csv', row.names=F) # write.csv(curve.hy2, 'curve.hy2.csv', row.names=F) # read curve.hy1.csv, curve.hy2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.16960477594E+000 b = 6.99196064676E+000 c = 7.39194619695E-002 d = 1.15376235794E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 7.25314894942E-001 # b = 8.35303266848E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 3.52229655045E-001 # b = 4.77374343042E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera species richness from plant model y.hy1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy1/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.02 1.02 1.03 0.94 0.94 ### dry season ### # Power Fit: y=ax^b # Coefficient Data: a = 5.58220969643E-001 b = 8.93300285453E-001 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 1.80389157987E+001 # b = 1.79576136053E+001 # c = 2.72148468874E-002 # d = 9.96396783616E-001 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.00158115855E-001 # b = 4.25507391695E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal # # predict the insect OTU richness from plant model y.hy2 <- a*(x.plant*0.01)^b # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy2 <- alpha.accum(comm=MBChy2, func="nonparametric", runs=1) Y.hy2 <- acc.hy2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy2/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 0.98 0.99 0.97 0.95 0.93 #### Lepidoptera #### # y1 <- sac.le1$richness; y2 <- sac.le2$richness # # curve.le1 <- data.frame(x=x, y=y1) # curve.le2 <- data.frame(x=x, y=y2) # # write.csv(curve.le1, 'curve.le1.csv', row.names=F) # write.csv(curve.le2, 'curve.le2.csv', row.names=F) # read curve.le1.csv, curve.le2.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.29022433638E+001 b = 2.23654888062E+001 c = 3.96794497202E-002 d = 1.09903971460E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.30201800669E+000 # b = 8.58787060127E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 6.04742205309E-001 # b = 9.04038645108E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the insect OTU richness from plant model y.le1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le1 <- alpha.accum(comm=MBCle1, func="nonparametric", runs=1) Y.le1 <- acc.le1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le1/(y.le1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 0.99 1.01 1.00 0.94 0.93 ### dry season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.49558175766E+002 b = 1.48882766488E+002 c = 4.78916716320E-003 d = 1.21899837516E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.07577650751E+000 # b = 1.03908909620E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -8.76093103040E-002 # b = 1.17118781619E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Lepidoptera species richness from plant model y.le2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le2 <- alpha.accum(comm=MBCle2, func="nonparametric", runs=1) Y.le2 <- acc.le2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le2/(y.le2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 1.00 0.98 0.99 0.96 0.97 #### Psocoptera #### # y1 <- sac.ps1$richness; y2 <- sac.ps2$richness # # curve.ps1 <- data.frame(x=x, y=y1) # curve.ps2 <- data.frame(x=x, y=y2) # # write.csv(curve.ps1, 'curve.ps1.csv', row.names=F) # write.csv(curve.ps2, 'curve.ps2.csv', row.names=F) # read curve.ps1.csv, curve.ps2.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.19947684582E+001 b = 1.23050284218E+001 c = 1.61568848436E-001 d = 8.34503171577E-001 yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.82478039682E+000 # b = 6.59257344883E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.45393355956E+000 # b = 7.36471820428E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Psocoptera species richness from plant model y.ps1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps1 <- alpha.accum(comm=MBCps1, func="nonparametric", runs=1) Y.ps1 <- acc.ps1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps1/(y.ps1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.00 0.99 0.98 0.91 0.89 ### dry season ### # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.86528581202E+000 b = 6.25290792334E+000 c = 1.39131179163E-001 d = 1.37628026598E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # asymptote from 1000, that's to say 1000 or 1600 plants harbour nearly same number of Psocoptera species, which sounds not sensible. Morover, the curve of wet season data is different. Thus, this model seems to be dropped. But keep it or not will not influence the general pattern of good fitness (result of below 'calculate the fitness'). # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.81521087330E+000 # b = 6.18549581768E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.51671441036E+000 # b = 6.51431688119E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Psocoptera species richness from plant model y.ps2 <- a-b*exp(-c*(x.plant*0.01)^d) # y.ps2 <- a*(x.plant*0.01)^b # Power Fit # # estimate the Psocoptera species richness by non-parametric estimation acc.ps2 <- alpha.accum(comm=MBCps2, func="nonparametric", runs=1) Y.ps2 <- acc.ps2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps2/(y.ps2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 0.96 0.96 0.95 0.95 (Weibull Model) # 0.84 0.75 0.72 0.65 0.75 0.67 (Power Fit) #### calculate the fitness #### DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in1[c(2,4,6)]*1000), Insect2=c(Y.in2[c(2,4,6)], y.in2[c(2,4,6)]*1000), Cole1=c(Y.cole1[c(2,4,6)], y.cole1[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole2[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di1[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di2[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he1[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he2[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy1[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy2[c(2,4,6)]*100), Le1=c(Y.le1[c(2,4,6)], y.le1[c(2,4,6)]*10), Le2=c(Y.le2[c(2,4,6)], y.le2[c(2,4,6)]*10), Ps1=c(Y.ps1[c(2,4,6)], y.ps1[c(2,4,6)]*10), Ps2=c(Y.ps2[c(2,4,6)], y.ps2[c(2,4,6)]*10), Spider1=c(Y.sp1[c(2,4,6)], y.sp1[c(2,4,6)]*10), Spider2=c(Y.sp2[c(2,4,6)], y.sp2[c(2,4,6)]*10), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C2P')) # only presenting P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9,11,13,15),] # wet season DAT2 <- DAT[c(2,4,6,8,10,12,14,16),] # dry season #### calculate the R^2 fitted to the y=x model #### options(digits=4) ### wet season ## Jack1inP yi <- DAT1[2:7, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.998 ## Jack2inP yi <- DAT1[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9956 ## Chao2P yi <- DAT1[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9941 ### dry season ## Jack1inP yi <- DAT2[2:7, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9990 ## Jack2inP yi <- DAT2[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9987 ## Chao2P yi <- DAT2[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9697 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[2:7, ]$Jack1inP, x=DAT1[2:7, ]$plant.model.J1P, method='pearson') # r=1 cor.test(y=DAT1[2:7, ]$Jack2inP, x=DAT1[2:7, ]$plant.model.J2P, method='pearson') # 1 cor.test(y=DAT1[2:7, ]$Chao2P, x=DAT1[2:7, ]$plant.model.C2P, method='pearson') # 0.9984 # dry season cor.test(y=DAT2[2:7, ]$Jack1inP, x=DAT2[2:7, ]$plant.model.J1P, method='pearson') # 0.9996 cor.test(y=DAT2[2:7, ]$Jack2inP, x=DAT2[2:7, ]$plant.model.J2P, method='pearson') # 0.9994 cor.test(y=DAT2[2:7, ]$Chao2P, x=DAT2[2:7, ]$plant.model.C2P, method='pearson') # 0.9997 options(digits=2) #### plot Yinggeling and Mengsong together #### (Fig. 2) # windows(width=11.69, height=3.9, pointsize=14) par(mfrow=c(1,3), mar=c(4.2,6,3.5,1.1)) # default margin = ~4.1 for y axis ## Yinggeling plot(Jack1inP~plant.model, data=dat[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='Non-parametric estimates (no. spp.)', col=c(2:6), pch=16, xlim=c(200,3500), ylim=c(200,3500),xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(500,1000,1500,2000,2500,3000,3500), label=c('500','1000',NA,'2000',NA,'5000',NA), tick=T) axis.break(1,2200, brw=0.015) axis(2, at=c(500,1000,1500,2000,2500,3000,3500), label=c('500','1000',NA,'2000',NA,'5000',NA), tick=T) axis.break(2,2200, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model, data=dat[-1, ], col=c(2:6), pch=15) # square = Jack2inP points(Chao2P~plant.model, data=dat[-1, ], col=c(2:6), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model, data=dat[1, ]-2000, pch=16) points(Jack2inP~plant.model, data=dat[1, ]-2000, pch=15) points(Chao2P~plant.model, data=dat[1, ]-2000, pch=17) # add the taxa names xnames=c('Insecta','Diptera','Hemiptera','Hymenoptera','Lepidoptera') # no Coleoptera here text(x=c(4649-1650,1898+100,476+50,347,709+20), y=c(5045-2500,2015-100, 506-80,336-100,730-100), pos=4, srt=0, cex=0.8, labels=xnames, col=c(1,3:6)) text(x=669, y=909+100, pos=4, srt=70, cex=0.8, labels="Coleoptera", col=2) # add same-site prediction and location name text(x=1000, y=3450, as.expression(bquote(italic('Same-site prediction')))) text(x=600, y=3250, "Yinggeling") # add R square legend(1350, 450, legend=c(as.expression(bquote("Jackknife1"*italic('P')*',' ~ R^2 ~ "= 0.960")), as.expression(bquote("Jackknife2"*italic('P')*',' ~ R^2 ~ "= 0.963")), as.expression(bquote(" Chao2"*italic('P')*',' ~ R^2 ~ "= 0.945"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.6, y.intersp=1, cex=0.85) mtext(text='Fig. 2', side=3, at=-250, line=1.3) ## Mengsong_wet par(mar=c(4.2,5,3.5,2.1)) plot(Jack1inP~plant.model.J1P, data=DAT1[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(0,1800), ylim=c(0,1800),xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(1,1050, brw=0.015) axis(2, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(2,1050, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT1[1, ]-1800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT1[1, ]-1800, pch=15) points(Chao2P~plant.model.C2P, data=DAT1[1, ]-1800, pch=17) # add Psocoptera and Arachnida which are absent in Yinggeling text(x=c(100,182), y=c(94-50,177), pos=4, srt=0, cex=0.8, labels=c('Psocoptera','Arachnida'), col=c('grey50','gold3')) # add same-site prediction, location name and season text(x=440, y=1770, as.expression(bquote(italic('Same-site prediction')))) text(x=500, y=1670, "Mengsong: wet season") # add R square legend(1100, 130, legend=c(as.expression(bquote(~ R^2 ~ "= 0.998")), as.expression(bquote(~ R^2 ~ "= 0.996")), as.expression(bquote(~ R^2 ~ "= 0.994"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.6, y.intersp=1, cex=0.85) # Mengsong_dry par(mar=c(4.4,3.8,3.5,3.3)) plot(Jack1inP~plant.model.J1P, data=DAT2[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(0,1800), ylim=c(0,1800),xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(1,1100, brw=0.015) axis(2, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(2,1100, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT2[1, ]-1800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT2[1, ]-1800, pch=15) points(Chao2P~plant.model.C2P, data=DAT2[1, ]-1800, pch=17) # add Psocoptera and Arachnida which are absent in Yinggeling text(x=c(67,150), y=c(65-50,126), pos=4, srt=0, cex=0.8, labels=c('Psocoptera','Arachnida'), col=c('grey50','gold3')) # add same-site prediction, location name and season text(x=440, y=1770, as.expression(bquote(italic('Same-site prediction')))) text(x=490, y=1670, "Mengsong: dry season") # add R square legend(1100, 130, legend=c(as.expression(bquote(~ R^2 ~ "= 0.999")), as.expression(bquote(~ R^2 ~ "= 0.999")), as.expression(bquote(~ R^2 ~ "= 0.970"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.6, y.intersp=1, cex=0.85) par(mfrow=c(1,1)) ``` ##### __2. forests only (mature forest + regenerating forest) __ ```{r alpha_Mengsong_F_3_alternative_functions} ### Arachnida # Pearson correlation test plot(specnumber(MBCsp1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong_wet)", xlab="Plants", ylab="Arachnida") # no positive relationship plot(specnumber(MBCsp2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong_dry)", xlab="Plants", ylab="Arachnida") # no positive relationship cor.test(specnumber(MBCsp1f, MARGIN=1),specnumber(Plantf, MARGIN=1), method='pearson') # r = -0.12 cor.test(specnumber(MBCsp2f, MARGIN=1),specnumber(Plantf, MARGIN=1), method='pearson') # r = 0.00 # Plant model approach sac.plant <- specaccum(comm=Plantf, method="random", permutations=9999) sac.sp1 <- specaccum(comm=MBCsp1f, method="random", permutations=9999) sac.sp2 <- specaccum(comm=MBCsp2f, method="random", permutations=9999) plot(sac.sp1$richness ~ sac.plant$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.sp2$richness ~ sac.plant$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # # **you may need to remove the # before below commands and run the commands yourself # y1 <- sac.sp1$richness; y2 <- sac.sp2$richness # x <- sac.plant$richness # # curve.sp1 <- data.frame(x=x, y=y1) # curve.sp2 <- data.frame(x=x, y=y2) # # write.csv(curve.sp1, 'curve.sp1.forest.csv', row.names=F) # write.csv(curve.sp2, 'curve.sp2.forest.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read curve.sp1.forest.csv, curve.sp2.forest.csv into CurveExpert # scale x by 0.01 and y by 0.1 as suggested by CurveExpert ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.67583384893E+001 b = 4.65226889306E+001 c = 1.36500744195E-002 d = 1.28178834541E+000 # check the curve xx <- 1:1600 # max(x.plant) = 1501 yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # n <- 22 # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 7.88029192433E-001 # b = 1.14564495896E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -5.09359408689E-001 # b = 1.11147271208E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # estimate the plant species richness by non-parametric estimation acc.plant <- alpha.accum(comm=Plantf, func="nonparametric", runs=1) (x.plant <- acc.plant[22,c(10,11,14,15,18,19)]) # # predict the spider OTU richness from plant model y.sp1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the spider OTU richness by non-parametric estimation acc.sp1 <- alpha.accum(comm=MBCsp1f, func="nonparametric", runs=1) Y.sp1 <- acc.sp1[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.sp1/(y.sp1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.05 1.03 1.08 1.04 1.09 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.17256203920E+001 b = 2.15289992515E+001 c = 3.11367615097E-002 d = 1.27163037029E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.53440803231E-001 # b = 1.07129960916E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -2.62919321560E-001 # b = 1.01526556948E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the spider OTU richness from plant model y.sp2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the spider OTU richness by non-parametric estimation acc.sp2 <- alpha.accum(comm=MBCsp2f, func="nonparametric", runs=1) Y.sp2 <- acc.sp2[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.sp2/(y.sp2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 1.01 0.96 0.98 0.87 0.88 ### Insecta # Pearson correlation test plot(specnumber(MBCin1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Insecta") # no positive relationship plot(specnumber(MBCin2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Insecta") # no positive relationship cor.test(specnumber(MBCin1f, MARGIN=1),specnumber(Plantf, MARGIN=1), method='pearson') # r = -0.07 cor.test(specnumber(MBCin2f, MARGIN=1),specnumber(Plantf, MARGIN=1), method='pearson') # r = 0.29 # Plant model approach sac.in1 <- specaccum(MBCin1f, "random", permutations=9999) sac.in2 <- specaccum(MBCin2f, "random", permutations=9999) plot(sac.in1$richness ~ sac.plant$richness, xlab='Plants', ylab='Insect', main='Mengsong_wet') # clear relationship plot(sac.in2$richness ~ sac.plant$richness, xlab='Plants', ylab='Insect', main='Mengsong_dry') # clear relationship # # **you may need to remove the # before below commands and run the commands yourself # y1 <- sac.in1$richness; y2 <- sac.in2$richness # # curve.in1 <- data.frame(x=x, y=y1) # curve.in2 <- data.frame(x=x, y=y2) # # write.csv(curve.in1, 'curve.in1.forest.csv', row.names=F) # write.csv(curve.in2, 'curve.in2.forest.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read curve.in1.forest.csv, curve.in2.forest.csv into CurveExpert # scale x by 0.01 and y by 0.001 as suggested by CurveExpert ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.68028226519E+000 b = 4.59130590153E+000 c = 4.43804463534E-002 d = 1.16151974191E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 2.79593278432E-001 # b = 9.22361374089E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 7.22428419951E-002 # b = 2.30860238475E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the insect OTU richness from plant model y.in1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation acc.in1 <- alpha.accum(comm=MBCin1f, func="nonparametric", runs=1) Y.in1 <- acc.in1[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in1/(y.in1*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.03 1.03 1.05 0.98 1.00 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.46969578370E+000 b = 4.38393024472E+000 c = 5.35147929368E-002 d = 1.14898661258E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 3.15462700002E-001 # b = 8.99862139699E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 9.92969660932E-002 # b = 2.46595718374E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the insect OTU richness from plant model y.in2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation acc.in2 <- alpha.accum(comm=MBCin2f, func="nonparametric", runs=1) Y.in2 <- acc.in2[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in2/(y.in2*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 1.02 1.03 0.95 0.95 #### apply to Insecta orders #### # Pearson correlation test plot(specnumber(MBCcole1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Coleoptera") # no positive relationship plot(specnumber(MBCcole2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Coleoptera") # no positive relationship cor.test(specnumber(MBCcole1f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=-0.14 cor.test(specnumber(MBCcole2f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=0.11 plot(specnumber(MBCdi1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Diptera") # no positive relationship plot(specnumber(MBCdi2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Diptera") # positive relationship cor.test(specnumber(MBCdi1f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=0.14 cor.test(specnumber(MBCdi2f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=0.44 (p=0.04) plot(specnumber(MBChe1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Hemiptera") # no positive relationship plot(specnumber(MBChe2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Hemiptera") # no positive relationship cor.test(specnumber(MBChe1f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=-0.15 cor.test(specnumber(MBChe2f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=0.07 plot(specnumber(MBChy1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Hymenoptera") # no positive relationship plot(specnumber(MBChy2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Hymenoptera") # no positive relationship cor.test(specnumber(MBChy1f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=-0.26 cor.test(specnumber(MBChy2f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=-0.2 plot(specnumber(MBCle1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Lepidoptera") # no positive relationship plot(specnumber(MBCle2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Lepidoptera") # no positive relationship cor.test(specnumber(MBCle1f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=0.00 cor.test(specnumber(MBCle2f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=-0.12 (p=0.04) plot(specnumber(MBCps1f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Psocoptera") # no positive relationship plot(specnumber(MBCps2f, MARGIN=1)~specnumber(Plantf, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Psocoptera") # no positive relationship cor.test(specnumber(MBCps1f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=0.06 cor.test(specnumber(MBCps2f, MARGIN=1), specnumber(Plantf, MARGIN=1), method='p') # r=0.18 # Plant model approach sac.cole1 <- specaccum(MBCcole1f, "random", permutations=9999) sac.cole2 <- specaccum(MBCcole2f, "random", permutations=9999) sac.di1 <- specaccum(MBCdi1f, "random", permutations=9999) sac.di2 <- specaccum(MBCdi2f, "random", permutations=9999) sac.he1 <- specaccum(MBChe1f, "random", permutations=9999) sac.he2 <- specaccum(MBChe2f, "random", permutations=9999) sac.hy1 <- specaccum(MBChy1f, "random", permutations=9999) sac.hy2 <- specaccum(MBChy2f, "random", permutations=9999) sac.le1 <- specaccum(MBCle1f, "random", permutations=9999) sac.le2 <- specaccum(MBCle2f, "random", permutations=9999) sac.ps1 <- specaccum(MBCps1f, "random", permutations=9999) sac.ps2 <- specaccum(MBCps2f, "random", permutations=9999) plot(sac.cole1$richness ~ sac.plant$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.cole2$richness ~ sac.plant$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.di1$richness ~ sac.plant$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.di2$richness ~ sac.plant$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.he1$richness ~ sac.plant$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.he2$richness ~ sac.plant$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.hy1$richness ~ sac.plant$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.hy2$richness ~ sac.plant$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.le1$richness ~ sac.plant$richness, xlab='Plants', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.le2$richness ~ sac.plant$richness, xlab='Plants', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.ps1$richness ~ sac.plant$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.ps2$richness ~ sac.plant$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship #### Coleoptera #### # y1 <- sac.cole1$richness; y2 <- sac.cole2$richness # # curve.cole1 <- data.frame(x=x, y=y1) # curve.cole2 <- data.frame(x=x, y=y2) # # write.csv(curve.cole1, 'curve.cole1.forest.csv', row.names=F) # write.csv(curve.cole2, 'curve.cole2.forest.csv', row.names=F) # read curve.cole1.forest.csv, curve.cole2.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.94728910155E+001 b = 1.93334838991E+001 c = 1.52115644590E-002 d = 1.21180801948E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 3.83829312122E-001 # b = 1.05804438681E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -7.90319240622E-002 # b = 4.39557759186E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Coleoptera species richness from plant model y.cole1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1f, func="nonparametric", runs=1) Y.cole1 <- acc.cole1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole1/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.03 1.02 1.05 1.02 1.05 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.35096323243E+001 b = 1.33515265013E+001 c = 4.60498158216E-002 d = 1.14824185591E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 7.72907885507E-001 # b = 9.42362636042E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.42846766109E-001 # b = 6.72505469735E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Coleoptera species richness from plant model y.cole2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole2 <- alpha.accum(comm=MBCcole2f, func="nonparametric", runs=1) Y.cole2 <- acc.cole2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole2/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.00 0.97 0.98 0.90 0.90 #### Diptera #### # y1 <- sac.di1$richness; y2 <- sac.di2$richness # # curve.di1 <- data.frame(x=x, y=y1) # curve.di2 <- data.frame(x=x, y=y2) # # write.csv(curve.di1, 'curve.di1.forest.csv', row.names=F) # write.csv(curve.di2, 'curve.di2.forest.csv', row.names=F) # read curve.di1.forest.csv, curve.di2.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.99697819371E+000 b = 6.71612740873E+000 c = 7.23667261804E-002 d = 1.12201656250E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 7.40436904217E-001 # b = 7.94098847544E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 4.23072121499E-001 # b = 4.39636420396E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera species richness from plant model y.di1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Diptera species richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1f, func="nonparametric", runs=1) Y.di1 <- acc.di1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di1/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.03 1.04 1.05 0.97 0.97 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.56423386918E+000 b = 6.30394751771E+000 c = 8.57021108677E-002 d = 1.12894991704E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.01285911381E-001 # b = 7.81173409108E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 4.71808757793E-001 # b = 4.60747769278E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera species richness from plant model y.di2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Diptera species richness by non-parametric estimation acc.di2 <- alpha.accum(comm=MBCdi2f, func="nonparametric", runs=1) Y.di2 <- acc.di2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di2/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.02 1.02 1.03 0.95 0.94 #### Hemiptera #### # y1 <- sac.he1$richness; y2 <- sac.he2$richness # # curve.he1 <- data.frame(x=x, y=y1) # curve.he2 <- data.frame(x=x, y=y2) # # write.csv(curve.he1, 'curve.he1.forest.csv', row.names=F) # write.csv(curve.he2, 'curve.he2.forest.csv', row.names=F) # read curve.he1.forest.csv, curve.he2.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.69333006282E+001 b = 1.68168666833E+001 c = 2.27936715024E-002 d = 1.15365385041E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 4.71110562007E-001 # b = 1.01143258716E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -1.68503468195E-002 # b = 4.83764060073E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hemiptera species richness from plant model y.he1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1f, func="nonparametric", runs=1) Y.he1 <- acc.he1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he1/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.03 1.03 1.05 1.02 1.04 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.07535708802E+000 b = 7.96601333168E+000 c = 4.08630253864E-002 d = 1.17973080662E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 4.24181737069E-001 # b = 9.64474658263E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 5.03294043508E-002 # b = 3.89357630090E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hemiptera species richness from plant model y.he2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he2 <- alpha.accum(comm=MBChe2f, func="nonparametric", runs=1) Y.he2 <- acc.he2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he2/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.01 0.98 0.99 0.91 0.91 #### Hymenoptera #### # y1 <- sac.hy1$richness; y2 <- sac.hy2$richness # # curve.hy1 <- data.frame(x=x, y=y1) # curve.hy2 <- data.frame(x=x, y=y2) # # write.csv(curve.hy1, 'curve.hy1.forest.csv', row.names=F) # write.csv(curve.hy2, 'curve.hy2.forest.csv', row.names=F) # read curve.hy1.forest.csv, curve.hy2.forest.csv # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.13028722055E+000 b = 7.00771829953E+000 c = 7.02648150951E-002 d = 1.13343645176E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 6.37213034197E-001 # b = 8.66718834852E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.48652810083E-001 # b = 4.59220097767E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hymenoptera species richness from plant model y.hy1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1f, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy1/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.03 1.03 1.04 0.95 0.95 ### dry season ### # list candidates based on their ranks # Power Fit: y=ax^b # Coefficient Data: a = 4.89290614671E-001 b = 9.15024910177E-001 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 1.50085085100E+001 # b = 1.49342994204E+001 # c = 2.85464968081E-002 # d = 1.02519775861E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.37076722353E-001 # b = 3.96623162985E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Power minimal # # predict the Hymenoptera species richness from plant model y.hy2 <- a*(x.plant*0.01)^b # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy2 <- alpha.accum(comm=MBChy2f, func="nonparametric", runs=1) Y.hy2 <- acc.hy2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy2/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 0.99 1.01 1.00 0.99 0.98 #### Lepidoptera #### # y1 <- sac.le1$richness; y2 <- sac.le2$richness # # curve.le1 <- data.frame(x=x, y=y1) # curve.le2 <- data.frame(x=x, y=y2) # # write.csv(curve.le1, 'curve.le1.forest.csv', row.names=F) # write.csv(curve.le2, 'curve.le2.forest.csv', row.names=F) # read curve.le1.forest.csv, curve.le2.forest.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.27122204799E+001 b = 4.22326420650E+001 c = 2.01190814801E-002 d = 1.05504279645E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 4.65422646564E-001 # b = 8.79152681035E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.18353885329E+000 # b = 8.82655910269E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal (deltaAICc = -2, compared with linear) # # predict the Lepidoptera species richness from plant model y.le1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le1 <- alpha.accum(comm=MBCle1f, func="nonparametric", runs=1) Y.le1 <- acc.le1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le1/(y.le1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 0.97 0.95 0.93 0.87 0.85 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.31083278721E+002 b = 1.30461277202E+002 c = 5.51290247857E-003 d = 1.19890782647E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.07655258695E+000 # b = 1.01757935095E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -4.04147855548E-003 # b = 1.11159639007E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Lepidoptera species richness from plant model y.le2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le2 <- alpha.accum(comm=MBCle2f, func="nonparametric", runs=1) Y.le2 <- acc.le2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le2/(y.le2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 0.99 0.97 0.98 0.93 0.94 #### Psocoptera #### # y1 <- sac.ps1$richness; y2 <- sac.ps2$richness # # curve.ps1 <- data.frame(x=x, y=y1) # curve.ps2 <- data.frame(x=x, y=y2) # # write.csv(curve.ps1, 'curve.ps1.forest.csv', row.names=F) # write.csv(curve.ps2, 'curve.ps2.forest.csv', row.names=F) # read curve.ps1.forest.csv, curve.ps2.forest.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.89162632190E+000 b = 7.64485238546E+000 c = 1.47156933186E-001 d = 1.12316979464E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok, asymptote # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.53103192597E+000 # b = 6.92870889504E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.10325153968E+000 # b = 6.95151679007E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Psocoptera species richness from plant model y.ps1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps1 <- alpha.accum(comm=MBCps1f, func="nonparametric", runs=1) Y.ps1 <- acc.ps1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps1/(y.ps1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.00 0.90 0.90 0.89 0.88 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.06923082858E+000 b = 6.63345374252E+000 c = 1.25498731034E-001 d = 1.30988715263E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok, asymptote simlar as wet season curve (but appears earlier) # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.45339941358E+000 # b = 7.12948025105E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 9.94169602495E-001 # b = 6.99555108303E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Psocoptera species richness from plant model y.ps2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps2 <- alpha.accum(comm=MBCps2f, func="nonparametric", runs=1) Y.ps2 <- acc.ps2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps2/(y.ps2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.05 1.01 1.02 0.94 0.94 #### calculate the fitness #### DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in1[c(2,4,6)]*1000), Insect2=c(Y.in2[c(2,4,6)], y.in2[c(2,4,6)]*1000), Cole1=c(Y.cole1[c(2,4,6)], y.cole1[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole2[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di1[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di2[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he1[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he2[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy1[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy2[c(2,4,6)]*100), Le1=c(Y.le1[c(2,4,6)], y.le1[c(2,4,6)]*10), Le2=c(Y.le2[c(2,4,6)], y.le2[c(2,4,6)]*10), Ps1=c(Y.ps1[c(2,4,6)], y.ps1[c(2,4,6)]*10), Ps2=c(Y.ps2[c(2,4,6)], y.ps2[c(2,4,6)]*10), Spider1=c(Y.sp1[c(2,4,6)], y.sp1[c(2,4,6)]*10), Spider2=c(Y.sp2[c(2,4,6)], y.sp2[c(2,4,6)]*10), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C2P')) # only present P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9,11,13,15),] # wet season DAT2 <- DAT[c(2,4,6,8,10,12,14,16),] # dry season #### calculate the R^2 fitted to the y=x model #### options(digits=4) ### wet season ## Jack1inP yi <- DAT1[2:7, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9964 ## Jack2inP yi <- DAT1[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9911 ## Chao2P yi <- DAT1[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9921 ### dry season ## Jack1inP yi <- DAT2[2:7, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9995 ## Jack2inP yi <- DAT2[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9983 ## Chao2P yi <- DAT2[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9685 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[2:7, ]$Jack1inP, x=DAT1[2:7, ]$plant.model.J1P, method='pearson') # r=1 cor.test(y=DAT1[2:7, ]$Jack2inP, x=DAT1[2:7, ]$plant.model.J2P, method='pearson') # 0.9999 cor.test(y=DAT1[2:7, ]$Chao2P, x=DAT1[2:7, ]$plant.model.C2P, method='pearson') # 0.9971 # dry season cor.test(y=DAT2[2:7, ]$Jack1inP, x=DAT2[2:7, ]$plant.model.J1P, method='pearson') # 0.9998 cor.test(y=DAT2[2:7, ]$Jack2inP, x=DAT2[2:7, ]$plant.model.J2P, method='pearson') # 0.9993 cor.test(y=DAT2[2:7, ]$Chao2P, x=DAT2[2:7, ]$plant.model.C2P, method='pearson') # 0.9978 options(digits=2) #### plot together #### (Fig. S2a) ## DAT1: wet season # windows(width = 11.69, height = 6, pointsize=14) par(mfrow=c(1,2), mar=c(4.2,6,3.5,1)) # default margin = ~4.1 for y plot(Jack1inP~plant.model.J1P, data=DAT1[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='Non-parametric estimates (no. spp.)', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(70,2000), ylim=c(70,2000), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT1[1, ]-1600, pch=16) points(Jack2inP~plant.model.J2P, data=DAT1[1, ]-1600, pch=15) points(Chao2P~plant.model.C2P, data=DAT1[1, ]-1600, pch=17) text(x=430, y=2000, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=430, y=1900, labels='Forests: wet season', cex=0.8) xnames0=c('Insecta','Diptera','Hemiptera','Psocoptera','Arachnida') xnames70=c('Coleoptera','Hymenoptera','Lepidoptera') text(x=c(3104-1800,541,656+50,73+30,158+30), y=c(2847-1600,514,664,65-20,165-20), pos=4, srt=0, cex=0.7, labels=xnames0, col=c(1,3,4,'grey50','gold3')) # x:DAT1$plant.model.C2P, y:DAT1$Chao2P text(x=c(579,530-150,118-100), y=c(628+150,508+100,102+50), pos=4, srt=70, cex=0.7, labels=xnames70, col=c(2,5,6)) # x:DAT1$plant.model.C2P, y:DAT1$Chao2P legend(1000, 200, legend=c(as.expression(bquote("Jackknife1"*italic('P')*',' ~ R^2 ~ "= 0.996")), as.expression(bquote("Jackknife2"*italic('P')*',' ~ R^2 ~ "= 0.991")), as.expression(bquote(" Chao2"*italic('P')*',' ~ R^2 ~ "= 0.992"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.4, cex=0.7) # mtext(text='Fig. S2a', side=3, at=-300, line=1.5) ## DAT2: dry season par(mar=c(4.2,4,3.5,3)) plot(Jack1inP~plant.model.J1P, data=DAT2[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(70,2000), ylim=c(70,2000), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT2[1, ]-1600, pch=16) points(Jack2inP~plant.model.J2P, data=DAT2[1, ]-1600, pch=15) points(Chao2P~plant.model.C2P, data=DAT2[1, ]-1600, pch=17) text(x=430, y=2000, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=430, y=1900, labels='Forests: dry season', cex=0.8) legend(1400, 180, legend=c(as.expression(bquote(~ R^2 ~ "= 0.999")), as.expression(bquote(~ R^2 ~ "= 0.998")), as.expression(bquote(~ R^2 ~ "= 0.969"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.5, cex=0.7) par(mfrow=c(1,1)) ``` ##### __3. open land only__ ```{r alpha_Mengsong_OL_3_alternative_functions} ### Arachnida not included due to the low sample size (<50) ### Insecta # Pearson correlation test plot(specnumber(MBCin1ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Insects") # ? plot(specnumber(MBCin2ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Insects") # no positive relationship cor.test(specnumber(MBCin1ol, MARGIN=1), specnumber(Plantol, MARGIN=1), method='p') # r=0.53 (p=0.3) cor.test(specnumber(MBCin2ol, MARGIN=1), specnumber(Plantol, MARGIN=1), method='p') # r=0.16 # Plant model approach sac.plant <- specaccum(Plantol, "random", permutations=100) # keep default permutations (100), as 9999 (or even 999) > set of all permutations sac.in1 <- specaccum(MBCin1ol, "random", permutations=100) sac.in2 <- specaccum(MBCin2ol, "random", permutations=100) plot(sac.in1$richness ~ sac.plant$richness, xlab='Plants', ylab='Insect', main='Mengsong_wet') # clear relationship plot(sac.in2$richness ~ sac.plant$richness, xlab='Plants', ylab='Insect', main='Mengsong_dry') # clear relationship # # **you may need to remove the # before below commands and run the commands yourself # # y1 <- sac.in1$richness; y2 <- sac.in2$richness # # x <- sac.plant$richness # # # # curve.in1 <- data.frame(x=x, y=y1) # # curve.in2 <- data.frame(x=x, y=y2) # # write.csv(curve.in1, 'curve.in1.ol.csv', row.names=F) # write.csv(curve.in2, 'curve.in2.ol.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read curve.in1.ol.csv, curve.in2.ol.csv into CurveExpert # scale x and y by 0.01 as suggested by CurveExpert ### wet season ### # list candidates based on their ranks # Power Fit: y=ax^b # Coefficient Data: a = 5.86628004431E+000 b = 8.15522676588E-001 # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # n <- 6 # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 1.66161747932E+001 # b = 1.51220308373E+001 # c = 3.37495058301E-001 # d = 1.36880218347E+000 # # # check the curve # xx <- 1:657 # max(x.plant) = 657 # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok, asymptote # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.14970375192E+000 # b = 4.62962135948E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal # # **you may need to remove the # before above commands and run the commands yourself # # estimate the plant species richness by non-parametric estimation acc.plant <- alpha.accum(comm=Plantol, func="nonparametric", runs=1) (x.plant <- acc.plant[6,c(10,11,14,15,18,19)]) # # predict the insect OTU richness from plant model y.in1 <- a*(x.plant*0.01)^b # # estimate the insect OTU richness by non-parametric estimation acc.in1 <- alpha.accum(comm=MBCin1ol, func="nonparametric", runs=1) Y.in1 <- acc.in1[6,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in1/(y.in1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 0.99 1.03 1.00 0.98 0.95 ### dry season ### # list candidates based on their ranks # Power Fit: y=ax^b # Coefficient Data: a = 5.96011575361E+000 b = 8.33750557616E-001 # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 1.95151328010E+001 # b = 1.81929804472E+001 # c = 2.91456453984E-001 # d = 1.29080197786E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.05833930413E+000 # b = 4.82153928129E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the insect OTU richness from plant model y.in2 <- a*(x.plant*0.01)^b # # estimate the insect OTU richness by non-parametric estimation acc.in2 <- alpha.accum(comm=MBCin2ol, func="nonparametric", runs=1) Y.in2 <- acc.in2[6,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in2/(y.in2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 0.97 1.01 0.97 0.94 0.91 #### apply to Insecta orders #### # Pearson correlation test plot(specnumber(MBCcole1ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Coleoptera") # no positive relationship plot(specnumber(MBCcole2ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Coleoptera") # no positive relationship cor.test(specnumber(MBCcole1ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.56 (p=0.2) cor.test(specnumber(MBCcole2ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.28 plot(specnumber(MBCdi1ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Diptera") # no positive relationship plot(specnumber(MBCdi2ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Diptera") # no positive relationship cor.test(specnumber(MBCdi1ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.31 cor.test(specnumber(MBCdi2ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.01 plot(specnumber(MBChe1ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Hemiptera") # no positive relationship plot(specnumber(MBChe2ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Hemiptera") # positive relationship cor.test(specnumber(MBChe1ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.49 (p=0.3) cor.test(specnumber(MBChe2ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.89 (p=0.02)! plot(specnumber(MBChy1ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Hymenoptera") # positive relationship if omitting the bottom point plot(specnumber(MBChy2ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Hymenoptera") # no positive relationship cor.test(specnumber(MBChy1ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.60 (p=0.2) cor.test(specnumber(MBChy2ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=-0.37 plot(specnumber(MBCle1ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Lepidoptera") # no positive relationship plot(specnumber(MBCle2ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Lepidoptera") # no positive relationship cor.test(specnumber(MBCle1ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.73 (p=0.1) cor.test(specnumber(MBCle2ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=-0.16 plot(specnumber(MBCps1ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Plants", ylab="Psocoptera") # no positive relationship plot(specnumber(MBCps2ol, MARGIN=1)~specnumber(Plantol, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Plants", ylab="Psocoptera") # no positive relationship cor.test(specnumber(MBCps1ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.22 cor.test(specnumber(MBCps2ol, MARGIN=1),specnumber(Plantol, MARGIN=1), method='p') # r=0.17 # Plant model approach sac.cole1 <- specaccum(MBCcole1ol, "random") sac.cole2 <- specaccum(MBCcole2ol, "random") sac.di1 <- specaccum(MBCdi1ol, "random") sac.di2 <- specaccum(MBCdi2ol, "random") sac.he1 <- specaccum(MBChe1ol, "random") sac.he2 <- specaccum(MBChe2ol, "random") sac.hy1 <- specaccum(MBChy1ol, "random") sac.hy2 <- specaccum(MBChy2ol, "random") sac.le1 <- specaccum(MBCle1ol, "random") sac.le2 <- specaccum(MBCle2ol, "random") sac.ps1 <- specaccum(MBCps1ol, "random") sac.ps2 <- specaccum(MBCps2ol, "random") plot(sac.cole1$richness ~ sac.plant$richness, xlab='Plants', ylab='Coleoptera', main='Mengsong_wet') # clear relationship plot(sac.cole2$richness ~ sac.plant$richness, xlab='Plants', ylab='Coleoptera', main='Mengsong_dry') # clear relationship plot(sac.di1$richness ~ sac.plant$richness, xlab='Plants', ylab='Diptera', main='Mengsong_wet') # clear relationship plot(sac.di2$richness ~ sac.plant$richness, xlab='Plants', ylab='Diptera', main='Mengsong_dry') # clear relationship plot(sac.he1$richness ~ sac.plant$richness, xlab='Plants', ylab='Hemiptera', main='Mengsong_wet') # clear relationship plot(sac.he2$richness ~ sac.plant$richness, xlab='Plants', ylab='Hemiptera', main='Mengsong_dry') # clear relationship plot(sac.hy1$richness ~ sac.plant$richness, xlab='Plants', ylab='Hymenoptera', main='Mengsong_wet') # clear relationship plot(sac.hy2$richness ~ sac.plant$richness, xlab='Plants', ylab='Hymenoptera', main='Mengsong_dry') # clear relationship plot(sac.le1$richness ~ sac.plant$richness, xlab='Plants', ylab='Lepidoptera', main='Mengsong_wet') # clear relationship plot(sac.le2$richness ~ sac.plant$richness, xlab='Plants', ylab='Lepidoptera', main='Mengsong_dry') # clear relationship plot(sac.ps1$richness ~ sac.plant$richness, xlab='Plants', ylab='Psocoptera', main='Mengsong_wet') # clear relationship plot(sac.ps2$richness ~ sac.plant$richness, xlab='Plants', ylab='Psocoptera', main='Mengsong_dry') # clear relationship #### Coleoptera #### # y1 <- sac.cole1$richness; y2 <- sac.cole2$richness # # curve.cole1 <- data.frame(x=x, y=y1) # curve.cole2 <- data.frame(x=x, y=y2) # # write.csv(curve.cole1, 'curve.cole1.ol.csv', row.names=F) # write.csv(curve.cole2, 'curve.cole2.ol.csv', row.names=F) # read curve.cole1.csv, curve.cole2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Linear Fit: y=a+bx # Coefficient Data: a = 6.46971328337E-002 b = 6.91791998987E-001 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 7.59923782814E-001 # b = 9.26716111291E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 4.19288806558E+000 # b = 4.03128106247E+000 # c = 1.58225659202E-001 # d = 1.28129719152E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # linear minimal # # predict the Coleoptera species richness from plant model y.cole1 <- a+b*x.plant*0.01 # # estimate the Coleoptera species richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1ol, func="nonparametric", runs=1) Y.cole1 <- acc.cole1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole1/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 0.95 0.98 0.94 0.93 0.89 ### dry season ### # list candidates based on their ranks # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 5.57933655290E+000 # b = 5.26889677431E+000 # c = 2.53608348232E-001 # d = 1.39322052164E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 1.50334801764E+000 b = 9.36732034615E-001 # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.04057451773E-001 # b = 1.39099755306E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal (deltaAICc = -2.1 compared with linear) # # predict the Coleoptera species richness from plant model y.cole2 <- a*(x.plant*0.01)^b # # estimate the Coleoptera species richness by non-parametric estimation acc.cole2 <- alpha.accum(comm=MBCcole2ol, func="nonparametric", runs=1) Y.cole2 <- acc.cole2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole2/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.98 0.94 0.97 0.92 0.86 0.82 #### Diptera #### # y1 <- sac.di1$richness; y2 <- sac.di2$richness # # curve.di1 <- data.frame(x=x, y=y1) # curve.di2 <- data.frame(x=x, y=y2) # # write.csv(curve.di1, 'curve.di1.ol.csv', row.names=F) # write.csv(curve.di2, 'curve.di2.ol.csv', row.names=F) # read curve.di1.ol.csv, curve.di2.ol.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 4.22658585318E+000 # b = 3.80992824956E+000 # c = 2.70388004825E-001 # d = 1.26820060764E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok, asymptote but not early # # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 1.33528415133E+000 b = 7.43058791219E-001 # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 3.66194549949E-001 # b = 9.45730993973E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal (deltaAICc = -2.4 compared with linear) # # predict the Diptera species richness from plant model y.di1 <- a*(x.plant*0.01)^b # # estimate the Diptera species richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1ol, func="nonparametric", runs=1) Y.di1 <- acc.di1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di1/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 0.97 1.03 0.98 0.95 0.90 ### dry season ### # list candidates based on their ranks # Power Fit: y=ax^b # Coefficient Data: a = 1.21423662609E+000 b = 6.81486045396E-001 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 3.17205792929E+000 # b = 2.88533288256E+000 # c = 3.86559755750E-001 # d = 1.13449647812E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok, asymptote # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 4.04038886213E-001 # b = 7.84040054189E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal # # predict the Diptera species richness from plant model y.di2 <- a*(x.plant*0.01)^b # # estimate the Diptera species richness by non-parametric estimation acc.di2 <- alpha.accum(comm=MBCdi2ol, func="nonparametric", runs=1) Y.di2 <- acc.di2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di2/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 0.95 1.02 0.95 0.91 0.85 #### Hemiptera #### # y1 <- sac.he1$richness; y2 <- sac.he2$richness # # curve.he1 <- data.frame(x=x, y=y1) # curve.he2 <- data.frame(x=x, y=y2) # # write.csv(curve.he1, 'curve.he1.ol.csv', row.names=F) # write.csv(curve.he2, 'curve.he2.ol.csv', row.names=F) # read curve.he1.ol.csv, curve.he2.ol.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 5.12974295297E+000 # b = 5.08892153577E+000 # c = 2.91907013402E-001 # d = 9.83246494850E-001 # # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 1.32087203064E+000 b = 7.91523196882E-001 # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.86536856175E-001 # b = 1.01101503970E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal # # predict the Hemiptera species richness from plant model y.he1 <- a*(x.plant*0.01)^b # # estimate the Hemiptera species richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1ol, func="nonparametric", runs=1) Y.he1 <- acc.he1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he1/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 0.91 0.96 0.89 0.80 0.74 ### dry season ### # list candidates based on their ranks # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 2.86981677355E+000 # b = 2.53987883845E+000 # c = 3.45518570990E-001 # d = 1.48404115269E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # asymptote from 500, that's to say 500 and 650 plant species harbour nearly same number of Hemiptera species, which sounds not sensible. Morover, the curve of wet season data is different. Thus, this model seems to be dropped. # # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 1.08482222766E+000 b = 8.17205327705E-001 # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.12112349211E-001 # b = 8.57243105289E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal # # predict the Hemiptera species richness from plant model y.he2 <- a*(x.plant*0.01)^b # # estimate the Hemiptera species richness by non-parametric estimation acc.he2 <- alpha.accum(comm=MBChe2ol, func="nonparametric", runs=1) Y.he2 <- acc.he2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he2/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 0.95 1.00 0.95 0.90 0.85 #### Hymenoptera #### # y1 <- sac.hy1$richness; y2 <- sac.hy2$richness # # curve.hy1 <- data.frame(x=x, y=y1) # curve.hy2 <- data.frame(x=x, y=y2) # # write.csv(curve.hy1, 'curve.hy1.ol.csv', row.names=F) # write.csv(curve.hy2, 'curve.hy2.ol.csv', row.names=F) # read curve.hy1.ol.csv, curve.hy2.ol.csv into CurveExpert # scale x and y 0.01 ### wet season ### # list candidates based on their ranks # Power Fit: y=ax^b # Coefficient Data: a = 1.19440404175E+000 b = 8.81370156845E-001 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.55180069957E-001 # b = 1.02811471946E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 4.81975453409E+000 # b = 4.56359586350E+000 # c = 2.27347448541E-001 # d = 1.28833010101E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal (deltaAICc = -0.9 compared with linear) # # predict the Hymenoptera species richness from plant model y.hy1 <- a*(x.plant*0.01)^b # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1ol, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy1/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.06 1.07 1.09 1.18 1.20 ### dry season ### # list candidates based on their ranks # Power Fit: y=ax^b # Coefficient Data: a = 9.94692952672E-001 b = 8.74636214198E-001 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 4.27393380392E+000 # b = 4.08539974096E+000 # c = 2.17773343751E-001 # d = 1.23086329689E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.35496746559E-001 # b = 8.49164353287E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # power minimal # # predict the Hymenoptera species richness from plant model y.hy2 <- a*(x.plant*0.01)^b # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy2 <- alpha.accum(comm=MBChy2ol, func="nonparametric", runs=1) Y.hy2 <- acc.hy2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy2/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 0.99 1.03 1.01 1.04 1.02 #### Lepidoptera #### not included due to the low sample size (<50) #### Psocoptera #### not included due to the low sample size (<50) #### calculate the fitness #### DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in1[c(2,4,6)]*100), Insect2=c(Y.in2[c(2,4,6)], y.in2[c(2,4,6)]*100), Cole1=c(Y.cole1[c(2,4,6)], y.cole1[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole2[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di1[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di2[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he1[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he2[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy1[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy2[c(2,4,6)]*100), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C2P')) # only present P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9),] # wet season DAT2 <- DAT[c(2,4,6,8,10),] # dry season #### calculate the R^2 fitted to the y=x model #### options(digits=4) ### wet season ## Jack1inP yi <- DAT1[-1, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.8277 ## Jack2inP yi <- DAT1[-1, ]$Jack2inP ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.7440 ## Chao2P yi <- DAT1[-1, ]$Chao2P ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.4101 ### dry season ## Jack1inP yi <- DAT2[-1, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9511 ## Jack2inP yi <- DAT2[-1, ]$Jack2inP ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9288 ## Chao2P yi <- DAT2[-1, ]$Chao2P ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.4963 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[-1, ]$Jack1inP, x=DAT1[-1, ]$plant.model.J1P, method='pearson') # r=0.9315 cor.test(y=DAT1[-1, ]$Jack2inP, x=DAT1[-1, ]$plant.model.J2P, method='pearson') # 0.8943 cor.test(y=DAT1[-1, ]$Chao2P, x=DAT1[-1, ]$plant.model.C2P, method='pearson') # 0.7387 # dry season cor.test(y=DAT2[-1, ]$Jack1inP, x=DAT2[-1, ]$plant.model.J1P, method='pearson') # 0.9977 cor.test(y=DAT2[-1, ]$Jack2inP, x=DAT2[-1, ]$plant.model.J2P, method='pearson') # 0.9956 cor.test(y=DAT2[-1, ]$Chao2P, x=DAT2[-1, ]$plant.model.C2P, method='pearson') # 0.9584 options(digits=2) #### plot together #### (Fig. S2b) ## DAT1: wet season # windows(width = 11.69, height = 6, pointsize=14) par(mfrow=c(1,2), mar=c(4.2,6,3.5,1)) # default margin = ~4.1 for y plot(Jack1inP~plant.model.J1P, data=DAT1[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='Non-parametric estimates (no. spp.)', col=2:5, pch=16, xlim=c(300,2100), ylim=c(300,2100), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT1[-1, ], col=2:5, pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT1[-1, ], col=2:5, pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT1[1, ]-800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT1[1, ]-800, pch=15) points(Chao2P~plant.model.C2P, data=DAT1[1, ]-800, pch=17) text(x=630, y=2090, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=680, y=1990, labels='Open land: wet season', cex=0.8) xnames=c('Insecta','Coleoptera','Diptera','Hemiptera','Hymenoptera') text(x=c(2469-900+100,409,495+70,533+80,564+100), y=c(2474-900-100,384-50,484+50,472-40,614+30), pos=4, srt=0, cex=0.7, labels=xnames, col=1:5) # x:DAT1$plant.model.J2P, y:DAT1$Jack2inP legend(1160, 420, legend=c(as.expression(bquote("Jackknife1"*italic('P')*',' ~ R^2 ~ "= 0.828")), as.expression(bquote("Jackknife2"*italic('P')*',' ~ R^2 ~ "= 0.744")), as.expression(bquote(" Chao2"*italic('P')*',' ~ R^2 ~ "= 0.410"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.4, cex=0.7) # mtext(text='Fig. S2b', side=3, at=-50, line=1.5) ## DAT2: dry season par(mar=c(4.2,4,3.5,3)) plot(Jack1inP~plant.model.J1P, data=DAT2[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=2:5, pch=16, xlim=c(300,2100), ylim=c(300,2100), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT2[-1, ], col=2:5, pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT2[-1, ], col=2:5, pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT2[1, ]-800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT2[1, ]-800, pch=15) points(Chao2P~plant.model.C2P, data=DAT2[1, ]-800, pch=17) text(x=630, y=2090, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=680, y=1990, labels='Open land: dry season', cex=0.8) legend(1540, 400, legend=c(as.expression(bquote(~ R^2 ~ "= 0.951")), as.expression(bquote(~ R^2 ~ "= 0.929")), as.expression(bquote(~ R^2 ~ "= 0.496"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.5, cex=0.7) par(mfrow=c(1,1)) ``` ##### Use tree data only to build the plant model in Mengsong forests The scientific question: are there differences between vascular plant data and tree data in building the plant models? As there are no/few trees growing open lands, such test is restricted in the forests. ```{r alpha_Mengsong_F_tree_3_alternative_functions} # # read the tree data n=28 Tree_MS <- read.csv("MS_Tree_output.csv", header=TRUE, row.names = 1) # 390 species head(Tree_MS) str(Tree_MS) # only keep the plots in the forests, as there are no/few trees in open lands row.names(MSenv[MSenv$HAB=='OL', ]); row.names(Tree_MS) Treef <- Tree_MS[-c(8,12,19,23), ] # f = forest row.names(Treef); row.names(MBCin1f) # same row names Treef <- Treef[ ,specnumber(Treef, MARGIN=2)>0] # remove empty columns, 383 species and only 7 species are unique in open lands ### Arachnida # Pearson correlation test plot(specnumber(MBCsp1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong_wet)", xlab="Trees", ylab="Arachnida") # no positive relationship plot(specnumber(MBCsp2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong_dry)", xlab="Trees", ylab="Arachnida") # no positive relationship cor.test(specnumber(MBCsp1f, MARGIN=1),specnumber(Treef, MARGIN=1), method='pearson') # r = -0.17 cor.test(specnumber(MBCsp2f, MARGIN=1),specnumber(Treef, MARGIN=1), method='pearson') # r = -0.06 # Plant model approach sac.tree <- specaccum(comm=Treef, method="random", permutations=9999) sac.sp1 <- specaccum(comm=MBCsp1f, method="random", permutations=9999) sac.sp2 <- specaccum(comm=MBCsp2f, method="random", permutations=9999) plot(sac.sp1$richness ~ sac.tree$richness, xlab='Trees', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.sp2$richness ~ sac.tree$richness, xlab='Trees', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # # **you may need to remove the #s before below commands and run them yourself # y1 <- sac.sp1$richness; y2 <- sac.sp2$richness # x <- sac.tree$richness # # curve.sp1 <- data.frame(x=x, y=y1) # curve.sp2 <- data.frame(x=x, y=y2) # # write.csv(curve.sp1, 'curve.sp1.tree.forest.csv', row.names=F) # write.csv(curve.sp2, 'curve.sp2.tree.forest.csv', row.names=F) # read curve.sp1.tree.forest.csv, curve.sp2.tree.forest.csv into CurveExpert # scale x by 0.01 and y by 0.1 as suggested by CurveExpert ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.11774589562E+002 b = 1.11533929178E+002 c = 1.17920150639E-002 d = 1.33707455198E+000 # check the curve xx <- 1:709 # max(x.tree) = 709 yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # **you may need to remove the #s before above commands and run them yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # n <- 22 # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.50254129928E+000 # b = 1.23296096645E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -7.98988964477E-001 # b = 2.22476726708E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the #s before above commands and run them yourself # # estimate the tree species richness by non-parametric estimation acc.tree <- alpha.accum(comm=Treef, func="nonparametric", runs=1) (x.tree <- acc.tree[22,c(10,11,14,15,18,19)]) # use tree incidence estimator, as we intend to compare the results with plant data, which also implies incidence estimator. The results using tree abundance estimator are still ok. # (x.tree.ab <- acc.tree[22,c(8,9,12,13,16,17)]) # use tree abundance estimator # predict the spider OTU richness from plant model y.sp1 <- a-b*exp(-c*(x.tree*0.01)^d) # y.sp1.ab <- a-b*exp(-c*(x.tree.ab*0.01)^d) # # estimate the spider OTU richness by non-parametric estimation acc.sp1 <- alpha.accum(comm=MBCsp1f, func="nonparametric", runs=1) Y.sp1 <- acc.sp1[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.sp1/(y.sp1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 1.04 1.02 1.07 1.08 1.13 # Y.sp1/(y.sp1.ab*10) # # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # # 1.10 1.27 1.17 1.35 1.22 1.41 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.25069811091E+001 b = 2.22543578879E+001 c = 5.92789433201E-002 d = 1.38709119527E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # **you may need to remove the #s before below commands and run them yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.55080843177E+000 # b = 1.15820489352E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -5.50751715943E-001 # b = 2.03962900177E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the #s before above commands and run them yourself # # predict the spider OTU richness from plant model y.sp2 <- a-b*exp(-c*(x.tree*0.01)^d) # y.sp2.ab <- a-b*exp(-c*(x.tree.ab*0.01)^d) # # estimate the spider OTU richness by non-parametric estimation acc.sp2 <- alpha.accum(comm=MBCsp2f, func="nonparametric", runs=1) Y.sp2 <- acc.sp2[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.sp2/(y.sp2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 1.01 0.96 0.99 0.90 0.92 # Y.sp2/(y.sp2.ab*10) # # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # # 1.08 1.18 1.07 1.17 0.99 1.09 ### Insecta # Pearson correlation test plot(specnumber(MBCin1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Trees", ylab="Insecta") # no positive relationship plot(specnumber(MBCin2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Trees", ylab="Insecta") # no clear relationship cor.test(specnumber(MBCin1f, MARGIN=1),specnumber(Treef, MARGIN=1), method='pearson') # r = 0.02 cor.test(specnumber(MBCin2f, MARGIN=1),specnumber(Treef, MARGIN=1), method='pearson') # r = 0.35 # Plant model approach sac.in1<- specaccum(MBCin1f, "random", permutations=9999) sac.in2<- specaccum(MBCin2f, "random", permutations=9999) plot(sac.in1$richness ~ sac.tree$richness, xlab='Trees', ylab='Insect', main='Mengsong_wet') # clear relationship plot(sac.in2$richness ~ sac.tree$richness, xlab='Trees', ylab='Insect', main='Mengsong_dry') # clear relationship # # **you may need to remove the # before below commands and run the commands yourself # y1 <- sac.in1$richness; y2 <- sac.in2$richness # x <- sac.tree$richness # # curve.in1 <- data.frame(x=x, y=y1) # curve.in2 <- data.frame(x=x, y=y2) # # write.csv(curve.in1, 'curve.in1.tree.forest.csv', row.names=F) # write.csv(curve.in2, 'curve.in2.tree.forest.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read curve.in1.tree.forest.csv, curve.in2.tree.forest.csv into CurveExpert # scale x by 0.01 and y by 0.001 as suggested by CurveExpert ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.85058735473E+000 b = 4.74847313246E+000 c = 8.00594849496E-002 d = 1.26059350117E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 7.48269570746E-003 # b = 4.63736624332E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 4.69530740498E-001 # b = 9.93773174980E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the # before above commands and run the commands yourself # # predict the insect OTU richness from plant model y.in1 <- a-b*exp(-c*(x.tree*0.01)^d) # y.in1.ab <- a-b*exp(-c*(x.tree.ab*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation acc.in1 <- alpha.accum(comm=MBCin1f, func="nonparametric", runs=1) Y.in1 <- acc.in1[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in1/(y.in1*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.04 1.04 1.07 1.02 1.04 Y.in1/(y.in1.ab*1000) # # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # # 1.10 1.19 1.14 1.24 1.11 1.20 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.71028697916E+000 b = 4.61277769118E+000 c = 9.51638345461E-002 d = 1.23541444078E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx) # ok # # **you may need to remove the #s before below commands and run them yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 5.24435416388E-001 # b = 9.67478826761E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 3.16542249023E-002 # b = 4.94953789448E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # **you may need to remove the #s before above commands and run them yourself # # predict the insect OTU richness from plant model y.in2 <- a-b*exp(-c*(x.tree*0.01)^d) # y.in2.ab <- a-b*exp(-c*(x.tree.ab*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation acc.in2 <- alpha.accum(comm=MBCin2f, func="nonparametric", runs=1) Y.in2 <- acc.in2[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in2/(y.in2*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.03 1.02 1.04 0.97 0.98 # Y.in2/(y.in2.ab*1000) # # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # # 1.09 1.16 1.11 1.19 1.06 1.13 #### apply to Insecta orders #### # Pearson correlation test plot(specnumber(MBCcole1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Trees", ylab="Coleoptera") # no positive relationship plot(specnumber(MBCcole2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Trees", ylab="Coleoptera") # no positive relationship cor.test(specnumber(MBCcole1f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.00 cor.test(specnumber(MBCcole2f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.09 plot(specnumber(MBCdi1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Trees", ylab="Diptera") # no positive relationship plot(specnumber(MBCdi2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Trees", ylab="Diptera") # positive relationship? cor.test(specnumber(MBCdi1f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.23 cor.test(specnumber(MBCdi2f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.46 (p=0.03) plot(specnumber(MBChe1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Trees", ylab="Hemiptera") # no positive relationship plot(specnumber(MBChe2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Trees", ylab="Hemiptera") # no positive relationship cor.test(specnumber(MBChe1f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=-0.1 cor.test(specnumber(MBChe2f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.12 plot(specnumber(MBChy1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Trees", ylab="Hymenoptera") # no positive relationship plot(specnumber(MBChy2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Trees", ylab="Hymenoptera") # no positive relationship cor.test(specnumber(MBChy1f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=-0.17 cor.test(specnumber(MBChy2f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=-0.07 plot(specnumber(MBCle1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Trees", ylab="Lepidoptera") # no positive relationship plot(specnumber(MBCle2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Trees", ylab="Lepidoptera") # no positive relationship cor.test(specnumber(MBCle1f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.12 cor.test(specnumber(MBCle2f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.02 plot(specnumber(MBCps1f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:wet)", xlab="Trees", ylab="Psocoptera") # no positive relationship plot(specnumber(MBCps2f, MARGIN=1)~specnumber(Treef, MARGIN=1), main="Species richness comparison at plot scale (Mengsong:dry)", xlab="Trees", ylab="Psocoptera") # no positive relationship cor.test(specnumber(MBCps1f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=-0.07 cor.test(specnumber(MBCps2f, MARGIN=1), specnumber(Treef, MARGIN=1), method='p') # r=0.19 # Plant model approach sac.cole1 <- specaccum(MBCcole1f, "random", permutations=9999) sac.cole2 <- specaccum(MBCcole2f, "random", permutations=9999) sac.di1 <- specaccum(MBCdi1f, "random", permutations=9999) sac.di2 <- specaccum(MBCdi2f, "random", permutations=9999) sac.he1 <- specaccum(MBChe1f, "random", permutations=9999) sac.he2 <- specaccum(MBChe2f, "random", permutations=9999) sac.hy1 <- specaccum(MBChy1f, "random", permutations=9999) sac.hy2 <- specaccum(MBChy2f, "random", permutations=9999) sac.le1 <- specaccum(MBCle1f, "random", permutations=9999) sac.le2 <- specaccum(MBCle2f, "random", permutations=9999) sac.ps1 <- specaccum(MBCps1f, "random", permutations=9999) sac.ps2 <- specaccum(MBCps2f, "random", permutations=9999) plot(sac.cole1$richness ~ sac.tree$richness, xlab='Trees', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.cole2$richness ~ sac.tree$richness, xlab='Trees', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.di1$richness ~ sac.tree$richness, xlab='Trees', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.di2$richness ~ sac.tree$richness, xlab='Trees', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.he1$richness ~ sac.tree$richness, xlab='Trees', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.he2$richness ~ sac.tree$richness, xlab='Trees', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.hy1$richness ~ sac.tree$richness, xlab='Trees', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.hy2$richness ~ sac.tree$richness, xlab='Trees', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.le1$richness ~ sac.tree$richness, xlab='Trees', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.le2$richness ~ sac.tree$richness, xlab='Trees', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship plot(sac.ps1$richness ~ sac.tree$richness, xlab='Trees', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship plot(sac.ps2$richness ~ sac.tree$richness, xlab='Trees', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship #### Coleoptera #### # y1 <- sac.cole1$richness; y2 <- sac.cole2$richness # # curve.cole1 <- data.frame(x=x, y=y1) # curve.cole2 <- data.frame(x=x, y=y2) # # write.csv(curve.cole1, 'curve.cole1.tree.forest.csv', row.names=F) # write.csv(curve.cole2, 'curve.cole2.tree.forest.csv', row.names=F) # read curve.cole1.tree.forest.csv, curve.cole2.tree.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.08302045646E+001 b = 2.06629076721E+001 c = 2.70392393303E-002 d = 1.32396038008E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 6.94743451809E-001 # b = 1.14054118569E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -1.97891563406E-001 # b = 8.80850268624E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Coleoptera species richness from plant model y.cole1 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1f, func="nonparametric", runs=1) Y.cole1 <- acc.cole1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole1/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.05 1.03 1.07 1.07 1.11 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.23427545999E+001 b = 1.21097339612E+001 c = 9.06327610874E-002 d = 1.29295392547E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -5.35547500763E-002 # b = 1.35347366290E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.30842896425E+000 # b = 1.01816265404E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Coleoptera species richness from plant model y.cole2 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole2 <- alpha.accum(comm=MBCcole2f, func="nonparametric", runs=1) Y.cole2 <- acc.cole2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole2/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.02 0.99 1.01 0.94 0.95 #### Diptera #### # y1 <- sac.di1$richness; y2 <- sac.di2$richness # # curve.di1 <- data.frame(x=x, y=y1) # curve.di2 <- data.frame(x=x, y=y2) # # write.csv(curve.di1, 'curve.di1.tree.forest.csv', row.names=F) # write.csv(curve.di2, 'curve.di2.tree.forest.csv', row.names=F) # read curve.di1.tree.forest.csv, curve.di2.tree.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.13038093514E+000 b = 6.81634421971E+000 c = 1.28909640522E-001 d = 1.22299755136E+000 yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.15458094230E+000 # b = 8.56947290703E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.92884676552E-001 # b = 8.84964050916E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera species richness from plant model y.di1 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Diptera species richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1f, func="nonparametric", runs=1) Y.di1 <- acc.di1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di1/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.03 1.05 1.06 1.00 1.00 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.03919942034E+000 b = 5.68424694693E+000 c = 1.62206376691E-001 d = 1.30164242783E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.24565249449E+000 # b = 8.39846354900E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 3.41670073454E-001 # b = 9.26054005854E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Diptera species richness from plant model y.di2 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Diptera species richness by non-parametric estimation acc.di2 <- alpha.accum(comm=MBCdi2f, func="nonparametric", runs=1) Y.di2 <- acc.di2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di2/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.05 1.05 1.05 1.07 0.98 0.99 #### Hemiptera #### # y1 <- sac.he1$richness; y2 <- sac.he2$richness # # curve.he1 <- data.frame(x=x, y=y1) # curve.he2 <- data.frame(x=x, y=y2) # # write.csv(curve.he1, 'curve.he1.tree.forest.csv', row.names=F) # write.csv(curve.he2, 'curve.he2.tree.forest.csv', row.names=F) # read curve.he1.tree.forest.csv, curve.he2.tree.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.97217233129E+001 b = 1.95811610246E+001 c = 3.64408902921E-002 d = 1.24565811007E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.31023280078E-001 # b = 1.09034675925E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -1.50169066305E-001 # b = 9.70709665057E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # # predict the Hemiptera species richness from plant model y.he1 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1f, func="nonparametric", runs=1) Y.he1 <- acc.he1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he1/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.04 1.03 1.07 1.06 1.09 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.65631681819E+000 b = 8.52815391896E+000 c = 7.23326638298E-002 d = 1.27176129487E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 7.29542507931E-001 # b = 1.03897805398E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -5.75283280234E-002 # b = 7.81644784376E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hemiptera species richness from plant model y.he2 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he2 <- alpha.accum(comm=MBChe2f, func="nonparametric", runs=1) Y.he2 <- acc.he2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he2/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 1.01 0.99 1.00 0.94 0.95 #### Hymenoptera #### # y1 <- sac.hy1$richness; y2 <- sac.hy2$richness # # curve.hy1 <- data.frame(x=x, y=y1) # curve.hy2 <- data.frame(x=x, y=y2) # # write.csv(curve.hy1, 'curve.hy1.tree.forest.csv', row.names=F) # write.csv(curve.hy2, 'curve.hy2.tree.forest.csv', row.names=F) # read curve.hy1.tree.forest.csv, curve.hy2.tree.forest.csv # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.39531361044E+000 b = 7.24123944409E+000 c = 1.25284754490E-001 d = 1.22168713456E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.04120324841E+000 # b = 9.30623078572E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.24198655775E-001 # b = 9.21344531106E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Hymenoptera species richness from plant model y.hy1 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1f, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy1/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.03 1.03 1.05 0.97 0.98 ### dry season ### # list candidates based on their ranks # Linear Fit: y=a+bx # Coefficient Data: a = 3.00898719656E-002 b = 7.95702355775E-001 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.21054691682E-001 # b = 9.83352996964E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 9.97921418578E+000 # b = 9.82357301716E+000 # c = 7.00023446664E-002 # d = 1.20178972549E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Linear minimal # # predict the Hymenoptera species richness from plant model y.hy2 <- a+b*x.tree*0.01 # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy2 <- alpha.accum(comm=MBChy2f, func="nonparametric", runs=1) Y.hy2 <- acc.hy2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy2/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.01 1.02 1.02 1.04 1.04 #### Lepidoptera #### # y1 <- sac.le1$richness; y2 <- sac.le2$richness # # curve.le1 <- data.frame(x=x, y=y1) # curve.le2 <- data.frame(x=x, y=y2) # # write.csv(curve.le1, 'curve.le1.tree.forest.csv', row.names=F) # write.csv(curve.le2, 'curve.le2.tree.forest.csv', row.names=F) # read curve.le1.tree.forest.csv, curve.le2.tree.forest.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.64144189651E+001 b = 4.58584803744E+001 c = 3.21073382573E-002 d = 1.15490970226E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.24350398379E-001 # b = 1.76309257544E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.94507460038E+000 # b = 9.49878838641E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Lepidoptera species richness from plant model y.le1 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le1 <- alpha.accum(comm=MBCle1f, func="nonparametric", runs=1) Y.le1 <- acc.le1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le1/(y.le1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 0.98 0.95 0.95 0.90 0.89 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.42794512514E+001 b = 6.35340227531E+001 c = 2.06420927281E-002 d = 1.35843605592E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.91036767900E+000 # b = 1.09453941131E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -2.95469530027E-001 # b = 2.22486959998E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Lepidoptera species richness from plant model y.le2 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le2 <- alpha.accum(comm=MBCle2f, func="nonparametric", runs=1) Y.le2 <- acc.le2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le2/(y.le2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 1.03 0.99 1.03 0.99 1.02 #### Psocoptera #### # y1 <- sac.ps1$richness; y2 <- sac.ps2$richness # # curve.ps1 <- data.frame(x=x, y=y1) # curve.ps2 <- data.frame(x=x, y=y2) # # write.csv(curve.ps1, 'curve.ps1.tree.forest.csv', row.names=F) # write.csv(curve.ps2, 'curve.ps2.tree.forest.csv', row.names=F) # read curve.ps1.tree.forest.csv, curve.ps2.tree.forest.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.95662890197E+000 b = 7.65490408988E+000 c = 2.69601765529E-001 d = 1.21263134972E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok, asymptote # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 2.26515555948E+000 # b = 7.44452948095E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 9.00116354760E-001 # b = 1.39943289627E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Psocoptera species richness from plant model y.ps1 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps1 <- alpha.accum(comm=MBCps1f, func="nonparametric", runs=1) Y.ps1 <- acc.ps1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps1/(y.ps1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.00 0.91 0.90 0.90 0.89 ### dry season ### # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.12017868314E+000 b = 6.62184443354E+000 c = 2.54304542886E-001 d = 1.41612357539E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx) # ok, asymptote # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 2.17536893453E+000 # b = 7.65835361017E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 7.92678127919E-001 # b = 1.40736915825E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Psocoptera species richness from plant model y.ps2 <- a-b*exp(-c*(x.tree*0.01)^d) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps2 <- alpha.accum(comm=MBCps2f, func="nonparametric", runs=1) Y.ps2 <- acc.ps2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps2/(y.ps2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.04 1.01 1.02 0.94 0.95 #### calculate the fitness #### DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in1[c(2,4,6)]*1000), Insect2=c(Y.in2[c(2,4,6)], y.in2[c(2,4,6)]*1000), Cole1=c(Y.cole1[c(2,4,6)], y.cole1[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole2[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di1[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di2[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he1[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he2[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy1[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy2[c(2,4,6)]*100), Le1=c(Y.le1[c(2,4,6)], y.le1[c(2,4,6)]*10), Le2=c(Y.le2[c(2,4,6)], y.le2[c(2,4,6)]*10), Ps1=c(Y.ps1[c(2,4,6)], y.ps1[c(2,4,6)]*10), Ps2=c(Y.ps2[c(2,4,6)], y.ps2[c(2,4,6)]*10), Spider1=c(Y.sp1[c(2,4,6)], y.sp1[c(2,4,6)]*10), Spider2=c(Y.sp2[c(2,4,6)], y.sp2[c(2,4,6)]*10), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C2P')) # only present P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9,11,13,15),] # wet season DAT2 <- DAT[c(2,4,6,8,10,12,14,16),] # dry season #### calculate the R^2 fitted to the y=x model #### options(digits=4) ### wet season ## Jack1inP yi <- DAT1[2:7, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.994 ## Jack2inP yi <- DAT1[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9858 ## Chao2P yi <- DAT1[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9785 ### dry season ## Jack1inP yi <- DAT2[2:7, ]$Jack1inP # only include individual insect order ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9968 ## Jack2inP yi <- DAT2[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9956 ## Chao2P yi <- DAT2[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9914 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[2:7, ]$Jack1inP, x=DAT1[2:7, ]$plant.model.J1P, method='pearson') # r=1 cor.test(y=DAT1[2:7, ]$Jack2inP, x=DAT1[2:7, ]$plant.model.J2P, method='pearson') # 0.9999 cor.test(y=DAT1[2:7, ]$Chao2P, x=DAT1[2:7, ]$plant.model.C2P, method='pearson') # 0.995 # dry season cor.test(y=DAT2[2:7, ]$Jack1inP, x=DAT2[2:7, ]$plant.model.J1P, method='pearson') # 0.9996 cor.test(y=DAT2[2:7, ]$Jack2inP, x=DAT2[2:7, ]$plant.model.J2P, method='pearson') # 0.9989 cor.test(y=DAT2[2:7, ]$Chao2P, x=DAT2[2:7, ]$plant.model.C2P, method='pearson') # 0.9973 options(digits=2) #### plot together #### (Fig. S4) ## DAT1: wet season # windows(width = 11.69, height = 6, pointsize=14) par(mfrow=c(1,2), mar=c(4.2,6,3.5,1)) # default margin = ~4.1 for y plot(Jack1inP~plant.model.J1P, data=DAT1[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='Non-parametric estimates (no. spp.)', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(70,2000), ylim=c(70,2000), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT1[1, ]-1600, pch=16) points(Jack2inP~plant.model.J2P, data=DAT1[1, ]-1600, pch=15) points(Chao2P~plant.model.C2P, data=DAT1[1, ]-1600, pch=17) text(x=430, y=2000, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=430, y=1900, labels='Forests: wet season', cex=0.8) xnames0=c('Insecta','Coleoptera','Hymenoptera','Psocoptera','Arachnida') xnames70=c('Hemiptera','Diptera','Lepidoptera') text(x=c(2723-1600+150,565+100,555,72+30,144+30), y=c(2847-1600,628+50,514,65-20,165-20), pos=4, srt=0, cex=0.7, labels=xnames0, col=c(1,2,5,'grey50','gold3')) # x:DAT1$plant.model.C2P, y:DAT1$Chao2P text(x=c(578,504-120,114-120), y=c(664+150,508,102+50), pos=4, srt=70, cex=0.7, labels=xnames70, col=c(4,3,6)) # x:DAT1$plant.model.C2P, y:DAT1$Chao2P legend(1050, 200, legend=c(as.expression(bquote("Jackknife1"*italic('P')*',' ~ R^2 ~ "= 0.994")), as.expression(bquote("Jackknife2"*italic('P')*',' ~ R^2 ~ "= 0.986")), as.expression(bquote(" Chao2"*italic('P')*',' ~ R^2 ~ "= 0.979"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.4, cex=0.7) ## DAT2: dry season par(mar=c(4.2,4,3.5,3)) plot(Jack1inP~plant.model.J1P, data=DAT2[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(70,2000), ylim=c(70,2000), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT2[1, ]-1600, pch=16) points(Jack2inP~plant.model.J2P, data=DAT2[1, ]-1600, pch=15) points(Chao2P~plant.model.C2P, data=DAT2[1, ]-1600, pch=17) text(x=430, y=2000, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=430, y=1900, labels='Forests: dry season', cex=0.8) legend(1460, 180, legend=c(as.expression(bquote(~ R^2 ~ "= 0.997")), as.expression(bquote(~ R^2 ~ "= 0.996")), as.expression(bquote(~ R^2 ~ "= 0.991"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.5, cex=0.7) par(mfrow=c(1,1)) ``` #### Yinggeling VS. Mengsong (_Cross-site prediction_) What's more interesting is to use Yinggeling plant model to predict Mengsong insects, or use Mengsong plant model to predict Yinggeling insects. If the results are good, then the plant model is general, and can be potentially applied in new forests elsewhere. Yinggeling and Mengsong are good examples to test the generality of the plant model, as both are in the same zoogeographic region (Holt 2013), but they are far from each other (~1000 km). However, there are two main differences between them: \* Yinggeling (forest nature reserve) and Mengsong (a mosaic of mature forest (MF), naturally regenerating forest (RF) and open land (OL)) are different landscapes. To maximum the comparability, I choose Mengsong plots within __the forest of Bulong Nature Reserve__. \* Plants of Yinggeling and Mengsong are sampled differently. Trees > 5cm DBH within each plot were included in Yinggeling (although DBH criteria are not strictly same between two sampling years: 2009 and 2011), while vasular plants (including trees > 2cm DBH) were survyed in the subplots of each plot in Mengsong. To maximum the comparability, I choose data of __tree >5cm DBH__ in Mengsong. ```{r prediction_between_YGL_and_MS_3_alternative_functions} # # prepare the datasets Tree5 <- read.csv('MS_Tree_output_5cm.csv', row.names=1, header=T) # 348 tree species with DBH>5 cm row.names(Tree5); row.names(MSenv) MSenvNR <- MSenv[-c(4,9),] # remove plot 62,119 with no trees, and get same rowname as Tree5 for further sort; NR: nature reserve (see below) Tree5NR <- Tree5[MSenvNR$F_NR==TRUE, ] # NR: nature reserve (Fig. 1) MBCin1NR <- MBCin1[MSenv$F_NR==TRUE, ] MBCcole1NR <- MBCcole1[MSenv$F_NR==TRUE, ] MBCdi1NR <- MBCdi1[MSenv$F_NR==TRUE, ] MBChe1NR <- MBChe1[MSenv$F_NR==TRUE, ] MBChy1NR <- MBChy1[MSenv$F_NR==TRUE, ] MBCle1NR <- MBCle1[MSenv$F_NR==TRUE, ] MBCps1NR <- MBCps1[MSenv$F_NR==TRUE, ] MBCin2NR <- MBCin2[MSenv$F_NR==TRUE, ] MBCcole2NR <- MBCcole2[MSenv$F_NR==TRUE, ] MBCdi2NR <- MBCdi2[MSenv$F_NR==TRUE, ] MBChe2NR <- MBChe2[MSenv$F_NR==TRUE, ] MBChy2NR <- MBChy2[MSenv$F_NR==TRUE, ] MBCle2NR <- MBCle2[MSenv$F_NR==TRUE, ] MBCps2NR <- MBCps2[MSenv$F_NR==TRUE, ] row.names(Tree5NR); row.names(MBCin1NR) # same Tree5NR <- Tree5NR[ ,specnumber(Tree5NR, MARGIN=2)>0] # 348 -> 281 MBCin1NR <- MBCin1NR[ ,specnumber(MBCin1NR, MARGIN=2)>0] # 2073 -> 1518 MBCcole1NR <- MBCcole1NR[ ,specnumber(MBCcole1NR, MARGIN=2)>0] # 375->257 MBCdi1NR <- MBCdi1NR[ ,specnumber(MBCdi1NR, MARGIN=2)>0] # 414->314 MBChe1NR <- MBChe1NR[ ,specnumber(MBChe1NR, MARGIN=2)>0] # 435->301 MBChy1NR <- MBChy1NR[ ,specnumber(MBChy1NR, MARGIN=2)>0] # 409->322 MBCle1NR <- MBCle1NR[ ,specnumber(MBCle1NR, MARGIN=2)>0] # 78->62 MBCps1NR <- MBCps1NR[ ,specnumber(MBCps1NR, MARGIN=2)>0] # 71->55 MBCin2NR <- MBCin2NR[ ,specnumber(MBCin2NR, MARGIN=2)>0] # 2215 -> 1693 MBCcole2NR <- MBCcole2NR[ ,specnumber(MBCcole2NR, MARGIN=2)>0] # 603->454 MBCdi2NR <- MBCdi2NR[ ,specnumber(MBCdi2NR, MARGIN=2)>0] # 413->337 MBChe2NR <- MBChe2NR[ ,specnumber(MBChe2NR, MARGIN=2)>0] # 370->246 MBChy2NR <- MBChy2NR[ ,specnumber(MBChy2NR, MARGIN=2)>0] # 360->289 MBCle2NR <- MBCle2NR[ ,specnumber(MBCle2NR, MARGIN=2)>0] # 95->72 MBCps2NR <- MBCps2NR[ ,specnumber(MBCps2NR, MARGIN=2)>0] # 63->53 # # begin the analyses ### Insecta # # get Mengsong plant model sac.tree <- specaccum(Tree5NR, "random", permutations=9999) sac.in1 <- specaccum(MBCin1NR, "random", permutations=9999) sac.in2 <- specaccum(MBCin2NR, "random", permutations=9999) plot(sac.in1$richness ~ sac.tree$richness, xlab='Trees', ylab='Insects', main='Accumulated species richness comparison (Mengsong:wet)') # clear relationship plot(sac.in2$richness ~ sac.tree$richness, xlab='Trees', ylab='Insects', main='Accumulated species richness comparison (Mengsong:dry') # clear relationship # # **you may need to remove the # before below commands and run the commands yourself # x <- sac.tree$richness # y1 <- sac.in1$richness; y2 <- sac.in2$richness # # curve.in1 <- data.frame(x=x, y=y1) # curve.in2 <- data.frame(x=x, y=y2) # # write.csv(curve.in1, 'curve.in1.tree.nr.csv', row.names=F) # write.csv(curve.in2, 'curve.in2.tree.nr.csv', row.names=F) # # **you may need to remove the # before above commands and run the commands yourself # read curve.in1.tree.nr.csv, curve.in2.tree.nr.csv into CurveExpert # scale x by 0.01, and y by 0.001 # # wet season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 3.98033654763E+000 b = 3.88787660047E+000 c = 1.28570668750E-001 d = 1.22562828762E+000 # check the curve xx <- 1:603 # tree species=603 in Yinggeling yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*1000)~xx, col='blue', ylim=c(0,5000)) # ok # # **you may need to remove the # before below commands and run the commands yourself # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # n <- 16 # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 5.67205527190E-001 # b = 9.54750960823E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 3.69957946523E-002 # b = 5.29758674245E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal (deltaAICc = -7 compared with Power) # # **you may need to remove the # before above commands and run the commands yourself # # predict Yinggeling insect OTU richness from Mengsong tree model y.in1 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling insect OTU richness Y.in/(y.in1*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.14 1.55 1.40 1.91 1.34 1.82 # # dry season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 3.48164456586E+000 b = 3.39315896257E+000 c = 1.80660220305E-001 d = 1.22509602804E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*1000)~xx, col='deepskyblue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 6.59283806584E-001 # b = 9.21002514492E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 6.81507937768E-002 # b = 5.87122612206E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Yinggeling insect OTU richness from plant model y.in2 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling insect OTU richness Y.in/(y.in2*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.11 1.52 1.37 1.87 1.31 1.79 # # Predict Mengsong nature reserve forest insects with Yinggeling plant model (YGL -> MS) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.39323327191E+001 b = 1.38515892171E+001 c = 2.69791795103E-002 d = 1.56512741540E+000 # plot the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*1000)~xx, col="green4") # # estimate Mengsong tree species richness by non-parametric estimation (acc.tree <- alpha.accum(comm=Tree5NR, func="nonparametric", runs=1)) (x.tree.ab <- acc.tree[16,c(8,9,12,13,16,17)]) # withdraw abundant Jackknif1, Jackknif2 and Chao1 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # estimate Mengsong insect OTU richness by Yinggeling plant model (y.in <- a-b*exp(-c*(x.tree.ab*0.01)^d)) # use tree abundance estimator # # estimate Mengsong insect OTU richness by non-parametric estimation acc.in1 <- alpha.accum(comm=MBCin1NR, func="nonparametric", runs=1) acc.in2 <- alpha.accum(comm=MBCin2NR, func="nonparametric", runs=1) (Y.in1 <- acc.in1[16,c(10,11,14,15,18,19)]) (Y.in2 <- acc.in2[16,c(10,11,14,15,18,19)]) # withdraw incidence Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare nonparametric estimates and tree model estimates Y.in1/(y.in*1000) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 0.79 0.83 0.77 0.82 0.82 0.86 Y.in2/(y.in*1000) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 0.86 0.87 0.81 0.82 0.82 0.83 #### apply to Insecta orders #### sac.cole1 <- specaccum(MBCcole1NR, "random", permutations=9999) sac.cole2 <- specaccum(MBCcole2NR, "random", permutations=9999) sac.di1 <- specaccum(MBCdi1NR, "random", permutations=9999) sac.di2 <- specaccum(MBCdi2NR, "random", permutations=9999) sac.he1 <- specaccum(MBChe1NR, "random", permutations=9999) sac.he2 <- specaccum(MBChe2NR, "random", permutations=9999) sac.hy1 <- specaccum(MBChy1NR, "random", permutations=9999) sac.hy2 <- specaccum(MBChy2NR, "random", permutations=9999) sac.le1 <- specaccum(MBCle1NR, "random", permutations=9999) sac.le2 <- specaccum(MBCle2NR, "random", permutations=9999) plot(sac.cole1$richness ~ sac.tree$richness, xlab='Trees', ylab='Coleoptera', main='Mengsong_wet') # clear relationship plot(sac.cole2$richness ~ sac.tree$richness, xlab='Trees', ylab='Coleoptera', main='Mengsong_dry') # clear relationship plot(sac.di1$richness ~ sac.tree$richness, xlab='Trees', ylab='Diptera', main='Mengsong_wet') # clear relationship plot(sac.di2$richness ~ sac.tree$richness, xlab='Trees', ylab='Diptera', main='Mengsong_dry') # clear relationship plot(sac.he1$richness ~ sac.tree$richness, xlab='Trees', ylab='Hemiptera', main='Mengsong_wet') # clear relationship plot(sac.he2$richness ~ sac.tree$richness, xlab='Trees', ylab='Hemiptera', main='Mengsong_dry') # clear relationship plot(sac.hy1$richness ~ sac.tree$richness, xlab='Trees', ylab='Hymenoptera', main='Mengsong_wet') # clear relationship plot(sac.hy2$richness ~ sac.tree$richness, xlab='Trees', ylab='Hymenoptera', main='Mengsong_dry') # clear relationship plot(sac.le1$richness ~ sac.tree$richness, xlab='Trees', ylab='Lepidoptera', main='Mengsong_wet') # clear relationship plot(sac.le2$richness ~ sac.tree$richness, xlab='Trees', ylab='Lepidoptera', main='Mengsong_dry') # clear relationship #### Coleoptera #### # # get Mengsong plant model # y1 <- sac.cole1$richness; y2 <- sac.cole2$richness # # curve.cole1 <- data.frame(x=x, y=y1) # curve.cole2 <- data.frame(x=x, y=y2) # # write.csv(curve.cole1, 'curve.cole1.tree.nr.csv', row.names=F) # write.csv(curve.cole2, 'curve.cole2.tree.nr.csv', row.names=F) # read curve.cole1.tree.nr.csv, curve.cole2.tree.nr.csv into CurveExpert # scale x and y by 0.01 # # wet season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.54940074465E+000 b = 8.38236315824E+000 c = 8.29451732067E-002 d = 1.35500782744E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx, ylim=c(0,800), col='blue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.39098205023E-001 # b = 1.08002143166E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -8.87971737943E-002 # b = 9.36356409195E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict Yinggeling Coleoptera OTU richness from Mengsong tree model y.cole1 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Coleoptera OTU richness Y.cole/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.75 1.13 0.98 1.46 1.15 1.72 # # dry season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.04231644722E+001 b = 1.02617311497E+001 c = 1.58401973096E-001 d = 1.21700605682E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col='deepskyblue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.68947584135E+000 # b = 9.65273075058E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 6.98699965252E-002 # b = 1.61051536693E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Yinggeling insect OTU richness from plant model y.cole2 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Coleoptera OTU richness Y.cole/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.50 0.75 0.66 0.98 0.77 1.15 # # Predict Mengsong nature reserve forest Coleoptera with Yinggeling plant model (YGL -> MS) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.04852725401E+001 b = 1.03543582791E+001 c = 3.34742069514E-002 d = 1.82069964115E+000 # plot the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col="green4") # # estimate Mengsong Coleoptera OTU richness by Yinggeling plant model (y.cole <- a-b*exp(-c*(x.tree.ab*0.01)^d)) # use tree abundance estimator # # estimate Mengsong Coleoptera OTU richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1NR, func="nonparametric", runs=1) acc.cole2 <- alpha.accum(comm=MBCcole2NR, func="nonparametric", runs=1) (Y.cole1 <- acc.cole1[16,c(10,11,14,15,18,19)]) (Y.cole2 <- acc.cole2[16,c(10,11,14,15,18,19)]) # withdraw incidence Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare nonparametric estimates and tree model estimates Y.cole1/(y.cole*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 1.16 1.30 1.17 1.32 1.32 1.48 Y.cole2/(y.cole*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 1.91 1.95 1.81 1.86 1.85 1.90 #### Diptera #### # # get Mengsong plant model # y1 <- sac.di1$richness; y2 <- sac.di2$richness # # curve.di1 <- data.frame(x=x, y=y1) # curve.di2 <- data.frame(x=x, y=y2) # # write.csv(curve.di1, 'curve.di1.tree.nr.csv', row.names=F) # write.csv(curve.di2, 'curve.di2.tree.nr.csv', row.names=F) # read curve.di1.tree.nr.csv, curve.di2.tree.nr.csv into CurveExpert # scale x and y by 0.01 # # wet season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.75671290002E+000 b = 8.50009246958E+000 c = 1.31639948386E-001 d = 1.10759405108E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx, col='blue', ylim=c(0,2000)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.31483836206E+000 # b = 8.41814292462E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 2.82370537096E-001 # b = 1.02735333513E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict Yinggeling Diptera OTU richness from Mengsong tree model y.di1 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Diptera OTU richness Y.di/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 2.38 3.15 2.90 3.85 2.76 3.66 # # dry season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.14113407542E+000 b = 4.84582368684E+000 c = 2.79832608806E-001 d = 1.24232761047E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col='deepskyblue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.50609361493E+000 # b = 7.94165606072E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 3.94913584825E-001 # b = 1.09436549397E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Yinggeling Diptera OTU richness from plant model y.di2 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Diptera OTU richness Y.di/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 2.74 3.63 3.34 4.44 3.17 4.21 # # Predict Mengsong nature reserve forest Diptera with Yinggeling plant model (YGL -> MS) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 3.24563134314E+001 b = 3.20423314259E+001 c = 5.21898054812E-002 d = 1.56897921325E+000 # plot the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col="green4") # # estimate Mengsong Diptera OTU richness by Yinggeling plant model y.di <- a-b*exp(-c*(x.tree.ab*0.01)^d) # use tree abundance estimator # # estimate Mengsong Diptera OTU richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1NR, func="nonparametric", runs=1) acc.di2 <- alpha.accum(comm=MBCdi2NR, func="nonparametric", runs=1) Y.di1 <- acc.di1[16,c(10,11,14,15,18,19)] Y.di2 <- acc.di2[16,c(10,11,14,15,18,19)] # withdraw incidence Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare nonparametric estimates and plant model estimates Y.di1/(y.di*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 0.39 0.40 0.38 0.40 0.40 0.41 Y.di2/(y.di*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 0.39 0.38 0.35 0.34 0.35 0.34 #### Hemiptera #### # # get Mengsong plant model # y1 <- sac.he1$richness; y2 <- sac.he2$richness # # curve.he1 <- data.frame(x=x, y=y1) # curve.he2 <- data.frame(x=x, y=y2) # # write.csv(curve.he1, 'curve.he1.tree.nr.csv', row.names=F) # write.csv(curve.he2, 'curve.he2.tree.nr.csv', row.names=F) # read curve.he1.tree.nr.csv, curve.he2.tree.nr.csv into CurveExpert # scale x and y by 0.01 # # wet season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.39282261789E+001 b = 1.37916873128E+001 c = 6.50393564882E-002 d = 1.23686329713E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx, col='blue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.00865975555E+000 # b = 1.05698024856E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -7.68019244683E-002 # b = 1.09178894146E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict Yinggeling Hemiptera OTU richness from Mengsong tree model y.he1 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Hemiptera OTU richness Y.he/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.51 0.69 0.62 0.85 0.58 0.80 # # dry season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.20250984616E+000 b = 7.07844618956E+000 c = 1.08457743041E-001 d = 1.26339172870E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col='deepskyblue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 8.60254370034E-001 # b = 1.01941301552E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = -2.21960510444E-002 # b = 8.84125297844E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal (deltaAICc = -1.3 compared with Powerd) # # predict the Yinggeling Hemiptera OTU richness from plant model y.he2 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Hemiptera OTU richness Y.he/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.68 0.93 0.84 1.15 0.78 1.07 # # Predict Mengsong nature reserve forest Hemiptera with Yinggeling plant model (YGL -> MS) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.33386336366E+001 b = 1.32570260080E+001 c = 2.84305655558E-002 d = 1.58862517562E+000 # plot the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col="green4") # # estimate Mengsong Hemiptera OTU richness by Yinggeling plant model y.he <- a-b*exp(-c*(x.tree.ab*0.01)^d) # use tree abundance estimator # # estimate Mengsong Hemiptera OTU richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1NR, func="nonparametric", runs=1) acc.he2 <- alpha.accum(comm=MBChe2NR, func="nonparametric", runs=1) Y.he1 <- acc.he1[16,c(10,11,14,15,18,19)] Y.he2 <- acc.he2[16,c(10,11,14,15,18,19)] # withdraw incidence Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare nonparametric estimates and plant model estimates Y.he1/(y.he*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 1.59 1.76 1.61 1.79 1.78 1.97 Y.he2/(y.he*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 1.26 1.35 1.23 1.32 1.26 1.35 #### Hymenoptera #### # # get Mengsong plant model # y1 <- sac.hy1$richness; y2 <- sac.hy2$richness # # curve.hy1 <- data.frame(x=x, y=y1) # curve.hy2 <- data.frame(x=x, y=y2) # # write.csv(curve.hy1, 'curve.hy1.tree.nr.csv', row.names=F) # write.csv(curve.hy2, 'curve.hy2.tree.nr.csv', row.names=F) # read curve.hy1.tree.nr.csv, curve.hy2.tree.nr.csv into CurveExpert # scale x and y by 0.01 # # wet season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.63375140098E+000 b = 6.51166198075E+000 c = 1.92569033582E-001 d = 1.17093543625E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*100)~xx, col='blue', ylim=c(0,600), main='Hymenoptera') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.28140895776E+000 # b = 9.01224373225E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.62346275502E-001 # b = 1.10840665949E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict Yinggeling Hymenoptera OTU richness from Mengsong tree model y.hy1 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Hymenoptera OTU richness Y.hy/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.47 0.62 0.56 0.73 0.48 0.63 # # dry season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.40143782576E+000 b = 8.29998174579E+000 c = 1.28524246933E-001 d = 1.11802648815E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col='deepskyblue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 1.11264404164E+000 # b = 9.26212398088E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 1.10101846089E-001 # b = 9.97502331300E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal (deltaAICc = -7.2 compared with Power) # # predict the Yinggeling Hymenoptera OTU richness from plant model y.hy2 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Hymenoptera OTU richness Y.hy/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.48 0.63 0.57 0.74 0.49 0.64 # # Predict Mengsong nature reserve forest Hymenoptera with Yinggeling plant model (YGL -> MS) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.41651571419E+000 b = 5.33635949865E+000 c = 5.66669769840E-002 d = 1.65174106074E+000 # plot the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col="green4") # # estimate Mengsong Hymenoptera OTU richness by Yinggeling plant model y.hy <- a-b*exp(-c*(x.tree.ab*0.01)^d) # use tree abundance estimator # # estimate Mengsong Hymenoptera OTU richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1NR, func="nonparametric", runs=1) acc.hy2 <- alpha.accum(comm=MBChy2NR, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[16,c(10,11,14,15,18,19)] Y.hy2 <- acc.hy2[16,c(10,11,14,15,18,19)] # withdraw incidence Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare nonparametric estimates and plant model estimates Y.hy1/(y.hy*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 2.02 2.07 1.95 2.01 1.9 2.00 Y.hy2/(y.hy*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 1.88 2.00 1.89 2.02 1.99 2.11 #### Lepidoptera #### # # get Mengsong plant model # y1 <- sac.le1$richness; y2 <- sac.le2$richness # # curve.le1 <- data.frame(x=x, y=y1) # curve.le2 <- data.frame(x=x, y=y2) # # write.csv(curve.le1, 'curve.le1.tree.nr.csv', row.names=F) # write.csv(curve.le2, 'curve.le2.tree.nr.csv', row.names=F) # read curve.le1.tree.nr.csv, curve.le2.tree.nr.csv into CurveExpert # scale x by 0.01, and y by 0.1 # # wet season # list candidates based on their ranks # Linear Fit: y=a+bx # Coefficient Data: a = 3.39258560392E-001 b = 2.07842105945E+000 # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Weibull Model: y=a-b*exp(-c*x^d) # # Coefficient Data: # a = 4.33781650659E+001 # b = 4.28726907588E+001 # c = 4.54050098873E-002 # d = 1.10381870666E+000 # # # check the curve # yy <- a-b*exp(-c*(xx*0.01)^d); plot(I(yy*10)~xx, col='blue', main='Lepidoptera', ylim=c(0,700)) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 2.41063588572E+000 # b = 9.06292240229E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal (deltaAICc = -9 compared with Linear) # # predict Yinggeling Lepidoptera OTU richness from Mengsong tree model y.le1 <- a+b*6.03 # # compare the two estimates of Yinggeling Lepidoptera OTU richness Y.le/(y.le1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 3.29 4.65 4.11 5.81 4.01 5.67 # # dry season # list candidates based on their ranks # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.68927852906E+001 b = 4.63795440046E+001 c = 4.57829583827E-002 d = 1.18244679186E+000 # check the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col='deepskyblue') # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Linear Fit: y=a+bx # # Coefficient Data: # a = 9.72219327368E-002 # b = 2.50946879960E+000 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # # Power Fit: y=ax^b # # Coefficient Data: # a = 2.58836808717E+000 # b = 9.83730057471E-001 # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # # which.min(c(AICc.l, AICc.p, AICc.w)) # Weibull minimal # # predict the Yinggeling Lepidoptera OTU richness from plant model y.le2 <- a-b*exp(-c*6.03^d) # # compare the two estimates of Yinggeling Lepidoptera OTU richness Y.le/(y.le2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 2.80 3.96 3.50 4.95 3.41 4.82 # # Predict Mengsong nature reserve forest Lepidoptera with Yinggeling plant model (YGL -> MS) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.00848708582E+001 b = 1.99831609899E+001 c = 2.23029376169E-002 d = 1.65228515255E+000 # plot the curve yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col='green4') # ok # # estimate Mengsong Lepidoptera OTU richness by Yinggeling plant model y.le <- a-b*exp(-c*(x.tree.ab*0.01)^d) # use tree abundance estimator # # estimate Mengsong Lepidoptera OTU richness by non-parametric estimation acc.le1 <- alpha.accum(comm=MBCle1NR, func="nonparametric", runs=1) acc.le2 <- alpha.accum(comm=MBCle2NR, func="nonparametric", runs=1) Y.le1 <- acc.le1[16,c(10,11,14,15,18,19)] Y.le2 <- acc.le2[16,c(10,11,14,15,18,19)] # withdraw incidence Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare nonparametric estimates and plant model estimates Y.le1/(y.le*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 0.24 0.26 0.24 0.26 0.26 0.27 Y.le2/(y.le*100) # Jack1 Jack1P Jack2 Jack2P Chao ChaoP # 0.29 0.31 0.29 0.31 0.31 0.34 #### calculate the fitness #### # Mengsong -> Yinggeling dat <- data.frame(Insect=c(Y.in[c(2,4,6)],y.in1*1000,y.in2*1000), Cole=c(Y.cole[c(2,4,6)],y.cole1*100,y.cole2*100), Di=c(Y.di[c(2,4,6)],y.di1*100,y.di2*100), He=c(Y.he[c(2,4,6)],y.he1*100,y.he2*100), Hy=c(Y.hy[c(2,4,6)],y.hy1*100,y.hy2*100), Le=c(Y.le[c(2,4,6)],y.le1*10,y.le2*10), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P','plant.model1','plant.model2')) # only present P-corrected versions dat <- data.frame(t(dat)) #### calculate the R^2 fitted to the y=x model #### options(digits=4) ## Jack1inP # MS1->YGL yi <- dat[-1, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi1 <- dat[-1, ]$plant.model1 # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi1)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -0.3214 # MS2->YGL fi2 <- dat[-1, ]$plant.model2 SSres <- sum((yi-fi2)^2) (Rsquare <- 1-SSres/SStotal) # -0.4372 ## Jack2inP # MS1->YGL yi <- dat[-1, ]$Jack2inP ym <- mean(yi) SStotal <- sum((yi-ym)^2) SSres <- sum((yi-fi1)^2) (Rsquare <- 1-SSres/SStotal) # -0.5299 # MS2->YGL SSres <- sum((yi-fi2)^2) (Rsquare <- 1-SSres/SStotal) # -0.6019 ## Chao2P # MS1->YGL yi <- dat[-1, ]$Chao2P ym <- mean(yi) SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi1)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -0.5478 # MS2->YGL SSres <- sum((yi-fi2)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -0.5717 #### calculate the correlations between two estimates #### # MS1->YGL cor.test(y=dat[-1, ]$Jack1inP, x=dat[-1, ]$plant.model1, method='pearson') # r=0.1031 cor.test(y=dat[-1, ]$Jack2inP, x=dat[-1, ]$plant.model1, method='pearson') # r=0.09711 cor.test(y=dat[-1, ]$Chao2P, x=dat[-1, ]$plant.model1, method='pearson') # r=0.09631 # MS2->YGL cor.test(y=dat[-1, ]$Jack1inP, x=dat[-1, ]$plant.model2, method='pearson') # r=-0.02961 cor.test(y=dat[-1, ]$Jack2inP, x=dat[-1, ]$plant.model2, method='pearson') # r=-0.01593 cor.test(y=dat[-1, ]$Chao2P, x=dat[-1, ]$plant.model2, method='pearson') # r=-0.06009 # YGL -> Mengsong DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in[c(2,4,6)]*1000), Insect2=c(Y.in2[c(2,4,6)], y.in[c(2,4,6)]*1000), Cole1=c(Y.cole1[c(2,4,6)], y.cole[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy[c(2,4,6)]*100), Le1=c(Y.le1[c(2,4,6)], y.le[c(2,4,6)]*100), Le2=c(Y.le2[c(2,4,6)], y.le[c(2,4,6)]*100), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C1P')) # only presenting P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9,11),] # wet season DAT2 <- DAT[c(2,4,6,8,10,12),] # dry season #### calculate the R^2 fitted to the y=x model #### ### wet season ## Jack1inP yi <- DAT1[-1, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -4.907 ## Jack2inP yi <- DAT1[-1, ]$Jack2inP ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -4.781 ## Chao2P yi <- DAT1[-1, ]$Chao2P ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.C1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -4.036 ### dry season ## Jack1inP yi <- DAT2[-1, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -3.777 ## Jack2inP yi <- DAT2[-1, ]$Jack2inP ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -4.372 ## Chao2P yi <- DAT2[-1, ]$Chao2P ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.C1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # -4.555 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[-1, ]$Jack1inP, x=DAT1[-1, ]$plant.model.J1P, method='pearson') # r=0.09852 cor.test(y=DAT1[-1, ]$Jack2inP, x=DAT1[-1, ]$plant.model.J2P, method='pearson') # 0.07105 cor.test(y=DAT1[-1, ]$Chao2P, x=DAT1[-1, ]$plant.model.C1P, method='pearson') # 0.06238 # dry season cor.test(y=DAT2[-1, ]$Jack1inP, x=DAT2[-1, ]$plant.model.J1P, method='pearson') # -0.0005805 cor.test(y=DAT2[-1, ]$Jack2inP, x=DAT2[-1, ]$plant.model.J2P, method='pearson') # -0.08766 cor.test(y=DAT2[-1, ]$Chao2P, x=DAT2[-1, ]$plant.model.C1P, method='pearson') # -0.1163 options(digits=2) #### plot together #### # windows(width = 11.69, height = 5.8, pointsize=14) ### wet season ### (Fig. 3) par(mfrow=c(1,2), mar=c(4.2,6,3.5,1)) # default margin = ~4.1 for y axis ## Mengsong_wet -> Yinggeling plot(Jack1inP~plant.model1, data=dat, xlab='', ylab='', col=1:6, pch=16, xlim=c(200,5500), ylim=c(200,5500),xaxt='n', yaxt='n', type='n') # circle = Jack1inP mtext(c(as.expression(bquote(italic('Mengsong')*' plant-model estimates (no. spp.)'))), side=1, line=3, cex=0.85) # add xlab mtext(c(as.expression(bquote(italic('Yinggeling')*' non-parametric estimates (no. spp.)'))), side=2, line=3, cex=0.85) # add ylab axis(1, at=c(500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500), label=c(NA,'1000',NA,'2000',NA,'3000',NA,'4000',NA,'5000',NA), tick=T) axis(2, at=c(500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500), label=c(NA,'1000',NA,'2000',NA,'3000',NA,'4000',NA,'5000',NA), tick=T) # show y=0.5*x and y=2*x polygon Yvec <- c(0.5*c(0:6000), rev(2*c(0:6000))) polygon(x=c(0:6000, rev(0:6000)), y=Yvec, col="lightblue", border=NA) abline(a=0, b=1, lty=2) points(Jack1inP~plant.model1, data=dat, col=1:6, pch=16) # circle = Jack1inP points(Jack2inP~plant.model1, data=dat, col=1:6, pch=15) # square = Jack2inP points(Chao2P~plant.model1, data=dat, col=1:6, pch=17) # triangle = Chao2P # add the taxa names text(x=c(3044-100,486), y=c(5045,327-150), pos=4, srt=0, cex=0.7, labels=c('Insecta','Hymenoptera'), col=c(1,5)) text(x=c(501,125-160), y=c(2122+100,748+200), pos=4, srt=70, cex=0.7, labels=c('Diptera','Lepidoptera'), col=c(3,6)) text(x=500, y=909+100, pos=4, srt=50, cex=0.7, labels='Coleoptera', col=2) text(x=650, y=542-50, pos=4, srt=40, cex=0.7, labels='Hemiptera', col=4) # add location name text(x=1150, y=5450, as.expression(bquote(italic('Cross-site prediction'))), cex=0.8) mtext(text='Fig. 3', side=3, at=-700, line=1.5) ## Yinggeling -> Mengsong_wet plot(Jack1inP~plant.model.J1P, data=DAT1, xlab='', ylab='', col=1:6, pch=16, xlim=c(150,3800), ylim=c(150,3800),xaxt='n', yaxt='n', type='n') # circle = Jack1inP mtext(c(as.expression(bquote(italic('Yinggeling')*' plant-model estimates (no. spp.)'))), side=1, line=3, cex=0.85) # add xlab mtext(c(as.expression(bquote(italic('Mengsong')*' non-parametric estimates (no. spp.)'))), side=2, line=3, cex=0.85) # add ylab axis(1, at=c(500,1000,1500,2000,2500,3000,3500), label=c(NA,'1000',NA,'2000',NA,'3000',NA), tick=T) axis(2, at=c(500,1000,1500,2000,2500,3000,3500), label=c(NA,'1000',NA,'2000',NA,'3000',NA), tick=T) # show y=0.5*x and y=2*x polygon Yvec <- c(0.5*c(0:4000), rev(2*c(0:4000))) polygon(x=c(0:4000, rev(0:4000)), y=Yvec, col="lightblue", border=NA) abline(a=0, b=1, lty=2) points(Jack1inP~plant.model.J1P, data=DAT1, col=1:6, pch=16) # # circle = Jack1inP points(Jack2inP~plant.model.J2P, data=DAT1, col=1:6, pch=15) # square = Jack2inP points(Chao2P~plant.model.C1P, data=DAT1, col=1:6, pch=17) # triangle = Chao2P # add lacation and season names text(x=800, y=3760, as.expression(bquote(italic('Cross-site prediction'))), cex=0.8) ### dry season ### (Fig. S5) # windows(width = 11.69, height = 5.8, pointsize=14) par(mfrow=c(1,2), mar=c(4.2,6,3.5,1)) # default margin = ~4.1 for y axis ## Mengsong_dry -> Yinggeling plot(Jack1inP~plant.model2, data=dat, xlab='', ylab='', col=1:6, pch=16, xlim=c(200,5500), ylim=c(200,5500),xaxt='n', yaxt='n', type='n') # circle = Jack1inP mtext(c(as.expression(bquote(italic('Mengsong')*' plant-model estimates (no. spp.)'))), side=1, line=3, cex=0.85) # add xlab mtext(c(as.expression(bquote(italic('Yinggeling')*' non-parametric estimates (no. spp.)'))), side=2, line=3, cex=0.85) # add ylab axis(1, at=c(500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500), label=c(NA,'1000',NA,'2000',NA,'3000',NA,'4000',NA,'5000',NA), tick=T) axis(2, at=c(500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500), label=c(NA,'1000',NA,'2000',NA,'3000',NA,'4000',NA,'5000',NA), tick=T) # show y=0.5*x and y=2*x polygon Yvec <- c(0.5*c(0:6000), rev(2*c(0:6000))) polygon(x=c(0:6000, rev(0:6000)), y=Yvec, col="lightblue", border=NA) abline(a=0, b=1, lty=2) points(Jack1inP~plant.model2, data=dat, col=1:6, pch=16) # circle = Jack1inP points(Jack2inP~plant.model2, data=dat, col=1:6, pch=15) # square = Jack2inP points(Chao2P~plant.model2, data=dat, col=1:6, pch=17) # triangle = Chao2P # add the taxa names text(x=c(3353-400,572), y=c(5045,327-100), pos=4, srt=0, cex=0.7, labels=c('Insecta','Hymenoptera'), col=c(1,5)) text(x=471-200, y=542+200, pos=4, srt=70, cex=0.7, labels='Hemiptera', col=4) text(x=c(461,130-180), y=c(2122+100,748+200), pos=4, srt=70, cex=0.7, labels=c('Diptera','Lepidoptera'), col=c(3,6)) text(x=767-100, y=909+200, pos=4, srt=50, cex=0.7, labels='Coleoptera', col=2) # add location name text(x=1150, y=5450, as.expression(bquote(italic('Cross-site prediction'))), cex=0.8) # mtext(text='Fig. S5', side=3, at=-900, line=1.5) ## Yinggeling -> Mengsong_dry plot(Jack1inP~plant.model.J1P, data=DAT2, xlab='', ylab='', col=1:6, pch=16, xlim=c(160,3800), ylim=c(160,3800),xaxt='n', yaxt='n', type='n') # circle = Jack1inP mtext(c(as.expression(bquote(italic('Yinggeling')*' plant-model estimates (no. spp.)'))), side=1, line=3, cex=0.85) # add xlab mtext(c(as.expression(bquote(italic('Mengsong')*' non-parametric estimates (no. spp.)'))), side=2, line=3, cex=0.85) # add ylab axis(1, at=c(0,500,1000,1500,2000,2500,3000,3500), label=c('0',NA,'1000',NA,'2000',NA,'3000',NA), tick=T) axis(2, at=c(0,500,1000,1500,2000,2500,3000,3500), label=c('0',NA,'1000',NA,'2000',NA,'3000',NA), tick=T) # show y=0.5*x and y=2*x polygon Yvec <- c(0.5*c(0:4000), rev(2*c(0:4000))) polygon(x=c(0:4000, rev(0:4000)), y=Yvec, col="lightblue", border=NA) abline(a=0, b=1, lty=2) points(Jack1inP~plant.model.J1P, data=DAT2, col=1:6, pch=16) # # circle = Jack1inP points(Jack2inP~plant.model.J2P, data=DAT2, col=1:6, pch=15) # square = Jack2inP points(Chao2P~plant.model.C1P, data=DAT2, col=1:6, pch=17) # triangle = Chao2P # add lacation and season names text(x=800, y=3760, as.expression(bquote(italic('Cross-site prediction'))), cex=0.8) par(mfrow=c(1,1)) ``` #### __25 alternative functions__ #### _Yinggeling, Hainan_ ```{r alpha_Yinggeling_25_alternative_functions} ### Arachnida not included due to the low sample size (<50) ### Insecta # read the curve.in.csv into CurveExpert # scale x by 0.01 and y by 0.001 # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.02430093728E-002 b = 3.10119319672E-001 c = 1.42522409677E-001 d = -7.41188976918E-003 # check the curve xx <- 1:603 # tree species = 603 in Yinggeling yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*1000)~xx, ylim=c(0,6000)) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # n <- 21 # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.36676590497E-001 b = -2.15226464380E-001 c = 1.53542254532E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*1000)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 3.57396765354E-001 b = 1.26689051859E+000 c = 1.50566694217E+000 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*1000)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -1.02890491089E+000 b = 2.36562561502E-001 c = 1.50566408897E+000 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*1000)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.s, AICc.m, AICc.v)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 21 plots to assess their suitability for extrapolation ransub <- sample(1:21, size=15, replace=F) Tree_rs <- Tree[ransub,] # rs=ransub MBCin_rs <- MBCin[ransub,] # rs=ransub # remove empty columns Tree_rs <- Tree_rs[,specnumber(Tree_rs, MARGIN=2)>0] # 297 -> 233 MBCin_rs <- MBCin_rs[,specnumber(MBCin_rs, MARGIN=2)>0] # 1995 -> 1549 sac.tree.rs <- specaccum(comm=Tree_rs, method="random", permutations=9999) sac.in.rs <- specaccum(comm=MBCin_rs, method="random", permutations=9999) plot(sac.in.rs$richness ~ sac.tree.rs$richness, xlab='Trees', ylab='Insecta', main='Accumulated species richness comparison (Yinggeling)') # clear relationship # x <- sac.tree.rs$richness # y <- sac.in.rs$richness # curve.in <- data.frame(x=x, y=y) # write.csv(curve.in, 'curve.in.rs.csv', row.names=F) # read the curve.in.rs.csv into CurveExpert # scale x by 0.01 and y by 0.001 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 2.01293198013E-002 b = 2.91321813740E-001 c = 1.96898973227E-001 d = -1.72236947174E-002 f_3p <- a+b*2.97+c*2.97^2+d*2.97^3 # 297 tree species found in the survey, 297*0.01=2.97; f: fitted, 3p: 3rd degree Polynomial # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.84649981224E-001 b = -1.75721643608E-001 c = 1.51802990778E+000 f_s <- a*(2.97-b)^c # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 4.04832774367E-001 b = 1.21314920497E+000 c = 1.48958449914E+000 f_m <- a*b^(1/2.97)*2.97^c # comparing the predicted with the actual value diff <- c(f_3p, f_s, f_m)*1000-dim(MBCin)[2] # getting the differences which.min(abs(diff)) # 3rd degree Polynomial Fit minimal # final choice # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.02430093728E-002 b = 3.10119319672E-001 c = 1.42522409677E-001 d = -7.41188976918E-003 # # predict the insect OTU richness from plant model (y.in <- a+b*6.03+c*6.03^2+d*6.03^3) # 603 tree species in Yinggeling, 603*0.01=6.03 # # estimate the insect OTU richness separately by non-parametric estimation acc.in <- alpha.accum(comm=MBCin, func="nonparametric", runs=1) (Y.in <- acc.in[21,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of insect OTU richness Y.in/(y.in*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.58 0.79 0.71 0.97 0.68 0.93 #### apply to Insecta orders #### #### Coleoptera #### # read the curve.cole.csv into CurveExpert # scale x and y by 0.01 # list candidates based on their ranks # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 4.08214271516E-001 b = 1.19719233635E+000 c = 1.13198458907E+000 # plot the curve yy <- a*(b^(xx*0.01))*((xx*0.01)^c); plot(I(yy*100)~xx) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = -8.02386177767E-003 b = 3.66116076223E-001 c = 1.21361414679E-001 d = 9.05608189465E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -2.31529449518E-002 b = 4.10527247508E-001 c = -2.31220785900E-001 d = 2.12984257422E-002 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 2.34085087456E-002 b = 2.91792633140E-001 c = 1.69154648248E-001 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.h, AICc.3p, AICc.r, AICc.q)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 21 plots to assess their suitability for extrapolation MBCcole_rs <- MBCcole[ransub,] # rs=ransub MBCcole_rs <- MBCcole_rs[,specnumber(MBCcole_rs, MARGIN=2)>0] # 239 -> 180 sac.cole.rs <- specaccum(MBCcole_rs, "random", permutations=9999) plot(sac.cole.rs$richness ~ sac.tree.rs$richness, xlab='Trees', ylab='Coleoptera', main='Accumulated species richness comparison (Yinggeling)') # clear relationship # y <- sac.cole.rs$richness # curve.cole <- data.frame(x=x, y=y) # write.csv(curve.cole, 'curve.cole.rs.csv', row.names=F) # read the curve.cole.rs.csv into CurveExpert # scale x and y by 0.01 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 2.03624578830E-002 b = 2.98643137123E-001 c = 2.33550180333E-001 d = -1.45459666162E-002 f_3p <- a+b*2.97+c*2.97^2+d*2.97^3 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -6.79331954686E-003 b = 3.99699869827E-001 c = -3.18567609739E-001 d = 4.72150845605E-002 f_r <- (a+b*2.97)/(1+c*2.97+d*2.97^2) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 4.67320906693E-001 b = 1.16022800092E+000 c = 1.18759613949E+000 f_h <- a*b^2.97*2.97^c # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_h)*100-dim(MBCcole)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -2.31529449518E-002 b = 4.10527247508E-001 c = -2.31220785900E-001 d = 2.12984257422E-002 # # predict the Coleoptera OTU richness from plant model y.cole <- (a+b*6.03)/(1+c*6.03+d*6.03^2) # # estimate the Coleoptera OTU richness separately by non-parametric estimation acc.cole <- alpha.accum(comm=MBCcole, func="nonparametric", runs=1) Y.cole <- acc.cole[21,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera OTU richness Y.cole/(y.cole*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.62 0.92 0.80 1.20 0.94 1.41 #### Diptera #### # read the curve.di.csv into CurveExpert # scale x and y by 0.01 # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.28375709424E-002 b = 1.59174356933E+000 c = 5.07125245301E-001 d = -2.80585130090E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 1.64752064882E+000 b = -1.75336044469E-001 c = 1.42932082578E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -4.89586900829E-002 b = 1.79096560147E+000 c = -1.86117553593E-001 d = 1.98010068129E-002 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 1.71546803016E+000 b = 1.20729054747E+000 c = 1.40893474503E+000 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.s, AICc.r, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 21 plots to assess their suitability for extrapolation MBCdi_rs <- MBCdi[ransub,] # rs=ransub MBCdi_rs <- MBCdi_rs[,specnumber(MBCdi_rs, MARGIN=2)>0] # 848 -> 644 sac.di.rs <- specaccum(MBCdi_rs, "random", permutations=9999) plot(sac.di.rs$richness ~ sac.tree.rs$richness, xlab='Trees', ylab='Diptera', main='Accumulated species richness comparison (Yinggeling)') # clear relationship # y <- sac.di.rs$richness # curve.di <- data.frame(x=x, y=y) # write.csv(curve.di, 'curve.di.rs.csv', row.names=F) # read the curve.di.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -5.25206854335E-003 b = 1.72457468398E+000 c = -2.44110318477E-001 d = 3.53594446932E-002 f_r <- (a+b*2.97)/(1+c*2.97+d*2.97^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.15636910879E-002 b = 1.50470608206E+000 c = 6.77522668444E-001 d = -6.26620979109E-002 f_3p <- a+b*2.97+c*2.97^2+d*2.97^3 # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 1.80663947621E+000 b = -1.39741841936E-001 c = 1.40686367017E+000 f_s <- a*(2.97-b)^c # comparing the predicted with the actual value diff <- c(f_r, f_3p, f_s)*100-dim(MBCdi)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -4.89586900829E-002 b = 1.79096560147E+000 c = -1.86117553593E-001 d = 1.98010068129E-002 # # predict the Diptera OTU richness from plant model y.di <- (a+b*6.03)/(1+c*6.03+d*6.03^2) # # estimate the Diptera OTU richness by separately non-parametric estimation acc.di <- alpha.accum(comm=MBCdi, func="nonparametric", runs=1) Y.di <- acc.di[21,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di/(y.di*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.73 0.97 0.89 1.18 0.84 1.12 #### Hemiptera #### # read the curve.he.csv into CurveExpert # scale x and y by 0.01 # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.77483837126E-002 b = 2.86436528767E-001 c = 1.64604431466E-001 d = -1.03660411133E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.42038012526E-001 b = -2.07770774148E-001 c = 1.54879794895E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -1.01847617370E+000 b = 2.35378740680E-001 c = 1.52193568265E+000 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=3) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 3.61144629037E-001 b = 1.26538796480E+000 c = 1.52193588349E+000 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.s, AICc.v, AICc.m)) # top three function # re-fit the top three functions for a randomized data set of 15 instead of 21 plots to assess their suitability for extrapolation MBChe_rs <- MBChe[ransub,] # rs=ransub # remove empty columns MBChe_rs <- MBChe_rs[,specnumber(MBChe_rs, MARGIN=2)>0] # 205 -> 159 sac.he.rs <- specaccum(MBChe_rs, "random", permutations=9999) plot(sac.he.rs$richness ~ sac.tree.rs$richness, xlab='Trees', ylab='Hemiptera', main='Accumulated species richness comparison (Yinggeling)') # clear relationship # y <- sac.he.rs$richness # curve.he <- data.frame(x=x, y=y) # write.csv(curve.he, 'curve.he.rs.csv', row.names=F) # read the curve.he.rs.csv into CurveExpert # scale x and y by 0.01 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.26472951245E-002 b = 2.53911356162E-001 c = 2.37074959758E-001 d = -2.52626578606E-002 f_3p <- a+b*2.97+c*2.97^2+d*2.97^3 # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -8.85965661685E-001 b = 1.93011255859E-001 c = 1.50091952739E+000 f_v <- exp(a+b/2.97+c*log(2.97)) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.94017827242E-001 b = -1.70116329101E-001 c = 1.52569896946E+000 f_s <- a*(2.97-b)^c # comparing the predicted with the actual value diff <- c(f_3p, f_v, f_s)*100-dim(MBChe)[2] # getting the differences which.min(abs(diff)) # 3rd degree Polynomial Fit minimal # final choice # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.77483837126E-002 b = 2.86436528767E-001 c = 1.64604431466E-001 d = -1.03660411133E-002 # # predict the Hemiptera OTU richness from plant model y.he <- a+b*6.03+c*6.03^2+d*6.03^3 # # estimate the Hemiptera OTU richness separately by non-parametric estimation acc.he <- alpha.accum(comm=MBChe, func="nonparametric", runs=1) Y.he <- acc.he[21,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera OTU richness Y.he/(y.he*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.59 0.81 0.73 0.99 0.68 0.93 #### Hymenoptera #### # read the curve.hy.csv into CurveExpert # scale x and y by 0.01 # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.15305129011E-002 b = 2.04318284904E-001 c = 1.57956474108E-001 d = -1.52921635821E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0, 450)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.49018023593E-003 b = 2.93773144969E-001 c = -2.57014383193E-001 d = 3.40738255196E-002 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 6.09592255464E-002 b = 6.13384672981E+001 c = 1.97963420779E+001 d = 1.53289634045E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -1.15567313699E+000 b = 1.89637598292E-001 c = 1.45481797914E+000 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=4) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.m, AICc.v)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 21 plots to assess their suitability for extrapolation MBChy_rs <- MBChy[ransub,] # rs=ransub MBChy_rs <- MBChy_rs[,specnumber(MBChy_rs, MARGIN=2)>0] # 163 -> 137 sac.hy.rs <- specaccum(MBChy_rs, "random", permutations=9999) plot(sac.hy.rs$richness ~ sac.tree.rs$richness, xlab='Trees', ylab='Hymenoptera', main='Accumulated species richness comparison (Yinggeling)') # clear relationship # y <- sac.hy.rs$richness # curve.hy <- data.frame(x=x, y=y) # write.csv(curve.hy, 'curve.hy.rs.csv', row.names=F) # read the curve.hy.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 9.10445014258E-003 b = 2.97120911835E-001 c = -3.32728575835E-001 d = 5.29085050634E-002 f_r <- (a+b*2.97)/(1+c*2.97+d*2.97^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.22555363680E-002 b = 2.12475684976E-001 c = 1.97897570636E-001 d = -1.81709256172E-002 f_3p <- a+b*2.97+c*2.97^2+d*2.97^3 # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 6.85050503231E-002 b = 4.64688651337E+001 c = 1.68747924733E+001 d = 1.60949208116E+000 f_m <- (a*b+c*2.97^d)/(b+2.97^d) # comparing the predicted with the actual value diff <- c(f_r, f_3p, f_m)*100-dim(MBChy)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.49018023593E-003 b = 2.93773144969E-001 c = -2.57014383193E-001 d = 3.40738255196E-002 # # predict the Hymenoptera OTU richness from plant model y.hy <- (a+b*6.03)/(1+c*6.03+d*6.03^2) # # estimate the Hymenoptera OTU richness separately by non-parametric estimation acc.hy <- alpha.accum(comm=MBChy, func="nonparametric", runs=1) Y.hy <- acc.hy[21,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy/(y.hy*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.97 1.27 1.15 1.50 0.99 1.30 #### Lepidoptera #### # read the curve.le.csv into CurveExpert # scale x and y by 0.01 # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.33069845437E-002 b = 3.39483732290E-001 c = 2.06008273792E-001 d = -7.98512841665E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.81320825765E-001 b = -2.46975896346E-001 c = 1.65238836846E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 4.13005042855E-001 b = 1.32438238988E+000 c = 1.61292601830E+000 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=3) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -8.84292161721E-001 b = 2.80944802405E-001 c = 1.61292306077E+000 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=4) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.s, AICc.m, AICc.v)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 21 plots to assess their suitability for extrapolation MBCle_rs <- MBCle[ransub,] # rs=ransub MBCle_rs <- MBCle_rs[,specnumber(MBCle_rs, MARGIN=2)>0] # 263 -> 203 sac.le.rs <- specaccum(MBCle_rs, "random", permutations=9999) plot(sac.le.rs$richness ~ sac.tree.rs$richness, xlab='Trees', ylab='Lepidoptera', main='Accumulated species richness comparison (Yinggeling)') # clear relationship # y <- sac.le.rs$richness # curve.le <- data.frame(x=x, y=y) # write.csv(curve.le, 'curve.le.rs.csv', row.names=F) # read the curve.le.rs.csv into CurveExpert # scale x and y by 0.01 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.37679168594E-002 b = 2.87374225850E-001 c = 3.15720725986E-001 d = -3.04139088037E-002 f_3p <- a+b*2.97+c*2.97^2+d*2.97^3 # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 5.00255227414E-001 b = 1.21607851083E+000 c = 1.55983097844E+000 f_m <- a*b^(1/2.97)*2.97^c # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 4.78601466672E-001 b = -1.64440266016E-001 c = 1.58398505261E+000 f_s <- a*(2.97-b)^c # comparing the predicted with the actual value diff <- c(f_3p, f_m, f_s)*100-dim(MBCle)[2] # getting the differences which.min(abs(diff)) # 3rd degree Polynomial Fit minimal # final choice # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.33069845437E-002 b = 3.39483732290E-001 c = 2.06008273792E-001 d = -7.98512841665E-003 # # predict the Lepidoptera species richness from plant model y.le <- a+b*6.03+c*6.03^2+d*6.03^3 # # estimate the Lepidoptera species richness separately by non-parametric estimation acc.le <- alpha.accum(comm=MBCle, func="nonparametric", runs=1) Y.le <- acc.le[21,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le/(y.le*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.54 0.77 0.68 0.96 0.66 0.94 #### calculate the fitness #### dat <- data.frame(Insect=c(Y.in[c(2,4,6)],y.in*1000), Cole=c(Y.cole[c(2,4,6)],y.cole*100), Di=c(Y.di[c(2,4,6)],y.di*100), He=c(Y.he[c(2,4,6)],y.he*100), Hy=c(Y.hy[c(2,4,6)],y.hy*100), Le=c(Y.le[c(2,4,6)],y.le*100), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P','plant.model')) # only present P-corrected versions dat <- data.frame(t(dat)) #### calculate the R^2 fitted to the y=x model #### options(digits=4) ## Jack1inP yi <- dat[-1, ]$Jack1inP # only include individual orders ym <- mean(yi) fi <- dat[-1, ]$plant.model # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9579 ## Jack2inP yi <- dat[-1, ]$Jack2inP ym <- mean(yi) SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9274 ## Chao2P yi <- dat[-1, ]$Chao2P ym <- mean(yi) SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9274 #### calculate the correlations between two estimates #### cor.test(y=dat[-1, ]$Jack1inP, x=dat[-1, ]$plant.model, method='pearson') # r=0.988 cor.test(y=dat[-1, ]$Jack2inP, x=dat[-1, ]$plant.model, method='pearson') # r=0.9893 cor.test(y=dat[-1, ]$Chao2P, x=dat[-1, ]$plant.model, method='pearson') # r=0.9803 options(digits=2) ``` #### _Mengsong, Yunnan_ There are three habitats in Mengsong, naming mature forest (n=10), regenerating forest (n=12) and open land (n=6). We do the analyses as the following order: 1. all habitats combined 2. forests only (mature forest + regenerating forest) 3. open land only ##### __1. all habitats combined__ ```{r alpha_Mengsong_all_25_alternative_functions} ### Arachnida # read the curve.sp1.csv, curve.sp2.csv into CurveExpert # scale x by 0.01 and y by 0.1 ### sample at the end of wet season (hereafter: wet season) ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.64816394316E-002 b = 8.44144814112E-001 c = -3.94665908328E-002 d = 2.03740591914E-003 # check the curve xx <- 1:1623 # max(x.plant) = 1623 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*10)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # n <- 28 # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.36619936467E-002 b = 8.20388885597E-001 c = 4.39589972155E-002 d = -2.14156355114E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*10)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.72638654274E-001 b = 1.61468797629E+002 c = 1.19745720452E+002 d = 1.18769197846E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.43080456893E+001 b = 4.40905960027E+001 c = 1.59794854193E-002 d = 1.22258180177E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.3p, AICc.m, AICc.w)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation ransub <- sample(x=1:28, size=20, replace=FALSE) # ransub=randomized subdata MBCsp1_rs <- MBCsp1[ransub,] # rs=ransub Plant_rs <- Plant[ransub,] # rs=ransub # remove empty columns MBCsp1_rs <- MBCsp1_rs[,specnumber(MBCsp1_rs, MARGIN=2)>0] # 84 -> 77 Plant_rs <- Plant_rs[,specnumber(Plant_rs, MARGIN=2)>0] # 807 -> 681 sac.plant.rs <- specaccum(comm=Plant_rs, method="random", permutations=9999) sac.sp1.rs <- specaccum(comm=MBCsp1_rs, method="random", permutations=9999) plot(sac.sp1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.sp1.rs$richness # x <- sac.plant.rs$richness # curve.sp1 <- data.frame(x=x, y=y1) # write.csv(curve.sp1, 'curve.sp1.rs.csv', row.names=F) # read the curve.sp1.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.43391746211E-002 b = 8.51832245554E-001 c = 4.72669389615E-002 d = -9.93894470079E-004 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # 807 vasular plant species found in the survey, 807*0.01=8.07; f: fitted, 3p: 3rd degree Polynomial # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.09078495773E-003 b = 8.70850822829E-001 c = -4.48038071342E-002 d = 1.64261287617E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.03106953981E-001 b = 6.89175247969E+003 c = 4.98332809427E+003 d = 1.21871819805E+000 f_m <- (a*b+c*8.07^d)/(b+8.07^d) # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_m)*10-dim(MBCsp1)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.72638654274E-001 b = 1.61468797629E+002 c = 1.19745720452E+002 d = 1.18769197846E+000 # # estimate the plant species richness by non-parametric estimation (acc.plant <- alpha.accum(comm=Plant, func="nonparametric", runs=1)) (x.plant <- acc.plant[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # predict the spider OTU richness from plant model (y.sp1 <- (a*b+c*(x.plant*0.01)^d)/(b+(x.plant*0.01)^d)) # # estimate the spider OTU richness separately by non-parametric estimation acc.sp1 <- alpha.accum(comm=MBCsp1, func="nonparametric", runs=1) (Y.sp1 <- acc.sp1[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of Arachnida OTU richness Y.sp1/(y.sp1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 1.01 0.99 1.01 0.96 0.97 ### sample at the end of dry season (hereafter: dry season) ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 7.42150887533E-002 b = 7.99413960672E-001 c = -5.33325328935E-002 d = 3.30439121071E-003 # check the curve yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*10)~xx, ylim=c(0,180)) # ok, asymptote # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 9.98262348730E-002 b = 7.61687963525E-001 c = 6.21158525248E-002 d = -3.75404128694E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*10)~xx, col=2) # drop # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.68331545898E+001 b = 2.65665778766E+001 c = 2.50125743452E-002 d = 1.27924890949E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.67024164819E-001 b = 7.11863452616E+001 c = 4.75193664140E+001 d = 1.28547582917E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 8.63845333114E-001 b = 9.95002324398E-001 c = 1.10580503385E+000 yy <- a*b^(xx*0.01)*(xx*0.01)^c; points(I(yy*10)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) order(c(AICc.r, AICc.w, AICc.m, AICc.h)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCsp2_rs <- MBCsp2[ransub,] # rs=ransub # remove empty columns MBCsp2_rs <- MBCsp2_rs[,specnumber(MBCsp2_rs, MARGIN=2)>0] # 83 -> 75 sac.sp2.rs <- specaccum(comm=MBCsp2_rs, method="random", permutations=9999) plot(sac.sp2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.sp2.rs$richness # curve.sp2 <- data.frame(x=x, y=y2) # write.csv(curve.sp2, 'curve.sp2.rs.csv', row.names=F) # read the curve.sp2.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 9.93749985064E-003 b = 8.64825805232E-001 c = -6.08758594544E-002 d = 4.32198765480E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # 807 vasular plant species found in the survey, 807*0.01=8.07; f: fitted, r: Rational Function # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.51279428048E+001 b = 2.49194936694E+001 c = 2.93738257873E-002 d = 1.28718625978E+000 f_w <- a-b*exp(-c*8.07^d) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.06866119266E-001 b = 6.12130905303E+001 c = 4.51142298196E+001 d = 1.29112482445E+000 f_m <- (a*b+c*8.07^d)/(b+8.07^d) # comparing the predicted with the actual value diff <- c(f_r, f_w, f_m)*10-dim(MBCsp2)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 7.42150887533E-002 b = 7.99413960672E-001 c = -5.33325328935E-002 d = 3.30439121071E-003 # # predict the spider OTU richness from plant model (y.sp2 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2)) # # estimate the spider OTU richness separately by non-parametric estimation acc.sp2 <- alpha.accum(comm=MBCsp2, func="nonparametric", runs=1) (Y.sp2 <- acc.sp2[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of Arachnida OTU richness Y.sp2/(y.sp2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.11 1.04 1.16 0.91 0.99 ### Insecta # read curve.in1.csv, curve.in2.csv into CurveExpert # scale x by 0.01, and y by 0.001 ### sample at the end of wet season (hereafter: wet season) ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.55969981483E-002 b = 2.67973281544E-001 c = 1.99040578281E-004 d = -3.00790768840E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*1000)~xx, ylim=c(0,3500)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.68142850269E-002 b = 2.66171985528E-001 c = -3.27059305986E-003 d = 1.37955870521E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*1000)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.55487850991E+000 b = 5.47191832092E+000 c = 4.50754287875E-002 d = 1.10435105916E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*1000)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 8.16386802416E-002 b = 3.86302757404E+001 c = 9.66668372081E+000 d = 1.10943766894E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*1000)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.w, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCin1_rs <- MBCin1[ransub,] # rs=ransub # remove empty columns MBCin1_rs <- MBCin1_rs[,specnumber(MBCin1_rs, MARGIN=2)>0] # 2073 -> 1759 sac.in1.rs <- specaccum(comm=MBCin1_rs, method="random", permutations=9999) plot(sac.in1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Insecta', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.in1.rs$richness # curve.in1 <- data.frame(x=x, y=y1) # write.csv(curve.in1, 'curve.in1.rs.csv', row.names=F) # read the curve.in1.rs.csv into CurveExpert # scale x by 0.01 and y by 0.001 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.65311393529E-002 b = 2.58898494202E-001 c = -8.59699970526E-004 d = -3.44901368071E-005 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # 807 vasular plant species found in the survey, 807*0.01=8.07; f: fitted, 3p: 3rd degree Polynomial # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.65606710344E-002 b = 2.58997791311E-001 c = 3.19606114051E-003 d = 1.61580542681E-004 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.55326688053E+000 b = 5.45539230516E+000 c = 3.93509999142E-002 d = 1.15611110738E+000 f_w <- a-b*exp(-c*8.07^d) # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_w)*1000-dim(MBCin1)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.68142850269E-002 b = 2.66171985528E-001 c = -3.27059305986E-003 d = 1.37955870521E-003 # # predict the insect OTU richness from plant model y.in1 <- (a+b*(x.plant*0.01))/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the insect OTU richness by non-parametric estimation (acc.in1 <- alpha.accum(comm=MBCin1, func="nonparametric", runs=1)) (Y.in1 <- acc.in1[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of insect OTU richness Y.in1/(y.in1*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.05 1.05 1.08 0.99 1.01 ### sample at the end of dry season (hereafter: dry season) ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 6.08693020681E-002 b = 2.90019933721E-001 c = 8.29946992891E-004 d = -4.54473333300E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*1000)~xx, ylim=c(0, 4000)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 6.29636570127E-002 b = 2.86818172563E-001 c = -6.79298041836E-003 d = 1.95354916645E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*1000)~xx, col=2) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.80629824999E+000 b = 4.70473784299E+000 c = 5.47751492706E-002 d = 1.14403544073E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*1000)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 9.85058760938E-002 b = 3.06605563400E+001 c = 8.09656936096E+000 d = 1.15118207847E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*1000)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 3.35284247180E-002 b = 3.15774214493E-001 c = -5.52014329645E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*1000)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.q)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCin2_rs <- MBCin2[ransub,] # rs=ransub # remove empty columns MBCin2_rs <- MBCin2_rs[,specnumber(MBCin2_rs, MARGIN=2)>0] # 2215 -> 1988 sac.in2.rs <- specaccum(comm=MBCin2_rs, method="random", permutations=9999) plot(sac.in2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Insecta', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.in2.rs$richness # curve.in2 <- data.frame(x=x, y=y2) # write.csv(curve.in2, 'curve.in2.rs.csv', row.names=F) # read the curve.in2.rs.csv into CurveExpert # scale x by 0.01 and y by 0.001 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.68931652752E-002 b = 3.06634601829E-001 c = 7.82542349489E-004 d = 1.46952475662E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # 807 vascular plant species found in the survey, 807*0.01=8.07, f = fitted, r = Rational Function # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 7.70580827742E-002 b = 3.30622896282E+001 c = 9.48170896789E+000 d = 1.11167578610E+000 f_m <- (a*b+c*8.07^d)/(b+8.07^d) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.11437437529E+000 b = 5.02842526375E+000 c = 5.48155982484E-002 d = 1.12537024844E+000 f_w <- a-b*exp(-c*8.07^d) # comparing the predicted with the actual value diff <- c(f_r, f_m, f_w)*1000-dim(MBCin2)[2] # getting the differences which.min(abs(diff)) # Weibull Model minimal # final choice # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.80629824999E+000 b = 4.70473784299E+000 c = 5.47751492706E-002 d = 1.14403544073E+000 # # predict the insect OTU richness from plant model y.in2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation (acc.in2 <- alpha.accum(comm=MBCin2, func="nonparametric", runs=1)) (Y.in2 <- acc.in2[28,c(10,11,14,15,18,19)]) # withdraw Jackknif1, Jackknif2 and Chao2 estimates, as well as their P-corrected versions (Lopez et al. 2012) # # compare the two estimates of insect OTU richness Y.in2/(y.in2*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 1.01 1.02 0.94 0.94 #### apply to Insecta orders #### #### Coleoptera #### # read curve.cole1.csv, curve.cole2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 6.91322024950E-002 b = 3.83837359150E-001 c = -3.13314240714E-002 d = 1.49062673548E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*100)~xx) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 7.30795299221E-002 b = 3.79989954719E-001 c = 1.46817499347E-002 d = -6.54747400068E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -1.00290366106E+000 b = 2.37653437115E-001 c = 1.09985986961E+000 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=3) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 3.66812617527E-001 b = 1.26826898017E+000 c = 1.09985994694E+000 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.3p, AICc.v, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCcole1_rs <- MBCcole1[ransub,] # rs=ransub # remove empty columns MBCcole1_rs <- MBCcole1_rs[,specnumber(MBCcole1_rs, MARGIN=2)>0] # 375 -> 297 sac.cole1.rs <- specaccum(MBCcole1_rs, "random", permutations=9999) plot(sac.cole1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.cole1.rs$richness # curve.cole1 <- data.frame(x=x, y=y1) # write.csv(curve.cole1, 'curve.cole1.rs.csv', row.names=F) # read the curve.cole1.rs.csv into CurveExpert # scale x and y by 0.01 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.43446453098E-002 b = 3.57240862749E-001 c = 1.02715165128E-002 d = 1.37348876751E-005 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # 807 vasular plant species found in the survey, 807*0.01=8.07; f: fitted, 3p: 3rd degree Polynomial # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.32928217505E-002 b = 3.57149607731E-001 c = -2.72594687118E-002 d = 4.98027419091E-004 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -1.21144247564E+000 b = 3.62056269805E-001 c = 1.16969474977E+000 f_v <- exp(a+b/8.07+c*log(8.07)) # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_v)*100-dim(MBCcole1)[2] # getting the differences which.min(abs(diff)) # 3rd degree Polynomial Fit minimal # final choice # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 7.30795299221E-002 b = 3.79989954719E-001 c = 1.46817499347E-002 d = -6.54747400068E-004 # # predict the Coleoptera species richness from plant model y.cole1 <- a+b*x.plant*0.01+c*(x.plant*0.01)^2+d*(x.plant*0.01)^3 # # estimate the Coleoptera species richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1, func="nonparametric", runs=1) Y.cole1 <- acc.cole1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole1/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.03 1.02 1.07 1.00 1.04 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.09336091814E-001 b = 7.27612345479E-001 c = 1.83251910754E-002 d = -2.16514629950E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,1000)) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.12554589646E-001 b = 7.22645808119E-001 c = -2.48707995166E-002 d = 2.84362723161E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.28710901607E+001 b = 1.26362449280E+001 c = 5.02841021281E-002 d = 1.19983803196E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.50700434374E-001 b = 3.24286892113E+001 c = 2.04218918580E+001 d = 1.23125358971E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.w, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCcole2_rs <- MBCcole2[ransub,] # rs=ransub # remove empty columns MBCcole2_rs <- MBCcole2_rs[,specnumber(MBCcole2_rs, MARGIN=2)>0] # 603 -> 532 sac.cole2.rs <- specaccum(MBCcole2_rs, "random", permutations=9999) plot(sac.cole2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.cole2.rs$richness # curve.cole2 <- data.frame(x=x, y=y2) # write.csv(curve.cole2, 'curve.cole2.rs.csv', row.names=F) # read the curve.cole2.rs.csv into CurveExpert # scale x and y by 0.01 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 6.13187050199E-002 b = 7.91508254266E-001 c = 8.50654842067E-003 d = -1.65631234079E-003 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 6.35736479779E-002 b = 7.87772598532E-001 c = -1.21222144003E-002 d = 2.20507452399E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.50696512975E+001 b = 1.49232013874E+001 c = 4.90165619610E-002 d = 1.12746066202E+000 f_w <- a-b*exp(-c*8.07^d) # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_w)*100-dim(MBCcole2)[2] # getting the differences which.min(abs(diff)) # 3rd degree Polynomial Fit minimal # final choice # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.09336091814E-001 b = 7.27612345479E-001 c = 1.83251910754E-002 d = -2.16514629950E-003 # # predict the Coleoptera species richness from plant model y.cole2 <- a+b*x.plant*0.01+c*(x.plant*0.01)^2+d*(x.plant*0.01)^3 # # estimate the Coleoptera species richness by non-parametric estimation acc.cole2 <- alpha.accum(comm=MBCcole2, func="nonparametric", runs=1) Y.cole2 <- acc.cole2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole2/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.06 1.14 1.10 1.31 0.97 1.08 #### Diptera #### # read curve.di1.csv, curve.di2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 2.40329490255E-001 b = 5.97545993072E-001 c = -1.00753768626E-002 d = -5.08087100057E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,700)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.48226199134E-001 b = 5.88256829203E-001 c = 8.18702782416E-003 d = 2.15494718600E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.31496568475E+000 b = 7.01103492934E+000 c = 7.76421581610E-002 d = 1.11301511276E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 2.09763236819E-001 b = 6.26338480711E-001 c = -1.71745809826E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 3.29861098285E-001 b = 1.99899190658E+001 c = 1.07777036093E+001 d = 1.16964350195E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.q, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCdi1_rs <- MBCdi1[ransub,] # rs=ransub # remove empty columns MBCdi1_rs <- MBCdi1_rs[,specnumber(MBCdi1_rs, MARGIN=2)>0] # 414 -> 363 sac.di1.rs <- specaccum(MBCdi1_rs, "random", permutations=9999) plot(sac.di1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.di1.rs$richness # curve.di1 <- data.frame(x=x, y=y1) # write.csv(curve.di1, 'curve.di1.rs.csv', row.names=F) # read the curve.di1.rs.csv into CurveExpert # scale x and y by 0.01 # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 2.23064177858E-001 b = 5.77379142375E-001 c = -1.12976423588E-002 f_q <- a+b*8.07+c*8.07^2 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.21651315187E-001 b = 5.83091629104E-001 c = 1.97814769694E-002 d = 4.26526579123E-004 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 9.44537688296E+000 b = 9.16958547341E+000 c = 5.79055105932E-002 d = 1.07420577080E+000 f_w <- a-b*exp(-c*8.07^d) # comparing the predicted with the actual value diff <- c(f_q, f_r, f_w)*100-dim(MBCdi1)[2] # getting the differences which.min(abs(diff)) # Quadratic Fit minimal # final choice # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 2.09763236819E-001 b = 6.26338480711E-001 c = -1.71745809826E-002 # # predict the Diptera species richness from plant model y.di1 <- a+b*x.plant*0.01+c*(x.plant*0.01)^2 # # estimate the Diptera species richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1, func="nonparametric", runs=1) Y.di1 <- acc.di1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di1/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.04 1.05 1.08 0.96 0.98 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 2.25165919059E-001 b = 6.31065331305E-001 c = -1.34355025783E-002 d = -5.92821242615E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,700)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.37404874422E-001 b = 6.15116629331E-001 c = 8.29975646735E-003 d = 2.93713549192E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.89502104051E-001 b = 6.64659567999E-001 c = -2.17186473532E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=3) # drop # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.35855308799E+000 b = 6.05053321809E+000 c = 9.24816900352E-002 d = 1.14120084794E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 3.46876020303E-001 b = 1.62816502352E+001 c = 8.90792853211E+000 d = 1.22675666588E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 7.56849825859E+000 b = 1.01997509646E+000 c = 9.30833643482E-002 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*100)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.e)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCdi2_rs <- MBCdi2[ransub,] # rs=ransub # remove empty columns MBCdi2_rs <- MBCdi2_rs[,specnumber(MBCdi2_rs, MARGIN=2)>0] # 413 -> 381 sac.di2.rs <- specaccum(MBCdi2_rs, "random", permutations=9999) plot(sac.di2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.di2.rs$richness # curve.di2 <- data.frame(x=x, y=y2) # write.csv(curve.di2, 'curve.di2.rs.csv', row.names=F) # read the curve.di2.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.05728622522E-001 b = 6.71188638810E-001 c = 1.71092725387E-002 d = 2.94160110252E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.51079720292E+000 b = 6.25223752875E+000 c = 1.00980052306E-001 d = 1.10493973900E+000 f_w <- a-b*exp(-c*8.07^d) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.90941536397E-001 b = 1.50522824731E+001 c = 9.40640186980E+000 d = 1.17306487839E+000 f_m <- (a*b+c*8.07^d)/(b+8.07^d) # comparing the predicted with the actual value diff <- c(f_r, f_w, f_m)*100-dim(MBCdi2)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.37404874422E-001 b = 6.15116629331E-001 c = 8.29975646735E-003 d = 2.93713549192E-003 # # predict the Diptera species richness from plant model y.di2 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the Diptera species richness by non-parametric estimation acc.di2 <- alpha.accum(comm=MBCdi2, func="nonparametric", runs=1) Y.di2 <- acc.di2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di2/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.05 1.06 1.05 1.09 0.96 0.98 #### Hemiptera #### # read curve.he1.csv, curve.he2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 6.99159121260E-002 b = 5.39662790889E-001 c = 3.61112610570E-003 d = -5.91440377723E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 7.08451957451E-002 b = 5.38067665643E-001 c = -7.38351742191E-003 d = 1.13913761230E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.52633131386E+001 b = 1.51396527382E+001 c = 3.29523802565E-002 d = 1.09955448221E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.24606823995E-001 b = 5.41055378384E+001 c = 2.70903237407E+001 d = 1.10538950881E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.w, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBChe1_rs <- MBChe1[ransub,] # rs=ransub # remove empty columns MBChe1_rs <- MBChe1_rs[,specnumber(MBChe1_rs, MARGIN=2)>0] # 435 -> 358 sac.he1.rs <- specaccum(MBChe1_rs, "random", permutations=9999) plot(sac.he1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.he1.rs$richness # curve.he1 <- data.frame(x=x, y=y1) # write.csv(curve.he1, 'curve.he1.rs.csv', row.names=F) # read the curve.he1.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.30533608199E-002 b = 4.95982433493E-001 c = -1.75373206678E-002 d = 1.68606406372E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.38352053824E-002 b = 4.95496114275E-001 c = 9.49225540046E-003 d = -9.18660033697E-004 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.38757991148E+001 b = 1.37581652338E+001 c = 3.26833297433E-002 d = 1.13735175502E+000 f_w <- a-b*exp(-c*8.07^d) # comparing the predicted with the actual value diff <- c(f_r, f_3p, f_w)*100-dim(MBChe1)[2] # getting the differences which.min(abs(diff)) # Weibull Model minimal # final choice # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.52633131386E+001 b = 1.51396527382E+001 c = 3.29523802565E-002 d = 1.09955448221E+000 # # predict the Hemiptera species richness from plant model y.he1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1, func="nonparametric", runs=1) Y.he1 <- acc.he1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he1/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 1.02 1.03 0.98 0.99 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 8.11299549042E-002 b = 4.30017219002E-001 c = 9.84838505141E-003 d = -9.29938604040E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,700)) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 8.09886516284E-002 b = 4.29367904441E-001 c = -2.10813305258E-002 d = 1.95668800331E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.41693129432E-001 b = 4.92427047370E+001 c = 1.91749661233E+001 d = 1.16348042611E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 9.68735748429E+000 b = 9.52259953842E+000 c = 3.85157069903E-002 d = 1.19217931986E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.m, AICc.w)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBChe2_rs <- MBChe2[ransub,] # rs=ransub # remove empty columns MBChe2_rs <- MBChe2_rs[,specnumber(MBChe2_rs, MARGIN=2)>0] # 370 -> 326 sac.he2.rs <- specaccum(MBChe2_rs, "random", permutations=9999) plot(sac.he2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.he2.rs$richness # curve.he2 <- data.frame(x=x, y=y2) # write.csv(curve.he2, 'curve.he2.rs.csv', row.names=F) # read the curve.he2.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.24307583545E-002 b = 4.54138673999E-001 c = -1.09870998399E-002 d = 7.88449707396E-004 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.27431924242E-002 b = 4.54036081474E-001 c = 5.28556835550E-003 d = -3.79940574365E-004 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 8.93747465044E-002 b = 9.64966150244E+001 c = 4.04977268314E+001 d = 1.09752035860E+000 f_m <- (a*b+c*8.07^d)/(b+8.07^d) # comparing the predicted with the actual value diff <- c(f_r, f_3p, f_m)*100-dim(MBChe2)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.41693129432E-001 b = 4.92427047370E+001 c = 1.91749661233E+001 d = 1.16348042611E+000 # # predict the Hemiptera species richness from plant model y.he2 <- (a*b+c*(x.plant*0.01)^d)/(b+(x.plant*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he2 <- alpha.accum(comm=MBChe2, func="nonparametric", runs=1) Y.he2 <- acc.he2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he2/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 0.99 0.98 0.98 0.91 0.91 #### Hymenoptera #### # read curve.hy1.csv, curve.hy2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 9.43715625734E-002 b = 5.85275480907E-001 c = -3.74699920287E-003 d = -9.16931567204E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,700)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.03764514665E-001 b = 5.72051777977E-001 c = -2.72945677516E-003 d = 2.68900153577E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Calculate AICc by hand Resid <- as.numeric(readClipboard(format = 1, raw = F)) K <- 4 AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.16960477594E+000 b = 6.99196064676E+000 c = 7.39194619695E-002 d = 1.15376235794E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.03117059973E-001 b = 2.09869563072E+001 c = 1.05942460011E+001 d = 1.21304161188E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 3.92094404411E-002 b = 6.37236534065E-001 c = -1.65587481313E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.q)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBChy1_rs <- MBChy1[ransub,] # rs=ransub # remove empty columns MBChy1_rs <- MBChy1_rs[,specnumber(MBChy1_rs, MARGIN=2)>0] # 409 -> 353 sac.hy1.rs <- specaccum(MBChy1_rs, "random", permutations=9999) plot(sac.hy1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.hy1.rs$richness # curve.hy1 <- data.frame(x=x, y=y1) # write.csv(curve.hy1, 'curve.hy1.rs.csv', row.names=F) # read the curve.hy1.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.78939180577E-002 b = 5.77009036835E-001 c = 1.44281542715E-002 d = 6.70238497925E-004 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.11588731665E+001 b = 1.10738004122E+001 c = 5.01090591514E-002 d = 1.04588287947E+000 f_w <- a-b*exp(-c*8.07^d) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 8.94750923060E-002 b = 3.44250337560E+001 c = 1.90992336728E+001 d = 1.05779056090E+000 f_m <- (a*b+c*8.07^d)/(b+8.07^d) # comparing the predicted with the actual value diff <- c(f_r, f_w, f_m)*100-dim(MBChy1)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.03117059973E-001 b = 2.09869563072E+001 c = 1.05942460011E+001 d = 1.21304161188E+000 # # predict the Diptera species richness from plant model y.hy1 <- (a*b+c*(x.plant*0.01)^d)/(b+(x.plant*0.01)^d) # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy1/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.00 1.00 1.00 0.92 0.91 ### dry season ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 6.95780674336E-002 b = 5.03358219912E-001 c = 2.25246678200E-002 d = -5.33060525720E-004 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*100)~xx) # ok # # Calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 7.20782847500E-002 b = 4.98539333582E-001 c = -9.94466532037E-003 d = 2.93721576277E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 5.55805163699E-001 b = 9.98434354460E-001 c = 9.01186218320E-001 yy <- a*b^(xx*0.01)*(xx*0.01)^c; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -5.77582711311E-001 b = -9.07555755734E-003 c = 8.91176719722E-001 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=4) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.3p, AICc.h, AICc.v)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBChy2_rs <- MBChy2[ransub,] # rs=ransub # remove empty columns MBChy2_rs <- MBChy2_rs[,specnumber(MBChy2_rs, MARGIN=2)>0] # 360 -> 317 sac.hy2.rs <- specaccum(MBChy2_rs, "random", permutations=9999) plot(sac.hy2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.hy2.rs$richness # curve.hy2 <- data.frame(x=x, y=y2) # write.csv(curve.hy2, 'curve.hy2.rs.csv', row.names=F) # read the curve.hy2.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.50105242919E-002 b = 5.21654638241E-001 c = 2.62447392328E-002 d = -8.89529424605E-004 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 5.60625577487E-001 b = 9.99114456921E-001 c = 9.06527456208E-001 f_h <- a*b^8.07*8.07^c # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.71792147359E-002 b = 5.16868222849E-001 c = -1.19552050995E-002 d = 4.71610717712E-004 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # comparing the predicted with the actual value diff <- c(f_r, f_h, f_3p)*100-dim(MBChy2)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 5.55805163699E-001 b = 9.98434354460E-001 c = 9.01186218320E-001 # # predict the insect OTU richness from plant model y.hy2 <- a*b^(x.plant*0.01)*(x.plant*0.01)^c # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy2 <- alpha.accum(comm=MBChy2, func="nonparametric", runs=1) Y.hy2 <- acc.hy2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy2/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 0.98 0.99 0.98 0.96 0.94 #### Lepidoptera #### # read curve.le1.csv, curve.le2.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.64878349324E-001 b = 9.38570951926E-001 c = 7.94640495253E-003 d = -1.42217025318E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*10)~xx, ylim=c(0,150)) # ok # # Calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.67857286061E-001 b = 9.30379431311E-001 c = -1.02838983863E-002 d = 1.60015496946E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.29022433638E+001 b = 2.23654888062E+001 c = 3.96794497202E-002 d = 1.09903971460E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 5.35227064150E-001 b = 4.44065425990E+001 c = 4.00442012739E+001 d = 1.10449885628E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.w, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCle1_rs <- MBCle1[ransub,] # rs=ransub # remove empty columns MBCle1_rs <- MBCle1_rs[,specnumber(MBCle1_rs, MARGIN=2)>0] # 78 -> 68 sac.le1.rs <- specaccum(MBCle1_rs, "random", permutations=9999) plot(sac.le1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.le1.rs$richness # curve.le1 <- data.frame(x=x, y=y1) # write.csv(curve.le1, 'curve.le1.rs.csv', row.names=F) # read the curve.le1.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 3.58632015169E-001 b = 1.04802300614E+000 c = 3.64501624687E-002 d = -3.17774369628E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.66363093274E-001 b = 1.02237739039E+000 c = -2.94411933641E-002 d = 2.67716645952E-003 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.07767344148E+002 b = 1.07255664421E+002 c = 8.14272438706E-003 d = 1.04306265908E+000 f_w <- a-b*exp(-c*8.07^d) # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_w)*10-dim(MBCle1)[2] # getting the differences which.min(abs(diff)) # Weibull Model minimal # final choice # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.29022433638E+001 b = 2.23654888062E+001 c = 3.96794497202E-002 d = 1.09903971460E+000 # # predict the insect OTU richness from plant model y.le1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le1 <- alpha.accum(comm=MBCle1, func="nonparametric", runs=1) Y.le1 <- acc.le1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le1/(y.le1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 0.99 1.01 1.00 0.94 0.93 ### dry season ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.23892823263E-001 b = 8.90525631792E-001 c = -3.19546868353E-002 d = 8.85137757657E-004 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*10)~xx) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 4.02540923514E-001 b = 9.20863758336E-001 c = 2.59289141391E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*10)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.21015198547E-001 b = 9.03461549176E-001 c = 3.02196804151E-002 d = -3.07088366151E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 6.43547164563E-001 b = -8.52380731259E-001 c = 1.23040295374E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*10)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.q, AICc.3p, AICc.s)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCle2_rs <- MBCle2[ransub,] # rs=ransub # remove empty columns MBCle2_rs <- MBCle2_rs[,specnumber(MBCle2_rs, MARGIN=2)>0] # 95->82 sac.le2.rs <- specaccum(MBCle2_rs, "random", permutations=9999) plot(sac.le2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.le2.rs$richness # curve.le2 <- data.frame(x=x, y=y2) # write.csv(curve.le2, 'curve.le2.rs.csv', row.names=F) # read the curve.le2.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 3.87903864678E-001 b = 9.42713532256E-001 c = -3.47679616102E-002 d = 1.41242645516E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.89667316897E-001 b = 9.50411409083E-001 c = 3.66464274227E-002 d = -1.09252693838E-003 f_3p <- a+b*8.07+c*8.07^2+d*8.07^3 # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 3.48286173042E-001 b = 9.95365306744E-001 c = 2.36688290438E-002 f_q <- a+b*8.07+c*8.07^2 # comparing the predicted with the actual value diff <- c(f_r, f_3p, f_q)*10-dim(MBCle2)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.23892823263E-001 b = 8.90525631792E-001 c = -3.19546868353E-002 d = 8.85137757657E-004 # # predict the Lepidoptera species richness from plant model y.le2 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the Lepidoptera species richness by non-parametric estimation acc.le2 <- alpha.accum(comm=MBCle2, func="nonparametric", runs=1) Y.le2 <- acc.le2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le2/(y.le2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.98 0.98 0.96 0.98 0.95 0.96 #### Psocoptera #### # read curve.ps1.csv, curve.ps2.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = -1.60131624319E-001 b = 8.98363989721E+000 c = 1.66695781905E+001 d = 9.19895682737E-001 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); plot(I(yy*10)~xx) # ok # # Calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.19947684582E+001 b = 1.23050284218E+001 c = 1.61568848436E-001 d = 8.34503171577E-001 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -2.49125637186E-002 b = 1.74691348063E+000 c = 1.29350274344E-001 d = -9.86217087610E-004 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 1.47975669351E+001 b = 8.75980281638E+000 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*10)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.m, AICc.w, AICc.r, AICc.s)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCps1_rs <- MBCps1[ransub,] # rs=ransub # remove empty columns MBCps1_rs <- MBCps1_rs[,specnumber(MBCps1_rs, MARGIN=2)>0] # 71 -> 64 sac.ps1.rs <- specaccum(MBCps1_rs, "random", permutations=9999) plot(sac.ps1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.ps1.rs$richness # curve.ps1 <- data.frame(x=x, y=y1) # write.csv(curve.ps1, 'curve.ps1.rs.csv', row.names=F) # read the curve.ps1.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -8.17925758179E-002 b = 1.88861210675E+000 c = 1.59937085128E-001 d = -2.04475162334E-003 f_r <- (a+b*8.07)/(1+c*8.07+d*8.07^2) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = -2.82627363620E-001 b = 8.01081375220E+000 c = 1.63306779206E+001 d = 8.78886266058E-001 f_m <- (a*b+c*8.07^d)/(b+8.07^d) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.16026639767E+001 b = 1.20276173945E+001 c = 1.80491859384E-001 d = 8.00889418226E-001 f_w <- a-b*exp(-c*8.07^d) # comparing the predicted with the actual value diff <- c(f_r, f_m, f_w)*10-dim(MBCps1)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -2.49125637186E-002 b = 1.74691348063E+000 c = 1.29350274344E-001 d = -9.86217087610E-004 # # predict the Psocoptera species richness from plant model y.ps1 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps1 <- alpha.accum(comm=MBCps1, func="nonparametric", runs=1) Y.ps1 <- acc.ps1[28,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps1/(y.ps1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 0.98 0.98 0.94 0.90 0.87 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.61980641941E-001 b = 1.30948094520E+000 c = -5.75978000011E-002 d = -1.30375774980E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*10)~xx, ylim=c(0,80)) # drop # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 8.35472595627E-002 b = 1.38336282272E+000 c = -7.58144451154E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*10)~xx, col=2) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.89385563171E-001 b = 1.12513706203E+000 c = -1.55309194695E-002 d = 9.36038586714E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=3) # drop # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.86528581202E+000 b = 6.25290792334E+000 c = 1.39131179163E-001 d = 1.37628026598E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=4) # ok, asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 6.84769935374E+000 b = 8.48428581898E-001 c = 4.17872507009E-001 yy <- a*exp(-exp(b-c*xx*0.01)); points(I(yy*10)~xx, col=5) # ok, asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.g <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Richards Model: y=a/(1+exp(b-cx))^(1/d) # Coefficient Data: a = 6.83791046200E+000 b = -3.03214593062E+000 c = 4.21826885569E-001 d = 2.02705429123E-002 yy <- a/(1+exp(b-c*xx*0.01))^(1/d); points(I(yy*10)~xx, col=6) # ok, asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 1.46830319307E+000 b = 9.08027899679E-001 c = 1.07377959509E+000 yy <- a*b^(xx*0.01)*(xx*0.01)^c; points(I(yy*10)~xx, col=7) # drop # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 8.34262605114E-001 b = 1.10325964194E+001 c = 7.92896360691E+000 d = 1.75202326065E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=8) # asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.w, AICc.g, AICc.r, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 20 instead of 28 plots to assess their suitability for extrapolation MBCps2_rs <- MBCps2[ransub,] # rs=ransub # remove empty columns MBCps2_rs <- MBCps2_rs[,specnumber(MBCps2_rs, MARGIN=2)>0] # 63 -> 61 sac.ps2.rs <- specaccum(MBCps2_rs, "random", permutations=9999) plot(sac.ps2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.ps2.rs$richness # curve.ps2 <- data.frame(x=x, y=y2) # write.csv(curve.ps2, 'curve.ps2.rs.csv', row.names=F) # read the curve.ps2.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.02708790209E+000 b = 6.47899886903E+000 c = 1.37814099114E-001 d = 1.38998967356E+000 f_w <- a-b*exp(-c*8.07^d) # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 6.94318597951E+000 b = 8.96933082924E-001 c = 4.35489699365E-001 f_g <- a*exp(-exp(b-c*8.07)) # Richards Model: y=a/(1+exp(b-cx))^(1/d) # Coefficient Data: a = 6.92311601598E+000 b = -2.68512210695E+000 c = 4.41956172496E-001 d = 2.71176708227E-002 f_r <- a/(1+exp(b-c*8.07))^(1/d) # comparing the predicted with the actual value diff <- c(f_w, f_g, f_r)*10-dim(MBCps2)[2] # getting the differences which.min(abs(diff)) # Richards Model minimal # final choice # Richards Model: y=a/(1+exp(b-cx))^(1/d) # Coefficient Data: a = 6.83791046200E+000 b = -3.03214593062E+000 c = 4.21826885569E-001 d = 2.02705429123E-002 # # predict the Psocoptera species richness from plant model y.ps2 <- a/(1+exp(b-c*x.plant*0.01))^(1/d) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps2 <- alpha.accum(comm=MBCps2, func="nonparametric", runs=1) Y.ps2 <- acc.ps2[28,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps2/(y.ps2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 0.96 0.97 0.95 0.95 #### calculate the fitness #### DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in1[c(2,4,6)]*1000), Insect2=c(Y.in2[c(2,4,6)], y.in2[c(2,4,6)]*1000), Cole1=c(Y.cole1[c(2,4,6)], y.cole1[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole2[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di1[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di2[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he1[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he2[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy1[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy2[c(2,4,6)]*100), Le1=c(Y.le1[c(2,4,6)], y.le1[c(2,4,6)]*10), Le2=c(Y.le2[c(2,4,6)], y.le2[c(2,4,6)]*10), Ps1=c(Y.ps1[c(2,4,6)], y.ps1[c(2,4,6)]*10), Ps2=c(Y.ps2[c(2,4,6)], y.ps2[c(2,4,6)]*10), Spider1=c(Y.sp1[c(2,4,6)], y.sp1[c(2,4,6)]*10), Spider2=c(Y.sp2[c(2,4,6)], y.sp2[c(2,4,6)]*10), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C2P')) # only presenting P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9,11,13,15),] # wet season DAT2 <- DAT[c(2,4,6,8,10,12,14,16),] # dry season #### calculate the R^2 fitted to the y=x model #### options(digits=4) ### wet season ## Jack1inP yi <- DAT1[2:6, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi <- DAT1[2:6, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9949 ## Jack2inP yi <- DAT1[2:6, ]$Jack2inP ym <- mean(yi) fi <- DAT1[2:6, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9818 ## Chao2P yi <- DAT1[2:6, ]$Chao2P ym <- mean(yi) fi <- DAT1[2:6, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9847 ### dry season ## Jack1inP yi <- DAT2[2:6, ]$Jack1inP ym <- mean(yi) fi <- DAT2[2:6, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9511 ## Jack2inP yi <- DAT2[2:6, ]$Jack2inP ym <- mean(yi) fi <- DAT2[2:6, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.8157 ## Chao2P yi <- DAT2[2:6, ]$Chao2P ym <- mean(yi) fi <- DAT2[2:6, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9612 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[2:6, ]$Jack1inP, x=DAT1[2:6, ]$plant.model.J1P, method='pearson') # r=0.9994 cor.test(y=DAT1[2:6, ]$Jack2inP, x=DAT1[2:6, ]$plant.model.J2P, method='pearson') # 0.9971 cor.test(y=DAT1[2:6, ]$Chao2P, x=DAT1[2:6, ]$plant.model.C2P, method='pearson') # 0.9938 # dry season cor.test(y=DAT2[2:6, ]$Jack1inP, x=DAT2[2:6, ]$plant.model.J1P, method='pearson') # 0.989 cor.test(y=DAT2[2:6, ]$Jack2inP, x=DAT2[2:6, ]$plant.model.J2P, method='pearson') # 0.9396 cor.test(y=DAT2[2:6, ]$Chao2P, x=DAT2[2:6, ]$plant.model.C2P, method='pearson') # 0.9831 options(digits=2) #### plot Yinggeling and Mengsong together #### (Fig. S1) # windows(width=11.69, height=3.9, pointsize=14) par(mfrow=c(1,3), mar=c(4.2,6,3.5,1.1)) # default margin = ~4.1 for y axis ## Yinggeling plot(Jack1inP~plant.model, data=dat[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='Non-parametric estimates (no. spp.)', col=c(2:6), pch=16, xlim=c(200,4500), ylim=c(200,4500),xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(500,1000,1500,2000,2500,3000,3500,4000,4500), label=c(NA,'1000',NA,'2000',NA,NA,'5000',NA,'6000'), tick=T) axis.break(1,2500, brw=0.015) axis(2, at=c(500,1000,1500,2000,2500,3000,3500,4000,4500), label=c(NA,'1000',NA,'2000',NA,NA,'5000',NA,'6000'), tick=T) axis.break(2,2500, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model, data=dat[-1, ], col=c(2:6), pch=15) # square = Jack2inP points(Chao2P~plant.model, data=dat[-1, ], col=c(2:6), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model, data=dat[1, ]-1500, pch=16) points(Jack2inP~plant.model, data=dat[1, ]-1500, pch=15) points(Chao2P~plant.model, data=dat[1, ]-1500, pch=17) # add the taxa names xnames0=c('Insecta','Diptera','Hemiptera','Hymenoptera','Lepidoptera') text(x=c(5675-1000-1500,2307-400,593+70,340+20,796+100), y=c(5045-500-1500,2015-150,506-100,336-150,730-100), pos=4, srt=0, cex=0.8, labels=xnames0, col=c(1,3:6)) text(x=750-100, y=909+200, pos=4, srt=70, cex=0.8, labels='Coleoptera', col=2) # add same-site prediction and location name text(x=1300, y=4450, as.expression(bquote(italic('Same-site prediction')))) text(x=760, y=4200, "Yinggeling") # add R square legend(1950, 500, legend=c(as.expression(bquote("Jackknife1"*italic('P')*',' ~ R^2 ~ "= 0.958")), as.expression(bquote("Jackknife2"*italic('P')*',' ~ R^2 ~ "= 0.927")), as.expression(bquote(" Chao2"*italic('P')*',' ~ R^2 ~ "= 0.927"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.6, y.intersp=1, cex=0.85) # mtext(text='Fig. S1', side=3, at=-500, line=1.5) ## Mengsong_wet par(mar=c(4.2,5,3.5,2.1)) plot(Jack1inP~plant.model.J1P, data=DAT1[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(0,1800), ylim=c(0,1800),xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(1,1050, brw=0.015) axis(2, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(2,1050, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT1[1, ]-1800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT1[1, ]-1800, pch=15) points(Chao2P~plant.model.C2P, data=DAT1[1, ]-1800, pch=17) # add only Psocoptera and Arachnida which are absent in Yinggeling text(x=c(105,194), y=c(84-50,156), pos=4, srt=0, cex=0.8, labels=c('Psocoptera','Arachnida'), col=c('grey50','gold3')) # x:DAT1$plant.model.J2P, y:DAT1$Chao2P # add same-site prediction, location and season names text(x=440, y=1770, as.expression(bquote(italic('Same-site prediction')))) text(x=500, y=1670, "Mengsong: wet season") # add R square legend(1200, 120, legend=c(as.expression(bquote(~ R^2 ~ "= 0.995")), as.expression(bquote(~ R^2 ~ "= 0.982")), as.expression(bquote(~ R^2 ~ "= 0.985"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.6, y.intersp=1, cex=0.85) # Mengosng_dry par(mar=c(4.4,3.8,3.5,3.3)) plot(Jack1inP~plant.model.J1P, data=DAT2[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(0,1800), ylim=c(0,1800),xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(1,1100, brw=0.015) axis(2, at=c(300,600,900,1200,1500,1800), label=c('300','600',NA,'3000',NA,'3600'), tick=T) axis.break(2,1100, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT2[1, ]-1800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT2[1, ]-1800, pch=15) points(Chao2P~plant.model.C2P, data=DAT2[1, ]-1800, pch=17) # add only Psocoptera and Arachnida which are absent in Yinggeling text(x=c(68+50,141+30), y=c(65-50,126-20), pos=4, srt=0, cex=0.8, labels=c('Psocoptera','Arachnida'), col=c('grey50','gold3')) # x:DAT2$plant.model.C2P, y:DAT2$Chao2P # add same-site prediction, location name and season text(x=440, y=1770, as.expression(bquote(italic('Same-site prediction')))) text(x=500, y=1670, "Mengsong: dry season") # add R square legend(1200, 120, legend=c(as.expression(bquote(~ R^2 ~ "= 0.951")), as.expression(bquote(~ R^2 ~ "= 0.816")), as.expression(bquote(~ R^2 ~ "= 0.961"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.6, y.intersp=1, cex=0.85) par(mfrow=c(1,1)) ``` ##### __2. forests only (mature forest + regenerating forest) __ ```{r alpha_Mengsong_F_25_alternative_functions} ### Arachnida # read curve.sp1.forest.csv, curve.sp2.forest.csv into CurveExpert # scale x by 0.01 and y by 0.1 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 2.22655448268E-002 b = 7.71507886673E-001 c = 5.52296123217E-002 d = -2.32899368511E-003 # check the curve xx <- 1:1600 # max(x.plant) = 1501 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*10)~xx) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx (not provided as SI) # n <- 22 # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -4.01921165553E-003 b = 8.07893927021E-001 c = -4.95966568320E-002 d = 2.40941450144E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.65321768507E-001 b = 3.13309212940E+002 c = 2.16421676434E+002 d = 1.21972522900E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -3.35975979979E-001 b = 1.67164988831E-001 c = 1.18408842691E+000 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*10)~xx, col=4) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.m, AICc.v)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation ransub <- sample(x=1:22, size=15, replace=FALSE) # ransub=randomized subdata MBCsp1f_rs <- MBCsp1f[ransub,] # rs=ransub Plantf_rs <- Plantf[ransub,] # rs=ransub # remove empty columns MBCsp1f_rs <- MBCsp1f_rs[,specnumber(MBCsp1f_rs, MARGIN=2)>0] # 79 -> 70 Plantf_rs <- Plantf_rs[,specnumber(Plantf_rs, MARGIN=2)>0] # 747 -> 623 sac.plant.rs <- specaccum(Plantf_rs, "random", permutations=9999) sac.sp1.rs <- specaccum(MBCsp1f_rs, "random", permutations=9999) plot(sac.sp1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.sp1.rs$richness # x <- sac.plant.rs$richness # curve.sp1 <- data.frame(x=x, y=y1) # write.csv(curve.sp1, 'curve.sp1.forest.rs.csv', row.names=F) # read the curve.ps1.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.35521395780E-002 b = 8.16062960138E-001 c = 5.43573490832E-002 d = -8.73401703733E-004 f_3p <- a+b*7.47+c*7.47^2+d*7.47^3 # 747 vascular plant species found in the forest in the survey, 747*0.01=7.47; f: fitted, 3p: 3rd degree Polynomial Fit # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -5.07414317409E-004 b = 8.36898314162E-001 c = -5.36459535478E-002 d = 2.04740884831E-003 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.59409439409E-001 b = 3.23224999159E+002 c = 2.09635602463E+002 d = 1.29641774966E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_m)*10-dim(MBCsp1f)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.65321768507E-001 b = 3.13309212940E+002 c = 2.16421676434E+002 d = 1.21972522900E+000 # # estimate the plant species richness by non-parametric estimation acc.plant <- alpha.accum(comm=Plantf, func="nonparametric", runs=1) (x.plant <- acc.plant[22,c(10,11,14,15,18,19)]) # # predict the spider OTU richness from plant model y.sp1 <- (a*b+c*(x.plant*0.01)^d)/(b+(x.plant*0.01)^d) # # estimate the spider OTU richness by non-parametric estimation acc.sp1 <- alpha.accum(comm=MBCsp1f, func="nonparametric", runs=1) Y.sp1 <- acc.sp1[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.sp1/(y.sp1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 1.02 1.00 1.04 1.02 1.05 ### dry season ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 6.35977118764E-003 b = 8.03670499538E-001 c = -5.01567197614E-002 d = 3.52877441209E-003 # check the curve yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*10)~xx, ylim=c(0,150)) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 2.77902440004E-002 b = 7.70134272266E-001 c = 5.67743129154E-002 d = -3.92932261504E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*10)~xx, col=2) # drop # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.17256203920E+001 b = 2.15289992515E+001 c = 3.11367615097E-002 d = 1.27163037029E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.02827794752E-001 b = 5.57220499737E+001 c = 3.72677702279E+001 d = 1.28462668092E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 8.23379788284E-001 b = 9.86185971199E-001 c = 1.13905759265E+000 yy <- a*b^(xx*0.01)*(xx*0.01)^c; points(I(yy*10)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.h)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCsp2f_rs <- MBCsp2f[ransub,] # rs=ransub # remove empty columns MBCsp2f_rs <- MBCsp2f_rs[,specnumber(MBCsp2f_rs, MARGIN=2)>0] # 73 -> 60 sac.sp2.rs <- specaccum(MBCsp2f_rs, "random", permutations=9999) plot(sac.sp2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Arachnida', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.sp2.rs$richness # curve.sp2 <- data.frame(x=x, y=y2) # write.csv(curve.sp2, 'curve.sp2.forest.rs.csv', row.names=F) # read the curve.ps2.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = -4.67324766138E-002 b = 8.40483501474E-001 c = -4.17056742141E-002 d = 3.20410570741E-003 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # 747 vascular plant species found in the forest in the survey, 747*0.01=7.47; r: Rational Function # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.05168304883E-001 b = 6.01331775146E+001 c = 4.44393794634E+001 d = 1.21489495668E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.39979916219E+001 b = 2.38890921759E+001 c = 3.07079948586E-002 d = 1.21474587344E+000 f_w <- a-b*exp(-c*7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_m, f_w)*10-dim(MBCsp2f)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.02827794752E-001 b = 5.57220499737E+001 c = 3.72677702279E+001 d = 1.28462668092E+000 # # predict the spider OTU richness from plant model y.sp2 <- (a*b+c*(x.plant*0.01)^d)/(b+(x.plant*0.01)^d) # # estimate the spider OTU richness by non-parametric estimation acc.sp2 <- alpha.accum(comm=MBCsp2f, func="nonparametric", runs=1) Y.sp2 <- acc.sp2[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.sp2/(y.sp2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 1.00 0.95 0.96 0.86 0.87 ### Insecta # read curve.in1.forest.csv, curve.in2.forest.csv into CurveExpert # scale x by 0.01 and y by 0.001 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.56050537617E-002 b = 2.37984122838E-001 c = 1.67908322743E-003 d = -3.27687895040E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*1000)~xx, ylim=c(0,3500)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.61628638950E-002 b = 2.36922332074E-001 c = -8.23245609201E-003 d = 1.45855158994E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*1000)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 7.05513385932E-002 b = 4.52256491406E+001 c = 1.00116779721E+001 d = 1.11435751295E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*1000)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.68028226519E+000 b = 4.59130590153E+000 c = 4.43804463534E-002 d = 1.16151974191E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*1000)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.m, AICc.w)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCin1f_rs <- MBCin1f[ransub,] # rs=ransub # remove empty columns MBCin1f_rs <- MBCin1f_rs[,specnumber(MBCin1f_rs, MARGIN=2)>0] # 1780 -> 1526 sac.in1.rs <- specaccum(MBCin1f_rs, "random", permutations=9999) plot(sac.in1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Insecta', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.in1.rs$richness # curve.in1 <- data.frame(x=x, y=y1) # write.csv(curve.in1, 'curve.in1.forest.rs.csv', row.names=F) # read the curve.in1.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.001 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.32134380159E-002 b = 2.41499250746E-001 c = -3.72609260657E-004 d = 4.31495462481E-004 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # 747 vascular plant species found in the forest in the survey, 747*0.01=7.47 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.31494202991E-002 b = 2.41608336196E-001 c = 3.13400095800E-005 d = -9.86171894389E-005 f_3p <- a+b*7.47+c*7.47^2+d*7.47^3 # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 9.44166587038E-002 b = 4.06959565416E+001 c = 8.18319470728E+000 d = 1.18363105526E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_3p, f_m)*1000-dim(MBCin1f)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 7.05513385932E-002 b = 4.52256491406E+001 c = 1.00116779721E+001 d = 1.11435751295E+000 # # predict the insect OTU richness from plant model y.in1 <- (a*b+c*(x.plant*0.01)^d)/(b+(x.plant*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation acc.in1 <- alpha.accum(comm=MBCin1f, func="nonparametric", runs=1) Y.in1 <- acc.in1[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in1/(y.in1*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.01 1.01 1.01 0.97 0.97 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.43772231617E-002 b = 2.67122119013E-001 c = 8.42120930534E-004 d = -4.13785623026E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*1000)~xx, ylim=c(0,3500)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.58097393442E-002 b = 2.64932424001E-001 c = -6.16676385545E-003 d = 1.85797536219E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*1000)~xx, col=2) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 7.76002532150E-002 b = 3.27206067870E+001 c = 8.00256169254E+000 d = 1.13917391199E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*1000)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.46969578370E+000 b = 4.38393024472E+000 c = 5.35147929368E-002 d = 1.14898661258E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*1000)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 2.30391412909E-002 b = 2.87910785319E-001 c = -4.57957634508E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*1000)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.m, AICc.w, AICc.q)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCin2f_rs <- MBCin2f[ransub,] # rs=ransub # remove empty columns MBCin2f_rs <- MBCin2f_rs[,specnumber(MBCin2f_rs, MARGIN=2)>0] # 1913 -> 1642 sac.in2.rs <- specaccum(MBCin2f_rs, "random", permutations=9999) plot(sac.in2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Insecta', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.in2.rs$richness # curve.in2 <- data.frame(x=x, y=y2) # write.csv(curve.in2, 'curve.in2.forest.rs.csv', row.names=F) # read the curve.in2.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.001 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 3.66678295802E-002 b = 2.71968425573E-001 c = 2.97320554114E-003 d = 9.22019391645E-004 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # 747 vascular plant species found in the forest in the survey, 747*0.01=7.47 # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 6.82091171095E-002 b = 3.81408988018E+001 c = 9.49399519742E+000 d = 1.11136703725E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.43184548028E+000 b = 4.34578577111E+000 c = 5.31219743935E-002 d = 1.15842620655E+000 f_w <- a-b*exp(-c*7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_m, f_w)*1000-dim(MBCin2f)[2] # getting the differences which.min(abs(diff)) # Weibull Model minimal # final choice # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 4.46969578370E+000 b = 4.38393024472E+000 c = 5.35147929368E-002 d = 1.14898661258E+000 # # predict the insect OTU richness from plant model y.in2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the insect OTU richness by non-parametric estimation acc.in2 <- alpha.accum(comm=MBCin2f, func="nonparametric", runs=1) Y.in2 <- acc.in2[22,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in2/(y.in2*1000) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 1.02 1.02 1.03 0.95 0.95 #### apply to Insecta orders #### #### Coleoptera #### # read curve.cole1.forest.csv, curve.cole2.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.30201139516E-002 b = 3.56804510308E-001 c = -3.23344228676E-002 d = 1.48620659402E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*100)~xx, ylim=c(0,800)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.67026204322E-002 b = 3.53103371933E-001 c = 1.39462323427E-002 d = -5.79148082452E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.24369718701E-001 b = -2.66069814656E-001 c = 1.12386068946E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -1.10538825073E+000 b = 2.47490339899E-001 c = 1.11668461865E+000 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=4) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.3p, AICc.s, AICc.v)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCcole1f_rs <- MBCcole1f[ransub,] # rs=ransub # remove empty columns MBCcole1f_rs <- MBCcole1f_rs[,specnumber(MBCcole1f_rs, MARGIN=2)>0] # 323 -> 261 sac.cole1.rs <- specaccum(MBCcole1f_rs, "random", permutations=9999) plot(sac.cole1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.cole1.rs$richness # curve.cole1 <- data.frame(x=x, y=y1) # write.csv(curve.cole1, 'curve.cole1.forest.rs.csv', row.names=F) # read the curve.cole1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.20834697493E-001 b = -2.40258032575E-001 c = 1.12237405141E+000 f_s <- a*(7.47-b)^c # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.87125241152E-002 b = 3.45733651571E-001 c = 1.47349635102E-002 d = -6.89337008617E-004 f_3p <- a+b*7.47+c*7.47^2+d*7.47^3 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.51675574608E-002 b = 3.49498712983E-001 c = -3.49172974675E-002 d = 1.79893863358E-003 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # comparing the predicted with the actual value diff <- c(f_s, f_3p, f_r)*100-dim(MBCcole1f)[2] # getting the differences which.min(abs(diff)) # Shifted Power Fit minimal # final choice # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 3.24369718701E-001 b = -2.66069814656E-001 c = 1.12386068946E+000 # # predict the Coleoptera species richness from plant model y.cole1 <- a*(x.plant*0.01-b)^c # # estimate the Coleoptera species richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1f, func="nonparametric", runs=1) Y.cole1 <- acc.cole1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole1/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 1.00 0.98 0.99 1.00 1.00 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 6.71743496954E-002 b = 6.80568401784E-001 c = 1.02321398677E-002 d = -1.47679697185E-003 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,900)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 6.92078277195E-002 b = 6.77416833053E-001 c = -1.57299049317E-002 d = 2.18475857440E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.35096323243E+001 b = 1.33515265013E+001 c = 4.60498158216E-002 d = 1.14824185591E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.61750782450E-001 b = 3.70630265127E+001 c = 2.28623592659E+001 d = 1.16145488983E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 7.44583614104E-001 b = 9.84123670631E-001 c = 1.01812310491E+000 yy <- a*b^(xx*0.01)*(xx*0.01)^c; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.h)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCcole2f_rs <- MBCcole2f[ransub,] # rs=ransub # remove empty columns MBCcole2f_rs <- MBCcole2f_rs[,specnumber(MBCcole2f_rs, MARGIN=2)>0] # 510 -> 437 sac.cole2.rs <- specaccum(MBCcole2f_rs, "random", permutations=9999) plot(sac.cole2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Coleoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.cole2.rs$richness # curve.cole2 <- data.frame(x=x, y=y2) # write.csv(curve.cole2, 'curve.cole2.forest.rs.csv', row.names=F) # read the curve.cole2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.66776591623E-002 b = 7.00383839620E-001 c = -9.79345601820E-003 d = 1.80627032594E-003 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.25125553405E-001 b = 4.01786789988E+001 c = 2.60771417065E+001 d = 1.12692576725E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.19120246112E+001 b = 1.17370501063E+001 c = 5.11640827798E-002 d = 1.17786685368E+000 f_w <- a-b*exp(-c*7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_m, f_w)*100-dim(MBCcole2f)[2] # getting the differences which.min(abs(diff)) # Weibull Model minimal # final choice # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.35096323243E+001 b = 1.33515265013E+001 c = 4.60498158216E-002 d = 1.14824185591E+000 # # predict the Coleoptera species richness from plant model y.cole2 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole2 <- alpha.accum(comm=MBCcole2f, func="nonparametric", runs=1) Y.cole2 <- acc.cole2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole2/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.00 0.97 0.98 0.90 0.90 #### Diptera #### # read curve.di1.forest.csv, curve.di2.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.22870144931E-001 b = 5.29979562233E-001 c = 4.04472618105E-003 d = 2.18409554592E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); plot(I(yy*100)~xx, ylim=c(0,600)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 2.16250981513E-001 b = 5.38183531599E-001 c = -6.36139520874E-003 d = -6.05548906891E-004 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=2) # drop # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.99697819371E+000 b = 6.71612740873E+000 c = 7.23667261804E-002 d = 1.12201656250E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 3.02751214263E-001 b = 2.17696056606E+001 c = 1.04922194488E+001 d = 1.17244248144E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.85024057635E-001 b = 5.68606420788E-001 c = -1.42957038846E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.q)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCdi1f_rs <- MBCdi1f[ransub,] # rs=ransub # remove empty columns MBCdi1f_rs <- MBCdi1f_rs[,specnumber(MBCdi1f_rs, MARGIN=2)>0] # 363 -> 317 sac.di1.rs <- specaccum(MBCdi1f_rs, "random", permutations=9999) plot(sac.di1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.di1.rs$richness # curve.di1 <- data.frame(x=x, y=y1) # write.csv(curve.di1, 'curve.di1.forest.rs.csv', row.names=F) # read the curve.di1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.29666657399E-001 b = 5.32939630908E-001 c = 8.81084733604E-003 d = 1.67998931667E-003 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.83378530572E-001 b = 2.46026529938E+001 c = 1.23839700439E+001 d = 1.11620724808E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.24274051951E+000 b = 6.95226000793E+000 c = 6.94991503777E-002 d = 1.11452150083E+000 f_w <- a-b*exp(-c*7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_m, f_w)*100-dim(MBCdi1f)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.22870144931E-001 b = 5.29979562233E-001 c = 4.04472618105E-003 d = 2.18409554592E-003 # # predict the Diptera species richness from plant model y.di1 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the Diptera species richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1f, func="nonparametric", runs=1) Y.di1 <- acc.di1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di1/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.06 1.07 1.10 0.99 1.01 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.87643215212E-001 b = 6.00066384695E-001 c = -1.04982308329E-002 d = -6.56318764885E-004 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,600)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.96537258854E-001 b = 5.88546232097E-001 c = 7.32808335716E-003 d = 2.68970587520E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 6.56423386918E+000 b = 6.30394751771E+000 c = 8.57021108677E-002 d = 1.12894991704E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.53798193154E-001 b = 6.33039960949E-001 c = -1.90977603030E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=4) # ok, asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 2.90823419023E-001 b = 1.79356891952E+001 c = 9.52553959185E+000 d = 1.19583288023E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.q, AICc.m)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCdi2f_rs <- MBCdi2f[ransub,] # rs=ransub # remove empty columns MBCdi2f_rs <- MBCdi2f_rs[,specnumber(MBCdi2f_rs, MARGIN=2)>0] # 381 -> 363 sac.di2.rs <- specaccum(MBCdi2f_rs, "random", permutations=9999) plot(sac.di2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.di2.rs$richness # curve.di2 <- data.frame(x=x, y=y2) # write.csv(curve.di2, 'curve.di2.forest.rs.csv', row.names=F) # read the curve.di2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.53919721454E-001 b = 6.35524804327E-001 c = 3.70984772809E-002 d = 5.05010188645E-004 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.68557369700E-001 b = 6.13025794444E-001 c = -1.80640263173E-002 f_q <- a+b*7.47+c*7.47^2 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.52043692694E+000 b = 7.32914852972E+000 c = 8.12187853263E-002 d = 1.04401369050E+000 f_w <- a-b*exp(-c*7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_q, f_w)*100-dim(MBCdi2f)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.96537258854E-001 b = 5.88546232097E-001 c = 7.32808335716E-003 d = 2.68970587520E-003 # # predict the Diptera species richness from plant model y.di2 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the Diptera species richness by non-parametric estimation acc.di2 <- alpha.accum(comm=MBCdi2f, func="nonparametric", runs=1) Y.di2 <- acc.di2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di2/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.05 1.05 1.09 0.96 0.98 #### Hemiptera #### # read curve.he1.forest.csv, curve.he2.forest.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.29707953433E-002 b = 4.37266444783E-001 c = 9.91303024517E-003 d = -6.31686556097E-004 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.09306409487E-002 b = 4.39337781136E-001 c = -1.96719480626E-002 d = 1.25748987779E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.06376956975E-001 b = 9.01540370681E+001 c = 3.54157303372E+001 d = 1.13980177198E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.69333006282E+001 b = 1.68168666833E+001 c = 2.27936715024E-002 d = 1.15365385041E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.m, AICc.w)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBChe1f_rs <- MBChe1f[ransub,] # rs=ransub # remove empty columns MBChe1f_rs <- MBChe1f_rs[,specnumber(MBChe1f_rs, MARGIN=2)>0] # 360 -> 303 sac.he1.rs <- specaccum(MBChe1f_rs, "random", permutations=9999) plot(sac.he1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.he1.rs$richness # curve.he1 <- data.frame(x=x, y=y1) # write.csv(curve.he1, 'curve.he1.forest.rs.csv', row.names=F) # read the curve.he1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 3.95381825615E-002 b = 4.20954436910E-001 c = -1.95034128830E-002 d = 1.63307044517E-005 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.96794657510E-002 b = 4.21725688300E-001 c = 8.12268612235E-003 d = 1.88997172451E-004 f_3p <- a+b*7.47+c*7.47^2+d*7.47^3 # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.34061113060E-001 b = 2.31697287120E+002 c = 8.02652184150E+001 d = 1.17971604818E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_3p, f_m)*100-dim(MBChe1f)[2] # getting the differences which.min(abs(diff)) # MMF Model minimal # final choice # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.06376956975E-001 b = 9.01540370681E+001 c = 3.54157303372E+001 d = 1.13980177198E+000 # # predict the Hemiptera species richness from plant model y.he1 <- (a*b+c*(x.plant*0.01)^d)/(b+(x.plant*0.01)^d) # # estimate the Hemiptera species richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1f, func="nonparametric", runs=1) Y.he1 <- acc.he1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he1/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 1.02 1.02 1.04 1.02 1.03 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.01776530360E-002 b = 3.66941498792E-001 c = 1.00849650992E-002 d = -1.00882100827E-003 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,600)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.97089219842E-002 b = 3.67137514821E-001 c = -2.47059388574E-002 d = 2.44371113091E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.07535708802E+000 b = 7.96601333168E+000 c = 4.08630253864E-002 d = 1.17973080662E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.07062084052E-001 b = 4.29241437039E+001 c = 1.41733548167E+001 d = 1.18373451436E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 4.13822725981E-001 b = 9.89638118134E-001 c = 1.01402295586E+000 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.h)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBChe2f_rs <- MBChe2f[ransub,] # rs=ransub # remove empty columns MBChe2f_rs <- MBChe2f_rs[,specnumber(MBChe2f_rs, MARGIN=2)>0] # 293 -> 244 sac.he2.rs <- specaccum(MBChe2f_rs, "random", permutations=9999) plot(sac.he2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.he2.rs$richness # curve.he2 <- data.frame(x=x, y=y2) # write.csv(curve.he2, 'curve.he2.forest.rs.csv', row.names=F) # read the curve.he2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.09310338728E-002 b = 3.88599691113E-001 c = 4.61894578772E-003 d = -7.19135696272E-004 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.18366469918E-001 b = 5.20315384253E+001 c = 1.59346260206E+001 d = 1.19517083938E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.22177483419E+000 b = 8.09522500180E+000 c = 3.66540630086E-002 d = 1.20881898797E+000 f_w <- a-b*exp(-c*7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_m, f_w)*100-dim(MBChe2f)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.97089219842E-002 b = 3.67137514821E-001 c = -2.47059388574E-002 d = 2.44371113091E-003 # # predict the Hemiptera species richness from plant model y.he2 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the Hemiptera species richness by non-parametric estimation acc.he2 <- alpha.accum(comm=MBChe2f, func="nonparametric", runs=1) Y.he2 <- acc.he2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he2/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.05 1.03 1.08 0.94 0.97 #### Hymenoptera #### # read curve.hy1.forest.csv, curve.hy2.forest.csv # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 5.22033735387E-002 b = 5.48470605360E-001 c = -4.08863341944E-003 d = -7.70443090248E-004 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx, ylim=c(0,700)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 5.89248575951E-002 b = 5.39250088602E-001 c = 3.95056513074E-004 d = 2.36738029379E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.13028722055E+000 b = 7.00771829953E+000 c = 7.02648150951E-002 d = 1.13343645176E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.43812696610E-001 b = 2.24837821299E+001 c = 1.08228828423E+001 d = 1.18222687752E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.24731924457E-002 b = 5.87177808848E-001 c = -1.41834964861E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.r, AICc.w, AICc.m, AICc.q)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBChy1f_rs <- MBChy1f[ransub,] # rs=ransub # remove empty columns MBChy1f_rs <- MBChy1f_rs[,specnumber(MBChy1f_rs, MARGIN=2)>0] # 360 -> 319 sac.hy1.rs <- specaccum(MBChy1f_rs, "random", permutations=9999) plot(sac.hy1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.hy1.rs$richness # curve.hy1 <- data.frame(x=x, y=y1) # write.csv(curve.hy1, 'curve.hy1.forest.rs.csv', row.names=F) # read the curve.hy1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 9.99542409746E-002 b = 2.22059982393E+001 c = 1.22900754620E+001 d = 1.10373561711E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.34548892712E-002 b = 5.92867903055E-001 c = 1.92857537590E-002 d = 1.34410328777E-003 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.32029880851E+000 b = 7.21782044580E+000 c = 7.53337104197E-002 d = 1.09351222898E+000 f_w <- a-b*exp(-c*7.47^d) # comparing the predicted with the actual value diff <- c(f_m, f_r, f_w)*100-dim(MBChy1f)[2] # getting the differences which.min(abs(diff)) # Weibull Model minimal # final choice # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.13028722055E+000 b = 7.00771829953E+000 c = 7.02648150951E-002 d = 1.13343645176E+000 # # predict the Hymenoptera species richness from plant model y.hy1 <- a-b*exp(-c*(x.plant*0.01)^d) # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1f, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy1/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.03 1.03 1.03 1.04 0.95 0.95 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.38565295374E-002 b = 4.54320116483E-001 c = -8.82498141400E-003 d = 3.22487358667E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*100)~xx) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.25915427118E-002 b = 4.57200245600E-001 c = 2.15155376847E-002 d = -6.78082217389E-004 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 4.87619648911E-001 b = 9.98487042553E-001 c = 9.22130331453E-001 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -7.07463254608E-001 b = -1.18906225787E-002 c = 9.12076610472E-001 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=4) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.3p, AICc.r, AICc.h, AICc.v)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBChy2f_rs <- MBChy2f[ransub,] # rs=ransub # remove empty columns MBChy2f_rs <- MBChy2f_rs[,specnumber(MBChy2f_rs, MARGIN=2)>0] # 308 -> 266 sac.hy2.rs <- specaccum(MBChy2f_rs, "random", permutations=9999) plot(sac.hy2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.hy2.rs$richness # curve.hy2 <- data.frame(x=x, y=y2) # write.csv(curve.hy2, 'curve.hy2.forest.rs.csv', row.names=F) # read the curve.hy2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 4.99539348835E-002 b = 4.40581754093E-001 c = -5.15181055854E-003 d = 2.63325760697E-004 f_3p <- a+b*7.47+c*7.47^2+d*7.47^3 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.97466226699E-002 b = 4.41624016431E-001 c = 1.23653938639E-002 d = -6.02701796875E-004 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 4.78797014147E-001 b = 1.00745796564E+000 c = 9.11941400660E-001 f_h <- a*b^7.47*7.47^c # comparing the predicted with the actual value diff <- c(f_3p, f_r, f_h)*100-dim(MBChy2f)[2] # getting the differences which.min(abs(diff)) # Rational Function minimal # final choice # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 4.25915427118E-002 b = 4.57200245600E-001 c = 2.15155376847E-002 d = -6.78082217389E-004 # # predict the Hymenoptera species richness from plant model y.hy2 <- (a+b*x.plant*0.01)/(1+c*x.plant*0.01+d*(x.plant*0.01)^2) # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy2 <- alpha.accum(comm=MBChy2f, func="nonparametric", runs=1) Y.hy2 <- acc.hy2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy2/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.00 0.99 1.00 0.98 0.99 0.97 #### Lepidoptera #### # read curve.le1.forest.csv, curve.le2.forest.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 9.61554778447E-001 b = -3.76503950977E-001 c = 9.64786103448E-001 yy <- a*(xx*0.01-b)^c; plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 3.76038407581E-001 b = 5.60676958768E+002 c = 5.24789379660E+002 d = 9.80930072427E-001 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 3.79775932403E-001 b = 9.42977254792E-001 c = 1.21245485174E-002 d = -5.92590735634E-004 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.83135279541E-001 b = 9.34581714396E-001 c = -9.80839652356E-003 d = 4.86389361909E-004 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*10)~xx, col=4) # ok # # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.s, AICc.m, AICc.r, AICc.3p)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCle1f_rs <- MBCle1f[ransub,] # rs=ransub # remove empty columns MBCle1f_rs <- MBCle1f_rs[,specnumber(MBCle1f_rs, MARGIN=2)>0] # 70 -> 59 sac.le1.rs <- specaccum(MBCle1f_rs, "random", permutations=9999) plot(sac.le1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Lepidoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.le1.rs$richness # curve.le1 <- data.frame(x=x, y=y1) # write.csv(curve.le1, 'curve.le1.forest.rs.csv', row.names=F) # read the curve.le1.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 2.46241014330E-001 b = 1.17870694238E+000 c = 1.05343964957E-001 d = -9.53672982890E-003 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 8.22773128415E-001 b = -6.10074948158E-001 c = 1.02140490604E+000 f_s <- a*(7.47-b)^c # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 5.28254970449E-001 b = 2.63350719113E+002 c = 2.14687019395E+002 d = 1.04141402868E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # comparing the predicted with the actual value diff <- c(f_r, f_s, f_m)*10-dim(MBCle1f)[2] # getting the differences which.min(abs(diff)) # Shifted Power Fit minimal # final choice # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 9.61554778447E-001 b = -3.76503950977E-001 c = 9.64786103448E-001 # # predict the Lepidoptera species richness from plant model y.le1 <- a*(x.plant*0.01-b)^c # # estimate the Lepidoptera species richness by non-parametric estimation acc.le1 <- alpha.accum(comm=MBCle1f, func="nonparametric", runs=1) Y.le1 <- acc.le1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le1/(y.le1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.98 0.95 0.93 0.90 0.86 0.83 ### dry season ### # list candidates based on their ranks # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 3.83632389971E-001 b = 9.01561919873E-001 c = 2.32813102460E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; plot(I(yy*10)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 3.76352252976E-001 b = 9.00249495469E-001 c = -2.33977989977E-002 d = 3.27910652920E-004 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.70308925725E-001 b = 9.14542329919E-001 c = 1.98960111247E-002 d = 2.58367082271E-004 yy <- a+b*(xx*0.01)+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*10)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 6.63653572897E-001 b = -7.80204801507E-001 c = 1.20314785373E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*10)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.q, AICc.r, AICc.3p, AICc.s)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCle2f_rs <- MBCle2f[ransub,] # rs=ransub # remove empty columns MBCle2f_rs <- MBCle2f_rs[,specnumber(MBCle2f_rs, MARGIN=2)>0] # 84 -> 75 sac.le2.rs <- specaccum(MBCle2f_rs, "random", permutations=9999) plot(sac.le2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Lepideptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.le2.rs$richness # curve.le2 <- data.frame(x=x, y=y2) # write.csv(curve.le2, 'curve.le2.forest.rs.csv', row.names=F) # read the curve.le2.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 3.56183941265E-001 b = 9.62391777531E-001 c = 2.97428897915E-002 f_q <- a+b*7.47+c*7.47^2 # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 3.51644338958E-001 b = 9.57951592552E-001 c = -2.87699486740E-002 d = 5.43770958283E-004 f_r <- (a+b*7.47)/(1+c*7.47+d*7.47^2) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 3.49400472889E-001 b = 9.70014796186E-001 c = 2.74054726454E-002 d = 2.11151805997E-004 f_3p <- a+b*7.47+c*7.47^2+d*7.47^3 # comparing the predicted with the actual value diff <- c(f_q, f_r, f_3p)*10-dim(MBCle2f)[2] # getting the differences which.min(abs(diff)) # Quadratic Fit minimal # final choice # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 3.83632389971E-001 b = 9.01561919873E-001 c = 2.32813102460E-002 # # predict the Lepidoptera species richness from plant model y.le2 <- a+b*(x.plant*0.01)+c*(x.plant*0.01)^2 # # estimate the Lepidoptera species richness by non-parametric estimation acc.le2 <- alpha.accum(comm=MBCle2f, func="nonparametric", runs=1) Y.le2 <- acc.le2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Lepidoptera species richness Y.le2/(y.le2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.96 0.95 0.93 0.91 0.90 0.89 #### Psocoptera #### # read curve.ps1.forest.csv, curve.ps2.forest.csv into CurveExpert # scale x by 0.01, and y by 0.1 ### wet season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.08575866213E-001 b = 1.25075669086E+000 c = -6.72304261633E-002 d = 7.49195956389E-004 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*10)~xx, ylim=c(0,80)) # drop # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.47210375885E-001 b = 1.21311694731E+000 c = -5.74139573214E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*10)~xx, col=2) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.26856809025E-001 b = 1.22242925457E+000 c = 3.94381056837E-002 d = 4.37395071809E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=3) # drop # xx[which.max(yy)] # 1499 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.89162632190E+000 b = 7.64485238546E+000 c = 1.47156933186E-001 d = 1.12316979464E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=4) # ok, asymptote # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 1.35519177158E+000 b = 9.36337996899E-001 c = 9.86315590066E-001 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); points(I(yy*10)~xx, col=5) # drop # xx[which.max(yy)] # 1499 # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 4.00734378679E-001 b = 9.84258416371E+000 c = 1.00965683689E+001 d = 1.29852945548E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association: y=a(1-exp(-bx) # Coefficient Data: a = 8.69533576738E+000 b = 1.58717678938E-001 yy <- a*(1-exp(-b*xx*0.01)); points(I(yy*10)~xx, col=7) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 8.66337545510E+000 b = 9.97511805218E-001 c = 1.60826829274E-001 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*10)~xx, col=8) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e3 <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.w, AICc.m, AICc.e, AICc.e3)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCps1f_rs <- MBCps1f[ransub,] # rs=ransub # remove empty columns MBCps1f_rs <- MBCps1f_rs[,specnumber(MBCps1f_rs, MARGIN=2)>0] # 60 -> 54 sac.ps1.rs <- specaccum(MBCps1f_rs, "random", permutations=9999) plot(sac.ps1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.ps1.rs$richness # curve.ps1 <- data.frame(x=x, y=y1) # write.csv(curve.ps1, 'curve.ps1.forest.rs.csv', row.names=F) # read the curve.ps1.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.23605465959E+000 b = 7.08224658459E+000 c = 1.76401100502E-001 d = 1.11167161816E+000 f_w <- a-b*exp(-c*7.47^d) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 3.31012389437E-001 b = 8.12235019164E+000 c = 9.18470768010E+000 d = 1.30469329859E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Exponential Association: y=a(1-exp(-bx) # Coefficient Data: a = 8.09125527481E+000 b = 1.77598367122E-001 f_e <- a*(1-exp(-b*7.47)) # comparing the predicted with the actual value diff <- c(f_w, f_m, f_e)*10-dim(MBCps1f)[2] # getting the differences which.min(abs(diff)) # Exponential Association minimal # final choice # Exponential Association: y=a(1-exp(-bx) # Coefficient Data: a = 8.69533576738E+000 b = 1.58717678938E-001 # # predict the Psocoptera species richness from plant model y.ps1 <- a*(1-exp(-b*x.plant*0.01)) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps1 <- alpha.accum(comm=MBCps1f, func="nonparametric", runs=1) Y.ps1 <- acc.ps1[22,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps1/(y.ps1*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.99 0.96 0.88 0.86 0.87 0.85 ### dry season ### # list candidates based on their ranks # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.05583250309E-001 b = 1.13294921108E+000 c = -3.18160211700E-002 d = -2.15344881652E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; plot(I(yy*10)~xx, ylim=c(0,80)) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.81372858613E-001 b = 1.02559621371E+000 c = -1.18234237021E-002 d = 7.46462677399E-003 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*10)~xx, col=2) # drop # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 7.06923082858E+000 b = 6.63345374252E+000 c = 1.25498731034E-001 d = 1.30988715263E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*10)~xx, col=3) # asymptote # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = -5.46571948166E-003 b = 1.24113887830E+000 c = -6.00319545712E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*10)~xx, col=4) # drop # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 5.94202432181E-001 b = 1.18801600052E+001 c = 8.68925955362E+000 d = 1.55760194847E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*10)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 1.24596948975E+000 b = 9.22899749848E-001 c = 1.07382175022E+000 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); points(I(yy*10)~xx, col=6) # drop # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 6.77493896195E+000 b = 8.87843587004E-001 c = 3.81863835564E-001 yy <- a*exp(-exp(b-c*xx*0.01)); points(I(yy*10)~xx, col=7) # ok, asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.g <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Richards Model: y=a/(1+exp(b-cx))^(1/d) # Coefficient Data: a = 6.75898768533E+000 b = -2.97813197792E+000 c = 3.86247723534E-001 d = 2.05400486502E-002 yy <- a/(1+exp(b-c*xx*0.01))^(1/d); points(I(yy*10)~xx, col=8) # ok, asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.r <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.w, AICc.m, AICc.g, AICc.r)) # top three functions # re-fit the top three functions for a randomized data set of 15 instead of 22 plots to assess their suitability for extrapolation MBCps2f_rs <- MBCps2f[ransub,] # rs=ransub # remove empty columns MBCps2f_rs <- MBCps2f_rs[,specnumber(MBCps2f_rs, MARGIN=2)>0] # 59 -> 55 sac.ps2.rs <- specaccum(MBCps2f_rs, "random", permutations=9999) plot(sac.ps2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Psocoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.ps2.rs$richness # curve.ps2 <- data.frame(x=x, y=y2) # write.csv(curve.ps2, 'curve.ps2.forest.rs.csv', row.names=F) # read the curve.ps2.forest.rs.csv into CurveExpert # scale x by 0.01 and y by 0.1 # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 8.06263033866E+000 b = 7.73740041426E+000 c = 1.12786655250E-001 d = 1.24984340191E+000 f_w <- a-b*exp(-c*7.47^d) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 4.03883316020E-001 b = 1.31195622208E+001 c = 1.09593634899E+001 d = 1.37282713840E+000 f_m <- (a*b+c*7.47^d)/(b+7.47^d) # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 6.95726929450E+000 b = 9.37102992946E-001 c = 3.80542565612E-001 f_g <- a*exp(-exp(b-c*7.47)) # comparing the predicted with the actual value diff <- c(f_w, f_m, f_g)*10-dim(MBCps2f)[2] # getting the differences which.min(abs(diff)) # Gompertz Relation minimal # final choice # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 6.77493896195E+000 b = 8.87843587004E-001 c = 3.81863835564E-001 # # predict the Psocoptera species richness from plant model y.ps2 <- a*exp(-exp(b-c*x.plant*0.01)) # # estimate the Psocoptera species richness by non-parametric estimation acc.ps2 <- alpha.accum(comm=MBCps2f, func="nonparametric", runs=1) Y.ps2 <- acc.ps2[22,c(10,11,14,15,18,19)] # # compare the two estimates of Psocoptera species richness Y.ps2/(y.ps2*10) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.07 1.08 1.04 1.06 0.96 0.98 #### calculate the fitness #### DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in1[c(2,4,6)]*1000), Insect2=c(Y.in2[c(2,4,6)], y.in2[c(2,4,6)]*1000), Cole1=c(Y.cole1[c(2,4,6)], y.cole1[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole2[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di1[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di2[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he1[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he2[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy1[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy2[c(2,4,6)]*100), Le1=c(Y.le1[c(2,4,6)], y.le1[c(2,4,6)]*10), Le2=c(Y.le2[c(2,4,6)], y.le2[c(2,4,6)]*10), Ps1=c(Y.ps1[c(2,4,6)], y.ps1[c(2,4,6)]*10), Ps2=c(Y.ps2[c(2,4,6)], y.ps2[c(2,4,6)]*10), Spider1=c(Y.sp1[c(2,4,6)], y.sp1[c(2,4,6)]*10), Spider2=c(Y.sp2[c(2,4,6)], y.sp2[c(2,4,6)]*10), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C2P')) # only present P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9,11,13,15),] # wet season DAT2 <- DAT[c(2,4,6,8,10,12,14,16),] # dry season #### calculate the R^2 fitted to the y=x model #### options(digits=4) ### wet season ## Jack1inP yi <- DAT1[2:7, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9958 ## Jack2inP yi <- DAT1[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9893 ## Chao2P yi <- DAT1[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT1[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9951 ### dry season ## Jack1inP yi <- DAT2[2:7, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9958 ## Jack2inP yi <- DAT2[2:7, ]$Jack2inP ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9896 ## Chao2P yi <- DAT2[2:7, ]$Chao2P ym <- mean(yi) fi <- DAT2[2:7, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.975 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[2:7, ]$Jack1inP, x=DAT1[2:7, ]$plant.model.J1P, method='pearson') # r=0.999 cor.test(y=DAT1[2:7, ]$Jack2inP, x=DAT1[2:7, ]$plant.model.J2P, method='pearson') # 0.997 cor.test(y=DAT1[2:7, ]$Chao2P, x=DAT1[2:7, ]$plant.model.C2P, method='pearson') # 0.9986 # dry season cor.test(y=DAT2[2:7, ]$Jack1inP, x=DAT2[2:7, ]$plant.model.J1P, method='pearson') # 0.9984 cor.test(y=DAT2[2:7, ]$Jack2inP, x=DAT2[2:7, ]$plant.model.J2P, method='pearson') # 0.9952 cor.test(y=DAT2[2:7, ]$Chao2P, x=DAT2[2:7, ]$plant.model.C2P, method='pearson') # 0.9967 options(digits=2) #### plot together #### (Fig. S3a) ## DAT1: wet season # windows(width=11.69, height=6, pointsize=14) par(mfrow=c(1,2), mar=c(4.2,6,3.5,1)) # default margin = ~4.1 for y plot(Jack1inP~plant.model.J1P, data=DAT1[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='Non-parametric estimates (no. spp.)', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(70,2000), ylim=c(70,2000), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(1,1100, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(2,1100, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT1[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT1[1, ]-1600, pch=16) points(Jack2inP~plant.model.J2P, data=DAT1[1, ]-1600, pch=15) points(Chao2P~plant.model.C2P, data=DAT1[1, ]-1600, pch=17) text(x=430, y=2000, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=430, y=1900, labels='Forests: wet season', cex=0.8) xnames0=c('Insecta','Hymenoptera','Coleoptera','Psocoptera','Arachnida') xnames70=c('Hemiptera','Diptera','Lepidoptera') text(x=c(3058-1600,540+30,810-100,73+50,176+30), y=c(2847-1600,514,664,65-20,165-20), pos=4, srt=0, cex=0.7, labels=xnames0, col=c(1,5,2,'grey50','gold3')) text(x=c(669-50,523-100,114-100), y=c(628+200,508+200,102+100), pos=4, srt=70, cex=0.7, labels=xnames70, col=c(4,3,6)) legend(1070, 200, legend=c(as.expression(bquote("Jackknife1"*italic('P')*',' ~ R^2 ~ "= 0.996")), as.expression(bquote("Jackknife2"*italic('P')*',' ~ R^2 ~ "= 0.989")), as.expression(bquote(" Chao2"*italic('P')*',' ~ R^2 ~ "= 0.995"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.4, cex=0.7) # mtext(text='Fig. S3a', side=3, at=-300, line=1.5) ## DAT2: dry season par(mar=c(4.2,4,3.5,3)) plot(Jack1inP~plant.model.J1P, data=DAT2[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=c(2:6,'grey50','gold3'), pch=16, xlim=c(70,2000), ylim=c(70,2000), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(1,1100, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2800','3200','3600'), tick=T) axis.break(2,1100, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT2[-1, ], col=c(2:6,'grey50','gold3'), pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT2[1, ]-1600, pch=16) points(Jack2inP~plant.model.J2P, data=DAT2[1, ]-1600, pch=15) points(Chao2P~plant.model.C2P, data=DAT2[1, ]-1600, pch=17) text(x=430, y=2000, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=430, y=1900, labels='Forests: dry season', cex=0.8) legend(1470, 180, legend=c(as.expression(bquote(~ R^2 ~ "= 0.996")), as.expression(bquote(~ R^2 ~ "= 0.990")), as.expression(bquote(~ R^2 ~ "= 0.975"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.5, cex=0.7) par(mfrow=c(1,1)) ``` ##### __3. open land only__ ```{r alpha_Mengsong_OL_25_alternative_modles} ### Arachnida not included due to the low sample size (<50) ### Insecta # read curve.in1.ol.csv, curve.in2.ol.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 1.52246151828E+001 b = 8.61921186601E-001 c = 8.98608836881E-001 # check the curve xx <- 1:657 # max(x.plant) = 657 yy <- a*exp(-exp(b-c*xx*0.01)); plot(I(yy*100)~xx, ylim=c(0,3000)) # asymptote # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # n <- 6 # K <- 3 # AICc.g <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 5.86628004431E+000 b = 8.15522676588E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 5.69274364314E-001 b = 5.71631553015E+000 c = -4.24197091892E-001 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=3) # asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 3.21196741209E+001 b = 1.01670030075E+000 c = 1.81350008389E-001 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 6.02927330068E+000 b = 9.74507877837E-001 c = 8.48360393095E-001 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 3.94084856712E+001 b = 5.67815474968E+000 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*100)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Linear Fit: y=a+bx # Coefficient Data: a = 1.14970375192E+000 b = 4.62962135948E+000 yy <- a+b*xx*0.01; points(I(yy*100)~xx, col=7) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.g, AICc.p, AICc.q, AICc.e, AICc.h, AICc.s, AICc.l)) # p s l # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation ransub <- sample(1:6, size=5, replace=F) Plantol_rs <- Plantol[ransub,] # rs=ransub MBCin1ol_rs <- MBCin1ol[ransub,] # remove empty columns Plantol_rs <- Plantol_rs[ ,specnumber(Plantol_rs, MARGIN=2)>0] MBCin1ol_rs <- MBCin1ol_rs[ ,specnumber(MBCin1ol_rs, MARGIN=2)>0] # 1049 -> 951 sac.plant.rs <- specaccum(Plantol_rs, "random") sac.in1.rs <- specaccum(MBCin1ol_rs, "random") plot(sac.in1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Insecta', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.in1.rs$richness # curve.in1 <- data.frame(x=x, y=y1) # write.csv(curve.in1, 'curve.in1.ol.rs.csv', row.names=F) # read the curve.in1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Power Fit: y=ax^b # Coefficient Data: a = 5.97885327101E+000 b = 7.78987269466E-001 f_p <- a*2.04^b # Linear Fit: y=a+bx # Coefficient Data: a = 1.28776737751E+000 b = 4.58525476867E+000 f_l <- a+b*2.04 # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 3.02548859447E+001 b = 4.00354137690E+000 f_s <- a*2.04/(b+2.04) # comparing the predicted with the actual value diff <- c(f_p, f_l, f_s)*100-dim(MBCin1ol)[2] # getting the differences which.min(abs(diff)) # Power Fit minimal # final choice # Power Fit: y=ax^b # Coefficient Data: a = 5.86628004431E+000 b = 8.15522676588E-001 # # estimate the plant species richness by non-parametric estimation acc.plant <- alpha.accum(comm=Plantol, func="nonparametric", runs=1) (x.plant <- acc.plant[6,c(10,11,14,15,18,19)]) # # predict the insect OTU richness from plant model y.in1 <- a*(x.plant*0.01)^b # # estimate the insect OTU richness by non-parametric estimation acc.in1 <- alpha.accum(comm=MBCin1ol, func="nonparametric", runs=1) Y.in1 <- acc.in1[6,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in1/(y.in1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 0.99 1.03 1.00 0.98 0.95 ### dry season ### # list candidates based on their ranks # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 5.59529750350E-001 b = 5.75542279225E+000 c = -3.64546604009E-001 yy <- a+b*xx*0.01+c*(xx*0.01)^2; plot(I(yy*100)~xx, ylim=c(0,3000)) # ok # # calculate AICc by hand # # AICc = n*ln(RSS/n) + 2*K + (2*K*(K+1))/(n-K-1) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # copy from CurveExpert, which is also saved in AICc.xlsx # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 1.43572561005E+000 b = 4.90438106192E+000 c = 2.79297444847E+001 d = 1.37526376669E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 5.96011575361E+000 b = 8.33750557616E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 1.95151328010E+001 b = 1.81929804472E+001 c = 2.91456453984E-001 d = 1.29080197786E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=4) # asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 3.79915663696E+001 b = 1.01371121975E+000 c = 1.54245304157E-001 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e3 <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 4.49509060498E+001 b = 6.50564167658E+000 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*100)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association: y=a(1-exp(-bx) # Coefficient Data: a = 2.54832546396E+001 b = 2.67766283826E-001 yy <- a*(1-exp(-b*xx*0.01)); points(I(yy*100)~xx, col=7) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.q, AICc.m, AICc.p, AICc.w, AICc.e3, AICc.s, AICc.e)) # p s q # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBCin2ol_rs <- MBCin2ol[ransub,] # rs=ransub # remove empty columns MBCin2ol_rs <- MBCin2ol_rs[,specnumber(MBCin2ol_rs, MARGIN=2)>0] # 1079 -> 962 sac.in2.rs <- specaccum(MBCin2ol_rs, "random") plot(sac.in2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Insecta', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.in2.rs$richness # curve.in2 <- data.frame(x=x, y=y2) # write.csv(curve.in2, 'curve.in2.ol.rs.csv', row.names=F) # read the curve.in2.ol.rs.csv into CurveExpert # scale x and y by 0.01 # Power Fit: y=ax^b # Coefficient Data: a = 5.93256712878E+000 b = 8.08158206190E-001 f_p <- a*2.04^b # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 7.60860404859E-001 b = 5.46806773408E+000 c = -3.24109798227E-001 f_q <- a+b*2.04+c*2.04^2 # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 3.49803327273E+001 b = 4.84033318274E+000 f_s <- a*2.04/(b+2.04) # comparing the predicted with the actual value diff <- c(f_q, f_s, f_p)*100-dim(MBCin2ol)[2] # getting the differences which.min(abs(diff)) # Quadratic Fit minimal # final choice # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 5.59529750350E-001 b = 5.75542279225E+000 c = -3.64546604009E-001 # # predict the insect OTU richness from plant model y.in2 <- a+b*x.plant*0.01+c*(x.plant*0.01)^2 # # estimate the insect OTU richness by non-parametric estimation acc.in2 <- alpha.accum(comm=MBCin2ol, func="nonparametric", runs=1) Y.in2 <- acc.in2[6,c(10,11,14,15,18,19)] # # compare the two estimates of insect OTU richness Y.in2/(y.in2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.08 1.08 1.16 1.03 1.15 #### apply to Insecta orders #### #### Coleoptera #### # read curve.cole1.csv, curve.cole2.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Linear Fit: y=a+bx # Coefficient Data: a = 6.46971328337E-002 b = 6.91791998987E-001 yy <- a+b*xx*0.01; plot(I(yy*100)~xx, ylim=c(0,600)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 6.90941858954E-001 b = 1.09480378098E+000 c = 8.09375061162E-001 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 7.77833882471E-002 b = 6.67291589846E-001 c = 9.56387048729E-003 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 6.61844957261E-001 b = -1.35042489765E-001 c = 1.03434670578E+000 yy <- a*(xx*0.01-b)^c; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Power Fit: y=ax^b # Coefficient Data: a = 7.59923782814E-001 b = 9.26716111291E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 1.46008136962E+001 b = 1.82327915749E+001 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*100)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.sg <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.l, AICc.h, AICc.q, AICc.s, AICc.p, AICc.sg)) # l p h # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBCcole1ol_rs <- MBCcole1ol[ransub,] # rs=ransub # remove empty columns MBCcole1ol_rs <- MBCcole1ol_rs[,specnumber(MBCcole1ol_rs, MARGIN=2)>0] # 148 -> 142 sac.cole1.rs <- specaccum(MBCcole1ol_rs, "random") plot(sac.cole1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Coleptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.cole1.rs$richness # curve.cole1 <- data.frame(x=x, y=y1) # write.csv(curve.cole1, 'curve.cole1.ol.rs.csv', row.names=F) # read the curve.cole1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Power Fit: y=ax^b # Coefficient Data: a = 8.59917923649E-001 b = 8.43712463005E-001 f_p <- a*2.04^b # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 8.65177072369E-001 b = 9.94345465511E-001 c = 8.50113657449E-001 f_h <- a*(b^2.04)*(2.04^c) # Linear Fit: y=a+bx # Coefficient Data: a = 1.30273793295E-001 b = 7.17773023824E-001 f_l <- a+b*2.04 # comparing the predicted with the actual value diff <- c(f_l, f_h, f_p)*100-dim(MBCcole1ol)[2] # getting the differences which.min(abs(diff)) # Hoerl Model minimal # final choice # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 6.90941858954E-001 b = 1.09480378098E+000 c = 8.09375061162E-001 # # predict the Coleoptera species richness from plant model y.cole1 <- a*(b^(x.plant*0.01))*((x.plant*0.01)^c) # # estimate the Coleoptera species richness by non-parametric estimation acc.cole1 <- alpha.accum(comm=MBCcole1ol, func="nonparametric", runs=1) Y.cole1 <- acc.cole1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole1/(y.cole1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.95 0.85 0.91 0.79 0.85 0.72 ### dry season ### # list candidates based on their ranks # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 3.19634628653E-001 b = 6.05164099609E+000 c = 8.58275613872E+000 d = 1.43654894717E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); plot(I(yy*100)~xx, ylim=c(0,800)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 5.57933655290E+000 b = 5.26889677431E+000 c = 2.53608348232E-001 d = 1.39322052164E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=2) # asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 1.50334801764E+000 b = 9.36732034615E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.56692547079E-001 b = 1.17482005809E+000 c = 2.31663814568E-001 d = -6.98533856275E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=4) # drop # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.46589626873E-001 b = 1.19502351039E+000 c = -1.44785255211E-001 d = 4.30386460533E-002 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=5) # drop # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 4.66920103929E+000 b = 9.94942768769E-001 c = 8.57598379302E-001 yy <- a*exp(-exp(b-c*xx*0.01)); points(I(yy*100)~xx, col=6) # asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.g <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 5.53779425909E-002 b = 1.48213652705E+000 c = -3.55766035812E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=7) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 2.33139342066E+001 b = 1.00176192478E+000 c = 6.48001917351E-002 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*100)~xx, col=8) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e3 <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include one more two-parameter function, as its AICc could be high even when its rank is low # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 3.14571558259E+001 b = 1.99011508408E+001 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*100)~xx, col=9) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association: y=a(1-exp(-bx)) # Coefficient Data: a = 1.64951655345E+001 b = 9.56674627406E-002 yy <- a*(1-exp(-b*xx*0.01)); points(I(yy*100)~xx, col=10) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.m, AICc.w, AICc.p, AICc.g, AICc.q, AICc.e3, AICc.s, AICc.e)) # p s e # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBCcole2ol_rs <- MBCcole2ol[ransub,] # rs=ransub # remove empty columns MBCcole2ol_rs <- MBCcole2ol_rs[,specnumber(MBCcole2ol_rs, MARGIN=2)>0] # 293 -> 245 sac.cole2.rs <- specaccum(MBCcole2ol_rs, "random") plot(sac.cole2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Coleptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.cole2.rs$richness # curve.cole2 <- data.frame(x=x, y=y2) # write.csv(curve.cole2, 'curve.cole2.ol.rs.csv', row.names=F) # read the curve.cole2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Exponential Association: y=a(1-exp(-bx)) # Coefficient Data: a = 1.00086517122E+001 b = 1.55207814777E-001 f_e <- a*(1-exp(-b*2.04)) # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 1.87644859162E+001 b = 1.20429234937E+001 f_s <- a*2.04/(b+2.04) # Power Fit: y=ax^b # Coefficient Data: a = 1.43100443246E+000 b = 9.13750785940E-001 f_p <- a*2.04^b # comparing the predicted with the actual value diff <- c(f_e, f_s, f_p)*100-dim(MBCcole2ol)[2] # getting the differences which.min(abs(diff)) # Power Fit minimal # final choice # Power Fit: y=ax^b # Coefficient Data: a = 1.50334801764E+000 b = 9.36732034615E-001 # # predict the Coleoptera species richness from plant model y.cole2 <- a*(x.plant*0.01)^b # # estimate the Coleoptera species richness by non-parametric estimation acc.cole2 <- alpha.accum(comm=MBCcole2ol, func="nonparametric", runs=1) Y.cole2 <- acc.cole2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Coleoptera species richness Y.cole2/(y.cole2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.98 0.94 0.97 0.92 0.86 0.82 #### Diptera #### # read curve.di1.ol.csv, curve.di2.ol.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 2.80696469491E-001 b = 1.10580260237E+000 c = -6.24848394431E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; plot(I(yy*100)~xx, ylim=c(0,600)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 8.01986348926E+000 b = 1.03370999719E+000 c = 1.41026940451E-001 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 1.21431472345E+000 b = 1.09139758765E+000 c = 8.22667766590E-001 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = 1.94179857023E-001 b = 8.74591305563E-002 c = 8.22667816350E-001 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=4) # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Power Fit: y=ax^b # Coefficient Data: a = 1.33528415133E+000 b = 7.43058791219E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Linear Fit: y=a+bx # Coefficient Data: a = 3.66194549949E-001 b = 9.45730993973E-001 yy <- a+b*xx*0.01; points(I(yy*100)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.q, AICc.e, AICc.m, AICc.v, AICc.p, AICc.l)) # p l q # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBCdi1ol_rs <- MBCdi1ol[ransub,] # rs=ransub # remove empty columns MBCdi1ol_rs <- MBCdi1ol_rs[,specnumber(MBCdi1ol_rs, MARGIN=2)>0] # 228 -> 206 sac.di1.rs <- specaccum(MBCdi1ol_rs, "random") plot(sac.di1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.di1.rs$richness # curve.di1 <- data.frame(x=x, y=y1) # write.csv(curve.di1, 'curve.di1.ol.rs.csv', row.names=F) # read the curve.di1.ol.rs.csv into CurveExpert # scale x and y by 0.01 # Power Fit: y=ax^b # Coefficient Data: a = 1.34263259922E+000 b = 7.10915938188E-001 f_p <- a*2.04^b # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 2.65859671126E-001 b = 1.17187665387E+000 c = -1.02794674513E-001 f_q <- a+b*2.04+c*2.04^2 # Linear Fit: y=a+bx # Coefficient Data: a = 3.76858061736E-001 b = 9.37023919656E-001 f_l <- a+b*2.04 # comparing the predicted with the actual value diff <- c(f_q, f_p, f_l)*100-dim(MBCdi1ol)[2] # getting the differences which.min(abs(diff)) # Linear Fit minimal # final choice # Linear Fit: y=a+bx # Coefficient Data: a = 3.66194549949E-001 b = 9.45730993973E-001 # # predict the Diptera species richness from plant model y.di1 <- a+b*x.plant*0.01 # # estimate the Diptera species richness by non-parametric estimation acc.di1 <- alpha.accum(comm=MBCdi1ol, func="nonparametric", runs=1) Y.di1 <- acc.di1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di1/(y.di1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.96 0.85 0.93 0.82 0.84 0.74 ### dry season ### # list candidates based on their ranks # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 1.26048691861E+000 b = 9.65854609739E-001 c = 7.24489699761E-001 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); plot(I(yy*100)~xx, ylim=c(0,700)) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.76603074113E-001 b = 1.27213093952E+000 c = -2.68504291682E-001 d = 3.69834551557E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.3p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = 2.37494150777E-001 b = -3.97879315153E-002 c = 6.44829056292E-001 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 1.26806540912E+000 b = 9.60991983666E-001 c = 6.44829110881E-001 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Power Fit: y=ax^b # Coefficient Data: a = 1.21423662609E+000 b = 6.81486045396E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 4.44281530857E+000 b = 2.61083797400E+000 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*100)~xx, col=6) # asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.h, AICc.3p, AICc.v, AICc.m, AICc.p, AICc.s)) # p h v # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBCdi2ol_rs <- MBCdi2ol[ransub,] # rs=ransub # remove empty columns MBCdi2ol_rs <- MBCdi2ol_rs[,specnumber(MBCdi2ol_rs, MARGIN=2)>0] # 197 -> 190 sac.di2.rs <- specaccum(MBCdi2ol_rs, "random") plot(sac.di2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Diptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.di2.rs$richness # curve.di2 <- data.frame(x=x, y=y2) # write.csv(curve.di2, 'curve.di2.ol.rs.csv', row.names=F) # read the curve.di2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Power Fit: y=ax^b # Coefficient Data: a = 1.28626419518E+000 b = 6.56733389630E-001 f_p <- a*2.04^b # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = 2.71294100600E-001 b = -1.76224330148E-002 c = 6.38393258068E-001 f_v <- exp(a+b/2.04+c*log(2.04)) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 1.31186552659E+000 b = 9.82130340576E-001 c = 6.76442775070E-001 f_h <- a*(b^2.04)*(2.04^c) # comparing the predicted with the actual value diff <- c(f_h, f_p, f_v)*100-dim(MBCdi2ol)[2] # getting the differences which.min(abs(diff)) # Hoerl Model minimal # final choice # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 1.26048691861E+000 b = 9.65854609739E-001 c = 7.24489699761E-001 # # predict the Diptera species richness from plant model y.di2 <- a*(b^(x.plant*0.01))*((x.plant*0.01)^c) # # estimate the Diptera species richness by non-parametric estimation acc.di2 <- alpha.accum(comm=MBCdi2ol, func="nonparametric", runs=1) Y.di2 <- acc.di2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Diptera species richness Y.di2/(y.di2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.04 1.01 1.06 1.04 0.96 0.94 #### Hemiptera #### # read curve.he1.ol.csv, curve.he2.ol.csv into CurveExpert # scale x and y by 0.01 ### wet season ### # list candidates based on their ranks # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = 4.06452844119E-001 b = -1.18700826371E-001 c = 6.84977443644E-001 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 1.50147900010E+000 b = 8.88071964025E-001 c = 6.84977527604E-001 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 1.46546698601E+000 b = 1.25792181332E-001 c = 7.00226509145E-001 yy <- a*(xx*0.01-b)^c; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Hoerl Model: y=a*(b^x)*(x^c) # Coefficient Data: a = 1.46640175700E+000 b = 9.06434869522E-001 c = 9.15797039082E-001 yy <- a*(b^(xx*0.01))*((xx*0.01)^c); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.h <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Power Fit: y=ax^b # Coefficient Data: a = 1.32087203064E+000 b = 7.91523196882E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Linear Fit: y=a+bx # Coefficient Data: a = 2.86536856175E-001 b = 1.01101503970E+000 yy <- a+b*xx*0.01; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.v, AICc.m, AICc.s, AICc.h, AICc.p, AICc.l)) # top three functions # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBChe1ol_rs <- MBChe1ol[ransub,] # rs=ransub # remove empty columns MBChe1ol_rs <- MBChe1ol_rs[,specnumber(MBChe1ol_rs, MARGIN=2)>0] # 231 -> 208 sac.he1.rs <- specaccum(MBChe1ol_rs, "random") plot(sac.he1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.he1.rs$richness # curve.he1 <- data.frame(x=x, y=y1) # write.csv(curve.he1, 'curve.he1.ol.rs.csv', row.names=F) # read the curve.he1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = 2.71118929852E-001 b = 1.89172263865E-002 c = 7.57066513295E-001 f_v <- exp(a+b/2.04+c*log(2.04)) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 1.31143015167E+000 b = 1.01909677072E+000 c = 7.57066513289E-001 f_m <- a*b^(1/2.04)*2.04^c # Shifted Power Fit: y=a*(x-b)^c # Coefficient Data: a = 1.31084380469E+000 b = -2.59667888848E-002 c = 7.57228380265E-001 f_s <- a*(2.04-b)^c # comparing the predicted with the actual value diff <- c(f_v, f_m, f_s)*100-dim(MBChe1ol)[2] # getting the differences which.min(abs(diff)) # Vapor Pressure Model minimal # final choice # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = 4.06452844119E-001 b = -1.18700826371E-001 c = 6.84977443644E-001 # # predict the Hemiptera species richness from plant model y.he1 <- exp(a+b/(x.plant*0.01)+c*log(x.plant*0.01)) # # estimate the Hemiptera species richness by non-parametric estimation acc.he1 <- alpha.accum(comm=MBChe1ol, func="nonparametric", runs=1) Y.he1 <- acc.he1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he1/(y.he1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.02 0.97 1.01 0.96 0.85 0.81 ### dry season ### # list candidates based on their ranks # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 2.90069752990E+000 b = 8.59576859369E-001 c = 8.64033893504E-001 yy <- a*exp(-exp(b-c*xx*0.01)); plot(I(yy*100)~xx, ylim=c(0,500)) # asymptote # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.g <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # MMF Model: y=(a*b+c*x^d)/(b+x^d) # Coefficient Data: a = 3.32615476266E-001 b = 4.15034216213E+000 c = 4.15184392733E+000 d = 1.54232346034E+000 yy <- (a*b+c*(xx*0.01)^d)/(b+(xx*0.01)^d); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Rational Function: y=(a+bx)/(1+cx+dx^2) # Coefficient Data: a = 1.98048846778E-001 b = 7.71120206065E-001 c = -1.53739380382E-001 d = 5.48860750326E-002 yy <- (a+b*xx*0.01)/(1+c*xx*0.01+d*(xx*0.01)^2); points(I(yy*100)~xx, col=3) # drop # Weibull Model: y=a-b*exp(-c*x^d) # Coefficient Data: a = 2.86981677355E+000 b = 2.53987883845E+000 c = 3.45518570990E-001 d = 1.48404115269E+000 yy <- a-b*exp(-c*(xx*0.01)^d); points(I(yy*100)~xx, col=4) # asymptote # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 4 # AICc.w <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # 3rd degree Polynomial Fit: y=a+bx+cx^2+dx^3... # Coefficient Data: a = 1.98707954985E-001 b = 7.94084455411E-001 c = 1.35150319096E-001 d = -5.24079162200E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2+d*(xx*0.01)^3; points(I(yy*100)~xx, col=5) # drop # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.22696073010E-001 b = 1.02465045610E+000 c = -6.53483871459E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 6.60072548932E+000 b = 1.01721047003E+000 c = 1.58831484687E-001 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*100)~xx, col=7) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Power Fit: y=ax^b # Coefficient Data: a = 1.08482222766E+000 b = 8.17205327705E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=8) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include one more two-parameter functions, as its AICc could be high even when its rank is low # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 7.40602790560E+000 b = 5.79113909942E+000 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*100)~xx, col=9) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.g, AICc.m, AICc.w, AICc.q, AICc.e, AICc.p, AICc.s)) # p g q # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBChe2ol_rs <- MBChe2ol[ransub,] # rs=ransub # remove empty columns MBChe2ol_rs <- MBChe2ol_rs[,specnumber(MBChe2ol_rs, MARGIN=2)>0] # 194 -> 174 sac.he2.rs <- specaccum(MBChe2ol_rs, "random") plot(sac.he2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hemiptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.he2.rs$richness # curve.he2 <- data.frame(x=x, y=y2) # write.csv(curve.he2, 'curve.he2.ol.rs.csv', row.names=F) # read the curve.he2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Power Fit: y=ax^b # Coefficient Data: a = 1.10269445175E+000 b = 7.63607952965E-001 f_p <- a*2.04^b # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.58141898970E-001 b = 1.02922384543E+000 c = -8.75672289095E-002 f_q <- a+b*2.04+c*2.04^2 # Gompertz Relation: y=a*exp(-exp(b-cx)) # Coefficient Data: a = 2.56740352951E+000 b = 7.89306256736E-001 c = 9.49463279886E-001 f_g <- a*exp(-exp(b-c*2.04)) # comparing the predicted with the actual values diff <- c(f_g, f_p, f_q)*100-dim(MBChe2ol)[2] # getting the differences which.min(abs(diff)) # Power Fit minimal # final choice # Power Fit: y=ax^b # Coefficient Data: a = 1.08482222766E+000 b = 8.17205327705E-001 # # predict the Hemiptera species richness from plant model y.he2 <- a*(x.plant*0.01)^b # # estimate the Hemiptera species richness by non-parametric estimation acc.he2 <- alpha.accum(comm=MBChe2ol, func="nonparametric", runs=1) Y.he2 <- acc.he2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hemiptera species richness Y.he2/(y.he2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 0.95 1.00 0.95 0.90 0.85 #### Hymenoptera #### # read curve.hy1.ol.csv, curve.hy2.ol.csv into CurveExpert # scale x and y 0.01 ### wet season ### # list candidates based on their ranks # Power Fit: y=ax^b # Coefficient Data: a = 1.19440404175E+000 b = 8.81370156845E-001 yy <- a*(xx*0.01)^b; plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 1.10012722438E-001 b = 1.11267813803E+000 c = -3.30097990818E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Exponential Association (3): y=a(b-exp(-cx)) # Coefficient Data: a = 1.42760644527E+001 b = 1.00683879839E+000 c = 7.97077617594E-002 yy <- a*(b-exp(-c*xx*0.01)); points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.e <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = 1.26906567543E-001 b = 4.73058637745E-002 c = 9.23057660634E-001 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Linear Fit: y=a+bx # Coefficient Data: a = 1.55180069957E-001 b = 1.02811471946E+000 yy <- a+b*xx*0.01; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 1.31336068750E+001 b = 9.97438429124E+000 yy <- a*xx*0.01/(b+xx*0.01); points(I(yy*100)~xx, col=6) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.s <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.p, AICc.q, AICc.e, AICc.v, AICc.l, AICc.s)) # p l s, the results are same when including one more two-parameter function # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBChy1ol_rs <- MBChy1ol[ransub,] # rs=ransub # remove empty columns MBChy1ol_rs <- MBChy1ol_rs[,specnumber(MBChy1ol_rs, MARGIN=2)>0] # 225 -> 197 sac.hy1.rs <- specaccum(MBChy1ol_rs, "random") plot(sac.hy1.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_wet)') # clear relationship # y1 <- sac.hy1.rs$richness # curve.hy1 <- data.frame(x=x, y=y1) # write.csv(curve.hy1, 'curve.hy1.ol.rs.csv', row.names=F) # read the curve.hy1.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Saturation Growth-Rate Model: y=ax/(b+x) # Coefficient Data: a = 6.99270867095E+000 b = 4.62211888072E+000 f_s <- a*2.04/(b+2.04) # Power Fit: y=ax^b # Coefficient Data: a = 1.22983783908E+000 b = 8.05039244786E-001 f_p <- a*2.04^b # Linear Fit: y=a+bx # Coefficient Data: a = 2.29387818062E-001 b = 9.79398429285E-001 f_l <- a+b*2.04 # comparing the predicted with the actual value diff <- c(f_s, f_p, f_l)*100-dim(MBChy1ol)[2] # getting the differences which.min(abs(diff)) # Linear Fit minimal # final choice # Linear Fit: y=a+bx # Coefficient Data: a = 1.55180069957E-001 b = 1.02811471946E+000 # # predict the Hymenoptera species richness from plant model y.hy1 <- a+b*x.plant*0.01 # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy1 <- alpha.accum(comm=MBChy1ol, func="nonparametric", runs=1) Y.hy1 <- acc.hy1[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy1/(y.hy1*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 1.01 0.99 1.02 1.00 1.12 1.09 ### dry season ### # list candidates based on their ranks # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 8.80473087468E-002 b = 9.38000357412E-001 c = -3.46776265320E-002 yy <- a+b*xx*0.01+c*(xx*0.01)^2; plot(I(yy*100)~xx) # ok # # calculate AICc by hand # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.q <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Vapor Pressure Model: y=exp(a+b/x+cln(x)) # Coefficient Data: a = -3.82808513610E-002 b = 3.07088291851E-002 c = 9.01745063891E-001 yy <- exp(a+b/(xx*0.01)+c*log(xx*0.01)); points(I(yy*100)~xx, col=2) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.v <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Modified Hoerl Model: y=a*b^(1/x)*x^c # Coefficient Data: a = 9.62438701156E-001 b = 1.03118199318E+000 c = 9.01745182292E-001 yy <- a*b^(1/(xx*0.01))*(xx*0.01)^c; points(I(yy*100)~xx, col=3) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 3 # AICc.m <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Further include two more two-parameter functions, as their AICc could be high even when their ranks are low (due to low sample size of open-land plots n = 6) # Power Fit: y=ax^b # Coefficient Data: a = 9.94692952672E-001 b = 8.74636214198E-001 yy <- a*(xx*0.01)^b; points(I(yy*100)~xx, col=4) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.p <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # Linear Fit: y=a+bx # Coefficient Data: a = 1.35496746559E-001 b = 8.49164353287E-001 yy <- a+b*xx*0.01; points(I(yy*100)~xx, col=5) # ok # Resid <- as.numeric(readClipboard(format = 1, raw = F)) # K <- 2 # AICc.l <- n*log(sum(Resid^2)/n) + 2*K + (2*K*(K+1))/(n-K-1) # order(c(AICc.q, AICc.v, AICc.m, AICc.p, AICc.l)) # p q l, the results are same when including one more two-parameter function # re-fit the top three functions for a randomized data set of 5 instead of 6 plots to assess their suitability for extrapolation MBChy2ol_rs <- MBChy2ol[ransub,] # rs=ransub # remove empty columns MBChy2ol_rs <- MBChy2ol_rs[,specnumber(MBChy2ol_rs, MARGIN=2)>0] # 186 -> 165 sac.hy2.rs <- specaccum(MBChy2ol_rs, "random") plot(sac.hy2.rs$richness ~ sac.plant.rs$richness, xlab='Plants', ylab='Hymenoptera', main='Accumulated species richness comparison (Mengsong_dry)') # clear relationship # y2 <- sac.hy2.rs$richness # curve.hy2 <- data.frame(x=x, y=y2) # write.csv(curve.hy2, 'curve.hy2.ol.rs.csv', row.names=F) # read the curve.hy2.forest.rs.csv into CurveExpert # scale x and y by 0.01 # Power Fit: y=ax^b # Coefficient Data: a = 9.89652414297E-001 b = 8.59187148790E-001 f_p <- a*2.04^b # Quadratic Fit: y=a+bx+cx^2 # Coefficient Data: a = 6.42444815870E-002 b = 9.90809598981E-001 c = -6.48683396308E-002 f_q <- a+b*2.04+c*2.04^2 # Linear Fit: y=a+bx # Coefficient Data: a = 1.34289757129E-001 b = 8.42606328739E-001 f_l <- a+b*2.04 # comparing the predicted with the actual value diff <- c(f_p, f_q, f_l)*100-dim(MBChy2ol)[2] # getting the differences which.min(abs(diff)) # Linear Fit minimal # final choice # Linear Fit: y=a+bx # Coefficient Data: a = 1.35496746559E-001 b = 8.49164353287E-001 # # predict the Hymenoptera species richness from plant model y.hy2 <- a+b*x.plant*0.01 # # estimate the Hymenoptera species richness by non-parametric estimation acc.hy2 <- alpha.accum(comm=MBChy2ol, func="nonparametric", runs=1) Y.hy2 <- acc.hy2[6,c(10,11,14,15,18,19)] # # compare the two estimates of Hymenoptera species richness Y.hy2/(y.hy2*100) # Jack1in Jack1inP Jack2in Jack2inP Chao2 Chao2P # 0.98 0.93 0.98 0.92 0.97 0.92 #### Lepidoptera #### not included due to the low sample size (<50) #### Psocoptera #### not included due to the low sample size (<50) #### calculate the fitness #### DAT <- data.frame(Insect1=c(Y.in1[c(2,4,6)], y.in1[c(2,4,6)]*100), Insect2=c(Y.in2[c(2,4,6)], y.in2[c(2,4,6)]*100), Cole1=c(Y.cole1[c(2,4,6)], y.cole1[c(2,4,6)]*100), Cole2=c(Y.cole2[c(2,4,6)], y.cole2[c(2,4,6)]*100), Di1=c(Y.di1[c(2,4,6)], y.di1[c(2,4,6)]*100), Di2=c(Y.di2[c(2,4,6)], y.di2[c(2,4,6)]*100), He1=c(Y.he1[c(2,4,6)], y.he1[c(2,4,6)]*100), He2=c(Y.he2[c(2,4,6)], y.he2[c(2,4,6)]*100), Hy1=c(Y.hy1[c(2,4,6)], y.hy1[c(2,4,6)]*100), Hy2=c(Y.hy2[c(2,4,6)], y.hy2[c(2,4,6)]*100), row.names=c('Jack1inP', 'Jack2inP', 'Chao2P', 'plant.model.J1P', 'plant.model.J2P', 'plant.model.C2P')) # only present P-corrected versions DAT <- data.frame(t(DAT)) DAT1 <- DAT[c(1,3,5,7,9), ] # wet season DAT2 <- DAT[c(2,4,6,8,10), ] # dry season #### calculate the R^2 fitted to the y=x model #### options(digits=4) ### wet season ## Jack1inP yi <- DAT1[-1, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.472 ## Jack2inP yi <- DAT1[-1, ]$Jack2inP ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.1913 ## Chao2P yi <- DAT1[-1, ]$Chao2P ym <- mean(yi) fi <- DAT1[-1, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.07264 ### dry season ## Jack1inP yi <- DAT2[-1, ]$Jack1inP # only include individual insect orders ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.J1P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9379 ## Jack2inP yi <- DAT2[-1, ]$Jack2inP ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.J2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.9077 ## Chao2P yi <- DAT2[-1, ]$Chao2P ym <- mean(yi) fi <- DAT2[-1, ]$plant.model.C2P # modeled (predicted) value SStotal <- sum((yi-ym)^2) # total sum of square SSres <- sum((yi-fi)^2) # residual sum of square (Rsquare <- 1-SSres/SStotal) # 0.5234 #### calculate the correlations between two estimates #### # wet season cor.test(y=DAT1[-1, ]$Jack1inP, x=DAT1[-1, ]$plant.model.J1P, method='pearson') # r=0.9023 cor.test(y=DAT1[-1, ]$Jack2inP, x=DAT1[-1, ]$plant.model.J2P, method='pearson') # 0.832 cor.test(y=DAT1[-1, ]$Chao2P, x=DAT1[-1, ]$plant.model.C2P, method='pearson') # 0.8067 # dry season cor.test(y=DAT2[-1, ]$Jack1inP, x=DAT2[-1, ]$plant.model.J1P, method='pearson') # 0.9967 cor.test(y=DAT2[-1, ]$Jack2inP, x=DAT2[-1, ]$plant.model.J2P, method='pearson') # 0.9953 cor.test(y=DAT2[-1, ]$Chao2P, x=DAT2[-1, ]$plant.model.C2P, method='pearson') # 0.992 options(digits=2) #### plot together #### (Fig. S3b) ## DAT1: wet season # windows(width=11.69, height=6, pointsize=14) par(mfrow=c(1,2), mar=c(4.2,6,3.5,1)) # default margin = ~4.1 for y plot(Jack1inP~plant.model.J1P, data=DAT1[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='Non-parametric estimates (no. spp.)', col=2:5, pch=16, xlim=c(300,2100), ylim=c(300,2100), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT1[-1, ], col=2:5, pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT1[-1, ], col=2:5, pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT1[1, ]-800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT1[1, ]-800, pch=15) points(Chao2P~plant.model.C2P, data=DAT1[1, ]-800, pch=17) text(x=630, y=2090, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=680, y=1990, labels='Open land: wet season', cex=0.8) xnames=c('Insecta','Coleoptera','Diptera','Hymenoptera') text(x=c(2469-800,488,588+100,614+130), y=c(2598-800-200,412-100,488,755-50), pos=4, srt=0, cex=0.7, labels=xnames, col=c(1:3,5)) # x:DAT1$plant.model.J2P, y:DAT1$Chao2P text(x=492-150, y=435+100, pos=4, srt=70, cex=0.7, labels='Hemiptera', col=4) # x:DAT1$plant.model.J2P, y:DAT1$Chao2P legend(1160, 420, legend=c(as.expression(bquote("Jackknife1"*italic('P')*',' ~ R^2 ~ "= 0.472")), as.expression(bquote("Jackknife2"*italic('P')*',' ~ R^2 ~ "= 0.191")), as.expression(bquote(" Chao2"*italic('P')*',' ~ R^2 ~ "= 0.073"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.4, cex=0.7) # mtext(text='Fig. S3b', side=3, at=-50, line=1.5) ## DAT2: dry season par(mar=c(4.2,4,3.5,3)) plot(Jack1inP~plant.model.J1P, data=DAT2[-1, ], xlab='Plant-model estimates (no. spp.)', ylab='', col=2:5, pch=16, xlim=c(300,2100), ylim=c(300,2100), xaxt='n', yaxt='n') # circle = Jack1inP axis(1, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(1,1000, brw=0.015) axis(2, at=c(400,800,1200,1600,2000), label=c('400','800','2000','2400','2800'), tick=T) axis.break(2,1000, brw=0.015) abline(a=0, b=1, lty=2) points(Jack2inP~plant.model.J2P, data=DAT2[-1, ], col=2:5, pch=15) # square = Jack2inP points(Chao2P~plant.model.C2P, data=DAT2[-1, ], col=2:5, pch=17) # triangle = Chao2P # add Insecta points(Jack1inP~plant.model.J1P, data=DAT2[1, ]-800, pch=16) points(Jack2inP~plant.model.J2P, data=DAT2[1, ]-800, pch=15) points(Chao2P~plant.model.C2P, data=DAT2[1, ]-800, pch=17) text(x=630, y=2050, labels=as.expression(bquote(italic('Same-site prediction'))), cex=0.8) text(x=680, y=1950, labels='Open land: dry season', cex=0.8) legend(1540, 400, legend=c(as.expression(bquote(~ R^2 ~ "= 0.938")), as.expression(bquote(~ R^2 ~ "= 0.908")), as.expression(bquote(~ R^2 ~ "= 0.523"))), pch=c(16,15,17), bty='n', yjust=0.5, x.intersp=0.5, y.intersp=0.5, cex=0.7) par(mfrow=c(1,1)) ``` ### 2. beta diversity level: Procrustes test between plants and insects Using __jaccard__ dissimilarity index, which is rank-order similar with __Bray-Curtis__ (default choice). The help file of _metaMDS_ suggests __Jaccard__ index which is metric probably should be preferred instead of the default __Bray-Curtis__ which is semimetric. __chao__ dissimilarity which takes into account the number of unseen species pairs (Chao et al. 2005) is currently not availabe for our incidence data. _A good rule of thumb: stress > 0.05 provides an excellent representation in reduced dimensions, > 0.1 is great, >0.2 is good/ok, and stress > 0.3 provides a poor representation._ By [Jon Lefcheck](http://jonlefcheck.net/2012/10/24/nmds-tutorial-in-r/) Our goal is to make stress < 0.2 (great level). #### _Yinggeling, Hainan_ Setting k=2 * stress: + Setting k=2: all with stress < 0.2 except Hemiptera (0.24) + Setting k=3: all with stress < 0.2 (Hemiptera=0.16) + Setting k=4: all with stress < 0.2 (Hemiptera=0.12) * performance: + Setting k=2 gives 2 correlation levels (0 with tree) with p > 0.05 + Setting k=3 gives 5 correlation levels (1 with tree) with p > 0.05 + Setting k=4 gives 4 correlation levels (0 with tree) with p > 0.05 ```{r beta_Yinggeling} MBCin.jmds <- metaMDS(MBCin, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCin.jmds <- metaMDS(MBCin, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=MBCin.jmds) # stress 0.15 MBCcole.jmds <- metaMDS(MBCcole, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCcole.jmds <- metaMDS(MBCcole, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=MBCcole.jmds) # stress 0.2 MBCdi.jmds <- metaMDS(MBCdi, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCdi.jmds <- metaMDS(MBCdi, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=MBCdi.jmds) # stress 0.16 MBChe.jmds <- metaMDS(MBChe, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChe.jmds <- metaMDS(MBChe, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=MBChe.jmds) # stress 0.24 MBChy.jmds <- metaMDS(MBChy, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChy.jmds <- metaMDS(MBChy, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=MBChy.jmds) # stress 0.16 MBCle.jmds <- metaMDS(MBCle, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCle.jmds <- metaMDS(MBCle, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=MBCle.jmds) # stress 0.19 # # The results of tree incidence data and tree abundance data are similar, thus use incidence data to keep consistent with plant data of Mengsong. # Tree.ab.jmds <- metaMDS(Tree, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) # abundante data # Tree.ab.jmds <- metaMDS(Tree, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=Tree.ab.jmds) # stress 0.14 Tree[Tree>0] <- 1 # convert to incidence data Tree.jmds <- metaMDS(Tree, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE) Tree.jmds <- metaMDS(Tree, distance='jaccard', k=2, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous=Tree.jmds) # stress 0.13 # below statistics are presented in Table 1a (protest1 <- protest(MBCin.jmds, Tree.jmds, symmetric=TRUE, permutation=9999)) # r=0.76 # (protest1ab <- protest(MBCin.jmds, Tree.ab.jmds, symmetric=TRUE, permutation=9999)) # r=0.74 (protest2 <- protest(MBCcole.jmds, MBCdi.jmds, symmetric=TRUE, permutation=9999)) # r=0.54 (protest3 <- protest(MBCcole.jmds, MBChe.jmds, symmetric=TRUE, permutation=9999)) # r=0.47 (protest4 <- protest(MBCcole.jmds, MBChy.jmds, symmetric=TRUE, permutation=9999)) # r=0.63 (protest5 <- protest(MBCcole.jmds, MBCle.jmds, symmetric=TRUE, permutation=9999)) # r=0.43 (protest6 <- protest(MBCcole.jmds, Tree.jmds, symmetric=TRUE, permutation=9999)) # r=0.44 # (protest6ab <- protest(MBCcole.jmds, Tree.ab.jmds, symmetric=TRUE, permutation=9999)) # r=0.45 (protest7 <- protest(MBCdi.jmds, MBChe.jmds, symmetric=TRUE, permutation=9999)) # r=0.64 (protest8 <- protest(MBCdi.jmds, MBChy.jmds, symmetric=TRUE, permutation=9999)) # r=0.57 (protest9 <- protest(MBCdi.jmds, MBCle.jmds, symmetric=TRUE, permutation=9999)) # r=0.53 (protest10 <- protest(MBCdi.jmds, Tree.jmds, symmetric=TRUE, permutation=9999)) # r=0.73 # (protest10ab <- protest(MBCdi.jmds, Tree.ab.jmds, symmetric=TRUE, permutation=9999)) # r=0.70 (protest11 <- protest(MBChe.jmds, MBChy.jmds, symmetric=TRUE, permutation=9999)) # r=0.45 (protest12 <- protest(MBChe.jmds, MBCle.jmds, symmetric=TRUE, permutation=9999)) # r=0.39 (protest13 <- protest(MBChe.jmds, Tree.jmds, symmetric=TRUE, permutation=9999)) # r=0.60 # (protest13ab <- protest(MBChe.jmds, Tree.ab.jmds, symmetric=TRUE, permutation=9999)) # r=0.63 (protest14 <- protest(MBChy.jmds, MBCle.jmds, symmetric=TRUE, permutation=9999)) # r=0.55 (protest15 <- protest(MBChy.jmds, Tree.jmds, symmetric=TRUE, permutation=9999)) # r=0.56 # (protest15ab <- protest(MBChy.jmds, Tree.ab.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest16 <- protest(MBCle.jmds, Tree.jmds, symmetric=TRUE, permutation=9999)) # r=0.65 # (protest16ab <- protest(MBCle.jmds, Tree.ab.jmds, symmetric=TRUE, permutation=9999)) # r=0.68 # adjusting p values for multiple tests pvalues <- c(protest1$signif, protest2$signif, protest3$signif, protest4$signif, protest5$signif, protest6$signif, protest7$signif, protest8$signif, protest9$signif, protest10$signif, protest11$signif, protest12$signif, protest13$signif, protest14$signif, protest15$signif, protest16$signif) p.adjust(pvalues, method='fdr', n=length(pvalues)) # # plot and combine elevation information YGLenv <- read.csv('YGLenv.csv', header=T, row.names=1) # YGL environmental variables data # head(YGLenv) YGLenv <- YGLenv[row.names(MBCin),] # make sure the orders are same summary(YGLenv) YGLenv$col <- 'orange3' # adding colour column, and assigning different color to different elevation categories. orange for <600m for (i in 1:21){ if (YGLenv$Elevation[i]>=600&YGLenv$Elevation[i]<800) {YGLenv$col[i] <- 'turquoise'} # turquoise/blue for [600, 800m) if (YGLenv$Elevation[i]>=800) {YGLenv$col[i] <- 'mediumorchid3'} # mediumorchid3/purple for >= 800m } # individual orders together (Fig. S6) # windows(width=11.69, height=8.27, pointsize=14) par(mfrow=c(2,3), mar=c(4.2,6,3.5,1)) # Coleoptera plot(protest6, kind=0, main='') points(protest6, display = "rotated", col=YGLenv$col, pch=20) # solid circle = Tree points(protest6, display = "target", col=YGLenv$col, pch=1, cex=0.8)# hollow circle = Coleoptera lines(protest6, type = "segments", choices = c(1, 2), col=YGLenv$col) text(x=c(0.35, -0.23), y=0.29, c("r = 0.44", "Coleoptera")) # Diptera par(mar=c(4.2,5.5,3.5,1.5)) plot(protest10, kind=0, main='', ylab='') points(protest10, display = "rotated", col=YGLenv$col, pch=20) # solid circle = Tree points(protest10, display = "target", col=YGLenv$col, pch=1, cex=0.8)# hollow circle = Diptera lines(protest10, type = "segments", choices = c(1, 2), col=YGLenv$col) text(x=c(0.3, -0.28), y=0.33, c("r = 0.73", "Diptera")) # Hemiptera par(mar=c(4.2,5,3.5,2)) plot(protest13, kind=0, main='', ylab='') points(protest13, display = "rotated", col=YGLenv$col, pch=20) # solid circle = Tree points(protest13, display = "target", col=YGLenv$col, pch=1, cex=0.8)# hollow circle = Hemiptera lines(protest13, type = "segments", choices = c(1, 2), col=YGLenv$col) text(x=c(0.23, -0.38), y=0.36, c("r = 0.60", "Hemiptera")) par(mar=c(4.2,6,3.5,1)) # Hymenoptera plot(protest15, kind=0, main='') points(protest15, display = "rotated", col=YGLenv$col, pch=20) # solid circle = Tree points(protest15, display = "target", col=YGLenv$col, pch=1, cex=0.8)# hollow circle = Hymenoptera lines(protest15, type = "segments", choices = c(1, 2), col=YGLenv$col) text(x=c(0.68, -0.05), y=0.44, c("r = 0.56", 'Hymenoptera')) # Lepidoptera par(mar=c(4.2,5.5,3.5,1.5)) plot(protest16, kind=0, main='', ylab='') points(protest16, display = "rotated", col=YGLenv$col, pch=20) # solid circle = Tree points(protest16, display = "target", col=YGLenv$col, pch=1, cex=0.8)# hollow circle = Lepidoptera lines(protest16, type = "segments", choices = c(1, 2), col=YGLenv$col) text(x=c(0.32, -0.22), y=0.3, c("r = 0.65", "Lepidoptera")) par(mfrow=c(1,1)) ``` #### _Mengsong, Yunnan_ There are three habitats in Mengsong, naming mature forest (n=10), regenerating forest (n=12) and open land (n=6). We do the analyses as the following order: 1. all habitats combined 2. forests only (mature forest + regenerating forest) Setting k=4 * stress: + Setting k=2: most stress >0.2 + Setting k=3: most stress <0.2 + Setting k=4: most stress <0.2 * performance: + Setting k=3: the results concerning the comparisons with plants are slightly worse than setting k=4 ##### __1. all habitats combined__ ```{r beta_Mengsong_all} # # wet season MBCin1.jmds <- metaMDS(MBCin1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCin1.jmds <- metaMDS(MBCin1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCin1.jmds) # stress 0.08 MBCcole1.jmds <- metaMDS(MBCcole1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCcole1.jmds <- metaMDS(MBCcole1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCcole1.jmds) # stress 0.12 MBCdi1.jmds <- metaMDS(MBCdi1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCdi1.jmds <- metaMDS(MBCdi1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCdi1.jmds) # stress 0.10 MBChe1.jmds <- metaMDS(MBChe1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChe1.jmds <- metaMDS(MBChe1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChe1.jmds) # stress 0.11 MBChy1.jmds <- metaMDS(MBChy1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChy1.jmds <- metaMDS(MBChy1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChy1.jmds) # stress 0.12 MBCle1.jmds <- metaMDS(MBCle1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCle1.jmds <- metaMDS(MBCle1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCle1.jmds) # stress 0.12 MBCps1.jmds <- metaMDS(MBCps1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCps1.jmds <- metaMDS(MBCps1, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCps1.jmds) # stress 0.11 Plant.jmds <- metaMDS(Plant, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) Plant.jmds <- metaMDS(Plant, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = Plant.jmds) # stress 0.08 # below statistics are presented in Table 1b (wet) (protest1.1 <- protest(MBCin1.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.78 (protest2.1 <- protest(MBCcole1.jmds, MBCdi1.jmds, symmetric=TRUE, permutation=9999)) # r=0.60 (protest3.1 <- protest(MBCcole1.jmds, MBChe1.jmds, symmetric=TRUE, permutation=9999)) # r=0.58 (protest4.1 <- protest(MBCcole1.jmds, MBChy1.jmds, symmetric=TRUE, permutation=9999)) # r=0.55 (protest5.1 <- protest(MBCcole1.jmds, MBCle1.jmds, symmetric=TRUE, permutation=9999)) # r=0.43 (protest6.1 <- protest(MBCcole1.jmds, MBCps1.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest7.1 <- protest(MBCcole1.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.53 (protest8.1 <- protest(MBCdi1.jmds, MBChe1.jmds, symmetric=TRUE, permutation=9999)) # r=0.67 (protest9.1 <- protest(MBCdi1.jmds, MBChy1.jmds, symmetric=TRUE, permutation=9999)) # r=0.71 (protest10.1 <- protest(MBCdi1.jmds, MBCle1.jmds, symmetric=TRUE, permutation=9999)) # r=0.63 (protest11.1 <- protest(MBCdi1.jmds, MBCps1.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest12.1 <- protest(MBCdi1.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.71 (protest13.1 <- protest(MBChe1.jmds, MBChy1.jmds, symmetric=TRUE, permutation=9999)) # r=0.58 (protest14.1 <- protest(MBChe1.jmds, MBCle1.jmds, symmetric=TRUE, permutation=9999)) # r=0.44 (protest15.1 <- protest(MBChe1.jmds, MBCps1.jmds, symmetric=TRUE, permutation=9999)) # r=0.50 (protest16.1 <- protest(MBChe1.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.70 (protest17.1 <- protest(MBChy1.jmds, MBCle1.jmds, symmetric=TRUE, permutation=9999)) # r=0.50 (protest18.1 <- protest(MBChy1.jmds, MBCps1.jmds, symmetric=TRUE, permutation=9999)) # r=0.57 (protest19.1 <- protest(MBChy1.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.64 (protest20.1 <- protest(MBCle1.jmds, MBCps1.jmds, symmetric=TRUE, permutation=9999)) # r=0.40 (protest21.1 <- protest(MBCle1.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.46 (protest22.1 <- protest(MBCps1.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.55 # adjusting p values for multiple tests pvalues=c(protest1.1$signif, protest2.1$signif, protest3.1$signif, protest4.1$signif, protest5.1$signif, protest6.1$signif, protest7.1$signif, protest8.1$signif, protest9.1$signif, protest10.1$signif, protest11.1$signif, protest12.1$signif, protest13.1$signif, protest14.1$signif, protest15.1$signif, protest16.1$signif, protest17.1$signif, protest18.1$signif, protest19.1$signif, protest20.1$signif, protest21.1$signif, protest22.1$signif) p.adjust(pvalues, method='fdr', n=length(pvalues)) # # dry season MBCin2.jmds <- metaMDS(MBCin2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCin2.jmds <- metaMDS(MBCin2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCin2.jmds) # stress 0.08 MBCcole2.jmds <- metaMDS(MBCcole2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCcole2.jmds <- metaMDS(MBCcole2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCcole2.jmds) # stress 0.11 MBCdi2.jmds <- metaMDS(MBCdi2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCdi2.jmds <- metaMDS(MBCdi2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCdi2.jmds) # stress 0.10 MBChe2.jmds <- metaMDS(MBChe2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChe2.jmds <- metaMDS(MBChe2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChe2.jmds) # stress 0.11 MBChy2.jmds <- metaMDS(MBChy2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChy2.jmds <- metaMDS(MBChy2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChy2.jmds) # stress 0.12 MBCle2.jmds <- metaMDS(MBCle2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCle2.jmds <- metaMDS(MBCle2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCle2.jmds) # stress 0.13 MBCps2.jmds <- metaMDS(MBCps2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCps2.jmds <- metaMDS(MBCps2, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCps2.jmds) # stress 0.12 # below statistics are presented in Table 1b (dry) (protest1.2 <- protest(MBCin2.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.75 (protest2.2 <- protest(MBCcole2.jmds, MBCdi2.jmds, symmetric=TRUE, permutation=9999)) # r=0.75 (protest3.2 <- protest(MBCcole2.jmds, MBChe2.jmds, symmetric=TRUE, permutation=9999)) # r=0.70 (protest4.2 <- protest(MBCcole2.jmds, MBChy2.jmds, symmetric=TRUE, permutation=9999)) # r=0.63 (protest5.2 <- protest(MBCcole2.jmds, MBCle2.jmds, symmetric=TRUE, permutation=9999)) # r=0.51 (protest6.2 <- protest(MBCcole2.jmds, MBCps2.jmds, symmetric=TRUE, permutation=9999)) # r=0.60 (protest7.2 <- protest(MBCcole2.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.63 (protest8.2 <- protest(MBCdi2.jmds, MBChe2.jmds, symmetric=TRUE, permutation=9999)) # r=0.78 (protest9.2 <- protest(MBCdi2.jmds, MBChy2.jmds, symmetric=TRUE, permutation=9999)) # r=0.61 (protest10.2 <- protest(MBCdi2.jmds, MBCle2.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest11.2 <- protest(MBCdi2.jmds, MBCps2.jmds, symmetric=TRUE, permutation=9999)) # r=0.50 (protest12.2 <- protest(MBCdi2.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.65 (protest13.2 <- protest(MBChe2.jmds, MBChy2.jmds, symmetric=TRUE, permutation=9999)) # r=0.61 (protest14.2 <- protest(MBChe2.jmds, MBCle2.jmds, symmetric=TRUE, permutation=9999)) # r=0.44 (protest15.2 <- protest(MBChe2.jmds, MBCps2.jmds, symmetric=TRUE, permutation=9999)) # r=0.57 (protest16.2 <- protest(MBChe2.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.77 (protest17.2 <- protest(MBChy2.jmds, MBCle2.jmds, symmetric=TRUE, permutation=9999)) # r=0.51 (protest18.2 <- protest(MBChy2.jmds, MBCps2.jmds, symmetric=TRUE, permutation=9999)) # r=0.61 (protest19.2 <- protest(MBChy2.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.72 (protest20.2 <- protest(MBCle2.jmds, MBCps2.jmds, symmetric=TRUE, permutation=9999)) # r=0.47 (protest21.2 <- protest(MBCle2.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.38 (protest22.2 <- protest(MBCps2.jmds, Plant.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 # adjusting p values for multiple tests pvalues=c(protest1.2$signif, protest2.2$signif, protest3.2$signif, protest4.2$signif, protest5.2$signif, protest6.2$signif, protest7.2$signif, protest8.2$signif, protest9.2$signif, protest10.2$signif, protest11.2$signif, protest12.2$signif, protest13.2$signif, protest14.2$signif, protest15.2$signif, protest16.2$signif, protest17.2$signif, protest18.2$signif, protest19.2$signif, protest20.2$signif, protest21.2$signif, protest22.2$signif) p.adjust(pvalues, method='fdr', n=length(pvalues)) ### plot Yinggeling and Mengsong together ### (Fig. 4) # windows(height=3.24, width=11.69, pointsize=14) # Yinggeling par(mfrow=c(1,3), mar=c(4.2,6,3.5,1)) plot(protest1, kind=0, main='', xaxt='n', yaxt='n') axis(1, at=c(-0.3,-0.2,-0.1,0,0.1,0.2,0.3,0.4), label=c(NA,'-0.2',NA,'0',NA,'0.2',NA,'0.4'), tick=T) axis(2, at=c(-0.3,-0.2,-0.1,0,0.1,0.2,0.3,0.4), label=c(NA,'-0.2',NA,'0',NA,'0.2',NA,'0.4'), tick=T) points(protest1, display = "rotated", col=YGLenv$col, pch=20) # solid circle = Tree points(protest1, display = "target", col=YGLenv$col, pch=1, cex=0.8)# hollow circle = Insecta lines(protest1, type = "segments", choices = c(1, 2), col=YGLenv$col) text(x=c(0.335,0.355), y=c(0.23,0.19), c('Yinggeling',"r = 0.76"), cex=0.9) mtext(text='Fig. 4', side=3, at=-0.37, line=1) # Mengsong wet MSenv$col <- 'red' # adding colour column, and assigning different color to different habitat types. red for MF for (i in 1:28){ if (MSenv$HAB[i] == 'OL') {MSenv$col[i] <- 'yellow3'} # yellow for OL if (MSenv$HAB[i] == 'RF') {MSenv$col[i] <- 'green'} # green for MF } par(mar=c(4.2,5.5,3.5,1.5)) plot(protest1.1, kind=0, main='', xaxt='n', yaxt='n', ylab='') axis(1, at=c(-0.3,-0.2,-0.1,0,0.1,0.2,0.3), label=c(NA,'-0.2',NA,'0',NA,'0.2',NA), tick=T) axis(2, at=c(-0.1,0,0.1,0.2), label=c('-0.1','0','0.1','0.2'), tick=T) points(protest1.1, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest1.1, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Insecta lines(protest1.1, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(0.145,0.24), y=c(0.26,0.225), c("Mengsong: wet season","r = 0.78"), cex=0.9) # Mengsong dry par(mar=c(4.2,5,3.5,2)) plot(protest1.2, kind=0, main='', xaxt='n', yaxt='n', ylab='') axis(1, at=c(-0.2,-0.1,0,0.1,0.2), label=c('-0.2','-0.1','0','0.1','0.2'), tick=T) axis(2, at=c(-0.1,0,0.1,0.2), label=c('-0.1','0','0.1','0.2'), tick=T) points(protest1.2, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest1.2, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Insecta lines(protest1.2, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(0.1,0.18), y=c(0.2,0.17), c("Mengsong: dry season","r = 0.75"), cex=0.9) ### plot Mengsong orders together (Fig. S7) # # wet season (Fig. S7a) # windows(width=11.69, height=8.27, pointsize=14) par(mfrow=c(2,3), mar=c(4.2,6,3.5,1)) # Coleoptera plot(protest7.1, kind=0, main='') points(protest7.1, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest7.1, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Coleoptera lines(protest7.1, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.16, 0.14), y=0.19, c("Coleoptera: wet", "r = 0.53")) mtext(text='a', side=3, at=-0.33, line=1, cex=1.5) # Diptera par(mar=c(4.2,5.5,3.5,1.5)) plot(protest12.1, kind=0, main='', ylab='') points(protest12.1, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest12.1, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Diptera lines(protest12.1, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.17, 0.17), y=0.17, c("Diptera: wet", "r = 0.71")) # Hemiptera par(mar=c(4.2,5,3.5,2)) plot(protest16.1, kind=0, main='', ylab='') points(protest16.1, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest16.1, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Hemiptera lines(protest16.1, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.14, 0.15), y=0.21, c("Hemiptera: wet", "r = 0.70")) par(mar=c(4.2,6,3.5,1)) # Hymenoptera plot(protest19.1, kind=0, main='') points(protest19.1, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest19.1, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Hymenoptera lines(protest19.1, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.19, 0.13), y=0.28, c('Hymenoptera: wet', "r = 0.64")) # Lepidoptera par(mar=c(4.2,5.5,3.5,1.5)) plot(protest21.1, kind=0, main='', ylab='') points(protest21.1, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest21.1, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Lepidoptera lines(protest21.1, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.11, 0.21), y=0.21, c("Lepidoptera: wet", "r = 0.46")) # Psocoptera par(mar=c(4.2,5,3.5,2)) plot(protest22.1, kind=0, main='', ylab='') points(protest22.1, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest22.1, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Psocoptera lines(protest22.1, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.15, 0.19), y=0.25, c("Psocoptera: wet", "r = 0.55")) # # dry season (Fig. S7b) # windows(width=11.69, height=8.27, pointsize=14) par(mfrow=c(2,3), mar=c(4.2,6,3.5,1)) # Coleoptera plot(protest7.2, kind=0, main='') points(protest7.2, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest7.2, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Coleoptera lines(protest7.2, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.15, 0.125), y=0.22, c("Coleoptera: dry", "r = 0.63")) mtext(text='b', side=3, at=-0.3, line=1, cex=1.5) # Diptera par(mar=c(4.2,5.5,3.5,1.5)) plot(protest12.2, kind=0, main='', ylab='') points(protest12.2, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest12.2, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Diptera lines(protest12.2, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.12, 0.2), y=0.21, c("Diptera: dry", "r = 0.65")) # Hemiptera par(mar=c(4.2,5,3.5,2)) plot(protest16.2, kind=0, main='', ylab='', margin=NULL) points(protest16.2, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest16.2, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Hemiptera lines(protest16.2, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.135, 0.16), y=0.15, c("Hemiptera: dry", "r = 0.77")) par(mar=c(4.2,6,3.5,1)) # Hymenoptera plot(protest19.2, kind=0, main='') points(protest19.2, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest19.2, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Hymenoptera lines(protest19.2, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.16, 0.13), y=0.23, c('Hymenoptera: dry', "r = 0.72")) # Lepidoptera par(mar=c(4.2,5.5,3.5,1.5)) plot(protest21.2, kind=0, main='', ylab='') points(protest21.2, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest21.2, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Lepidoptera lines(protest21.2, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.15, 0.19), y=0.22, c("Lepidoptera: dry", "r = 0.38")) # Psocoptera par(mar=c(4.2,5,3.5,2)) plot(protest22.2, kind=0, main='', ylab='') points(protest22.2, display = "rotated", col=MSenv$col, pch=20) # solid circle = vascular plant points(protest22.2, display = "target", col=MSenv$col, pch=1, cex=0.8)# hollow circle = Psocoptera lines(protest22.2, type = "segments", choices = c(1, 2), col=MSenv$col) text(x=c(-0.20, 0.145), y=0.28, c("Psocoptera: dry", "r = 0.52")) par(mfrow=c(1,1)) # # procrust analysis between MS1 and MS2 (Table 1b) (protest1 <- protest(MBCin1.jmds, MBCin2.jmds, symmetric=TRUE, permutation=9999)) # r=0.75 (protest2 <- protest(MBCcole1.jmds, MBCcole2.jmds, symmetric=TRUE, permutation=9999)) # r=0.45 (protest3 <- protest(MBCdi1.jmds, MBCdi2.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest4 <- protest(MBChe1.jmds, MBChe2.jmds, symmetric=TRUE, permutation=9999)) # r=0.67 (protest5 <- protest(MBChy1.jmds, MBChy2.jmds, symmetric=TRUE, permutation=9999)) # r=0.68 (protest6 <- protest(MBCle1.jmds, MBCle2.jmds, symmetric=TRUE, permutation=9999)) # r=0.33 (protest7 <- protest(MBCps1.jmds, MBCps2.jmds, symmetric=TRUE, permutation=9999)) # r=0.42 pvalues=c(protest1$signif, protest2$signif, protest3$signif, protest4$signif, protest5$signif, protest6$signif, protest7$signif) p.adjust(pvalues, method='fdr', n=length(pvalues)) ## species overlap rate options(digits=3) sum(colnames(MBCin1)%in%colnames(MBCin2))/dim(MBCin2)[2] # 0.606 sum(colnames(MBCcole1)%in%colnames(MBCcole2))/dim(MBCcole2)[2] # 0.380 sum(colnames(MBCdi1)%in%colnames(MBCdi2))/dim(MBCdi2)[2] # 0.709 sum(colnames(MBChe1)%in%colnames(MBChe2))/dim(MBChe2)[2] # 0.711 sum(colnames(MBChy1)%in%colnames(MBChy2))/dim(MBChy2)[2] # 0.700 sum(colnames(MBCle1)%in%colnames(MBCle2))/dim(MBCle2)[2] # 0.611 sum(colnames(MBCps1)%in%colnames(MBCps2))/dim(MBCps2)[2] # 0.857 options(digits=2) ``` ##### __2. forests only (mature forest + regenerating forest) __ ```{r beta_Mengsong_forest} # # wet season MBCin1f.jmds <- metaMDS(MBCin1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCin1f.jmds <- metaMDS(MBCin1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCin1f.jmds) # stress 0.07 MBCcole1f.jmds <- metaMDS(MBCcole1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCcole1f.jmds <- metaMDS(MBCcole1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCcole1f.jmds) # stress 0.11 MBCdi1f.jmds <- metaMDS(MBCdi1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCdi1f.jmds <- metaMDS(MBCdi1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCdi1f.jmds) # stress 0.08 MBChe1f.jmds <- metaMDS(MBChe1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChe1f.jmds <- metaMDS(MBChe1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChe1f.jmds) # stress 0.11 MBChy1f.jmds <- metaMDS(MBChy1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChy1f.jmds <- metaMDS(MBChy1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChy1f.jmds) # stress 0.10 MBCle1f.jmds <- metaMDS(MBCle1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCle1f.jmds <- metaMDS(MBCle1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCle1f.jmds) # stress 0.10 MBCps1f.jmds <- metaMDS(MBCps1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCps1f.jmds <- metaMDS(MBCps1f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCps1f.jmds) # stress 0.10 Plantf.jmds <- metaMDS(Plantf, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) Plantf.jmds <- metaMDS(Plantf, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = Plantf.jmds) # stress 0.08 # below statistics are presented in Table S1 (protest1.1 <- protest(MBCin1f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.69 (protest2.1 <- protest(MBCcole1f.jmds, MBCdi1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.63 (protest3.1 <- protest(MBCcole1f.jmds, MBChe1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.59 (protest4.1 <- protest(MBCcole1f.jmds, MBChy1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.60 (protest5.1 <- protest(MBCcole1f.jmds, MBCle1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.47 (protest6.1 <- protest(MBCcole1f.jmds, MBCps1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.50 (protest7.1 <- protest(MBCcole1f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest8.1 <- protest(MBCdi1f.jmds, MBChe1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.65 (protest9.1 <- protest(MBCdi1f.jmds, MBChy1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.65 (protest10.1 <- protest(MBCdi1f.jmds, MBCle1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.58 (protest11.1 <- protest(MBCdi1f.jmds, MBCps1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.60 (protest12.1 <- protest(MBCdi1f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.62 (protest13.1 <- protest(MBChe1f.jmds, MBChy1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.58 (protest14.1 <- protest(MBChe1f.jmds, MBCle1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.48 (protest15.1 <- protest(MBChe1f.jmds, MBCps1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest16.1 <- protest(MBChe1f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.60 (protest17.1 <- protest(MBChy1f.jmds, MBCle1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest18.1 <- protest(MBChy1f.jmds, MBCps1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.65 (protest19.1 <- protest(MBChy1f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.58 (protest20.1 <- protest(MBCle1f.jmds, MBCps1f.jmds, symmetric=TRUE, permutation=9999)) # r=0.45 (protest21.1 <- protest(MBCle1f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.48 (protest22.1 <- protest(MBCps1f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 # adjusting p values for multiple tests pvalues=c(protest1.1$signif, protest2.1$signif, protest3.1$signif, protest4.1$signif, protest5.1$signif, protest6.1$signif, protest7.1$signif, protest8.1$signif, protest9.1$signif, protest10.1$signif, protest11.1$signif, protest12.1$signif, protest13.1$signif, protest14.1$signif, protest15.1$signif, protest16.1$signif, protest17.1$signif, protest18.1$signif, protest19.1$signif, protest20.1$signif, protest21.1$signif, protest22.1$signif) p.adjust(pvalues, method='fdr', n=length(pvalues)) # # dry season MBCin2f.jmds <- metaMDS(MBCin2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCin2f.jmds <- metaMDS(MBCin2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCin2f.jmds) # stress 0.07 MBCcole2f.jmds <- metaMDS(MBCcole2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCcole2f.jmds <- metaMDS(MBCcole2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCcole2f.jmds) # stress 0.09 MBCdi2f.jmds <- metaMDS(MBCdi2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCdi2f.jmds <- metaMDS(MBCdi2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCdi2f.jmds) # stress 0.07 MBChe2f.jmds <- metaMDS(MBChe2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChe2f.jmds <- metaMDS(MBChe2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChe2f.jmds) # stress 0.10 MBChy2f.jmds <- metaMDS(MBChy2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBChy2f.jmds <- metaMDS(MBChy2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBChy2f.jmds) # stress 0.10 MBCle2f.jmds <- metaMDS(MBCle2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCle2f.jmds <- metaMDS(MBCle2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCle2f.jmds) # stress 0.10 MBCps2f.jmds <- metaMDS(MBCps2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE) MBCps2f.jmds <- metaMDS(MBCps2f, distance='jaccard', k=4, wascores=FALSE, autotransform=FALSE, noshare=FALSE, previous = MBCps2f.jmds) # stress 0.10 # below statistics are presented in Table S1 (protest1.2 <- protest(MBCin2f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.70 (protest2.2 <- protest(MBCcole2f.jmds, MBCdi2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.76 (protest3.2 <- protest(MBCcole2f.jmds, MBChe2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.72 (protest4.2 <- protest(MBCcole2f.jmds, MBChy2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.71 (protest5.2 <- protest(MBCcole2f.jmds, MBCle2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.56 (protest6.2 <- protest(MBCcole2f.jmds, MBCps2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.67 (protest7.2 <- protest(MBCcole2f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.68 (protest8.2 <- protest(MBCdi2f.jmds, MBChe2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.71 (protest9.2 <- protest(MBCdi2f.jmds, MBChy2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.68 (protest10.2 <- protest(MBCdi2f.jmds, MBCle2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.53 (protest11.2 <- protest(MBCdi2f.jmds, MBCps2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.62 (protest12.2 <- protest(MBCdi2f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.65 (protest13.2 <- protest(MBChe2f.jmds, MBChy2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.54 (protest14.2 <- protest(MBChe2f.jmds, MBCle2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.53 (protest15.2 <- protest(MBChe2f.jmds, MBCps2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.65 (protest16.2 <- protest(MBChe2f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.73 (protest17.2 <- protest(MBChy2f.jmds, MBCle2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.52 (protest18.2 <- protest(MBChy2f.jmds, MBCps2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.60 (protest19.2 <- protest(MBChy2f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.66 (protest20.2 <- protest(MBCle2f.jmds, MBCps2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.50 (protest21.2 <- protest(MBCle2f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.36 (protest22.2 <- protest(MBCps2f.jmds, Plantf.jmds, symmetric=TRUE, permutation=9999)) # r=0.62 # adjusting p values for multiple tests pvalues=c(protest1.2$signif, protest2.2$signif, protest3.2$signif, protest4.2$signif, protest5.2$signif, protest6.2$signif, protest7.2$signif, protest8.2$signif, protest9.2$signif, protest10.2$signif, protest11.2$signif, protest12.2$signif, protest13.2$signif, protest14.2$signif, protest15.2$signif, protest16.2$signif, protest17.2$signif, protest18.2$signif, protest19.2$signif, protest20.2$signif, protest21.2$signif, protest22.2$signif) p.adjust(pvalues, method='fdr', n=length(pvalues)) # # procrust analysis between MS1 and MS2 (Table S1) (protest1 <- protest(MBCin1f.jmds, MBCin2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.68 (protest2 <- protest(MBCcole1f.jmds, MBCcole2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.55 (protest3 <- protest(MBCdi1f.jmds, MBCdi2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.50 (protest4 <- protest(MBChe1f.jmds, MBChe2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.53 (protest5 <- protest(MBChy1f.jmds, MBChy2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.64 (protest6 <- protest(MBCle1f.jmds, MBCle2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.46 (protest7 <- protest(MBCps1f.jmds, MBCps2f.jmds, symmetric=TRUE, permutation=9999)) # r=0.44 pvalues=c(protest1$signif, protest2$signif, protest3$signif, protest4$signif, protest5$signif, protest6$signif, protest7$signif) p.adjust(pvalues, method='fdr', n=length(pvalues)) ## species overlap rate options(digits=3) sum(colnames(MBCin1f)%in%colnames(MBCin2f))/dim(MBCin2f)[2] # 0.559 sum(colnames(MBCcole1f)%in%colnames(MBCcole2f))/dim(MBCcole2f)[2] # 0.349 sum(colnames(MBCdi1f)%in%colnames(MBCdi2f))/dim(MBCdi2f)[2] # 0.648 sum(colnames(MBChe1f)%in%colnames(MBChe2f))/dim(MBChe2f)[2] # 0.655 sum(colnames(MBChy1f)%in%colnames(MBChy2f))/dim(MBChy2f)[2] # 0.669 sum(colnames(MBCle1f)%in%colnames(MBCle2f))/dim(MBCle2f)[2] # 0.560 sum(colnames(MBCps1f)%in%colnames(MBCps2f))/dim(MBCps2f)[2] # 0.780 ```