# Installation of packages if necessary InstallPackages <- function(Packages) { InstallPackage <- function(Package) { if (!Package %in% installed.packages()[, 1]) { install.packages(Package, repos="https://cran.rstudio.com/") } } invisible(sapply(Packages, InstallPackage)) } InstallPackages(c("remotes", "SpatDiv")) # knitr options knitr::opts_chunk$set( cache = TRUE, # Cache chunk results echo = TRUE, # Show R chunks warning = FALSE, # Hide warnings message = FALSE, # Hide warnings fig.align='center', out.width='80%', fig.dim=c(7, 5), # Code chunk format tidy=TRUE, tidy.opts=list(blank=FALSE, width.cutoff=80) ) # Random seed set.seed(97310)
This is a preliminary version of a package designed to measure spatially-explicit diversity.
Install the package for R from Github.
library("remotes") remotes::install_github("EricMarcon/SpatDiv")
Create a random, spatialized community with 100 individuals of 10 species.
library("SpatDiv") rSpCommunity(n=1, size=100, S=3, Spatial="Thomas") -> spCommunity autoplot(spCommunity)
Plot a rank-abundance curve.
autoplot(as.AbdVector(spCommunity))
Compute the Diversity Accumulation Curve for 1 to 50 neighbors for orders 0, 1 and 2, with the theoretical, null-model curve. Plot it for Shannon diversity.
divAccum <- DivAccum(spCommunity, n.seq=1:50, q.seq=0:2, H0="Multinomial", NumberOfSimulations=1000) autoplot(divAccum, q = 1)
Compute and plot the mixing index of any order. Save the local values for future use.
mixing <- Mixing(spCommunity, n.seq=1:50, q.seq=0:2, H0="Multinomial", NumberOfSimulations=1000, Individual=TRUE) autoplot(mixing, q = 1)
The same accumulation curves can be computed by increasing the sample area around each point. The argument \code{r.seq} contains the vector of radii of those circular plots.
divAccum <- DivAccum(spCommunity, r.seq = seq(0, .5, by=.1), q.seq=1, spCorrection = "Extrapolation", H0="Binomial") autoplot(divAccum, q = 1)
The actual accumulation curves of diversity and mixing index can be compared to null models with their confidence intervals. Values of the argument \code{H0} can be:
The multinomial null hypothesis is by far faster to compute than the others because it does not require point pattern simulations.
Map the local diversity accumulation or mixing index, for example the species accumulation in 10 points (9 neighbors and the central point).
par(mar=c(0,0,0,0)) MapPlot(mixing, Order = 0, NeighborHood = 10)
This is Simpson's entropy in neighborhoods of points, closely related to Ripley's K function. It is introduced as $\alpha(r)` by @Shimatani2001.
autoplot(Simpson_rEnvelope(spCommunity, Global = TRUE))
The Simpson_r()
function computes the statistic.
Simpson_rEnvelope()
also computes the confidence interval of the null hypothesis, which is random labeling of the points by default.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.