coalesc_abc {ecolottery} | R Documentation |
Estimation of neutral and non-neutral parameters of community assembly using Approximate Bayesian Computation (ABC)
Description
Estimates parameters of neutral migration-drift dynamics (through migration
rate m and parameters of environmental filtering (through a filtering function
filt.abc()
) from the composition of a local community and the related
regional pool.
Usage
coalesc_abc(comm.obs, pool = NULL, multi = "single", traits = NULL,
f.sumstats, filt.abc = NULL, params = NULL,
theta.max = NULL, nb.samp = 10^6, parallel = TRUE,
tol = NULL, pkg = NULL, method="rejection")
do.simul(J, pool = NULL, multi = "single", nb.com = NULL,
traits = NULL, f.sumstats = NULL, filt.abc = NULL,
params, theta.max = NULL, nb.samp = 10^6,
parallel = TRUE, tol = NULL, pkg = NULL,
method = "rejection")
Arguments
comm.obs |
the observed community composition. If |
pool |
composition of the regional pool to which the local community is hypothesized to be related through migration dynamics with possible environmental filtering. Should be a matrix of individuals on rows with their individual id (first column), species id (second column), and (optionally) the trait values of the individuals. |
multi |
structure of the community inputs:
|
traits |
the trait values of species in the regional pool. It is used if trait
information is not provided in |
f.sumstats |
a function allowing to calculate the summary statistics of local community composition. Will be used to compare observed and simulated community composition in the ABC estimation. It should take a community as input and output a list of summary statistics. |
filt.abc |
the hypothesized environmental filtering function. It is a function of individual trait values and additional parameters to be estimated. |
params |
a matrix of the bounds of the parameters used in |
theta.max |
if |
nb.samp |
the number of parameter values to be sampled in ABC calculation. Random
values of parameters of environmental filtering (see |
parallel |
boolean. If |
tol |
the tolerance value used in ABC estimation (see help in
|
pkg |
packages needed for calculation of |
method |
the method to be used in ABC estimation (see help on
|
J |
local community size. |
nb.com |
number of communities. |
Details
coalesc_abc()
performs ABC estimation for one (if multi = FALSE
,
default) or several communities (if multi = TRUE
) related to the same
regional pool.
do.simul()
provides the simulated communities used in ABC estimation,
and is not intended to be used directly.
Value
par |
parameter values used in simulations. |
obs |
observed summary statistics. |
obs.scaled |
observed summary statistics standardized according to the mean and standard deviation of simulated values. |
ss |
standardized summary statistics of the communities simulated with parameter
values listed in |
abc |
a single (if |
Author(s)
F. Munoz
References
Jabot, F., and J. Chave. 2009. Inferring the parameters of the neutral theory of biodiversity using phylogenetic information and implications for tropical forests. Ecology Letters 12:239-248.
Csillery, K., M. G. B. Blum, O. E. Gaggiotti, and O. Francois. 2010. Approximate Bayesian computation (ABC) in practice. Trends in Ecology & Evolution 25:410-418.
Csillery, K., O. Francois, and M. G. Blum. 2012. abc: an R package for Approximate Bayesian Computation (ABC). Methods in Ecology and Evolution 3:475-479.
See Also
abc()
in abc
package,
parLapply()
in parallel
package.
Examples
# Trait-dependent filtering function
filt_gaussian <- function(t, params) exp(-(t-params[1])^2/(2*params[2]^2))
# Definition of parameters and their range
params <- data.frame(rbind(c(0, 1), c(0.05, 1)))
row.names(params) <- c("topt", "sigmaopt")
# Number of values to sample in prior distributions
nb.samp <- 10^6 # Should be large
## Not run:
# Basic summary statistics
f.sumstats <- function(com) array(dimnames=list(c("cwm", "cwv", "cws",
"cwk", "S", "Es")),
c(mean(com[,3]), var(com[,3]),
e1071::skewness(com[,3]),
e1071::kurtosis(com[,3]),
vegan::specnumber(table(com[,2])),
vegan::diversity(table(com[,2]))))
# An observed community is here simulated (known parameters)
comm <- coalesc(J = 400, m = 0.5, theta = 50,
filt = function(x) filt_gaussian(x, c(0.2, 0.1)))
# ABC estimation of the parameters based on observed community composition
## Warning: this function may take a while
res <- coalesc_abc(comm$com, comm$pool, f.sumstats = f.sumstats,
filt.abc = filt_gaussian, params = params,
nb.samp = nb.samp, parallel = TRUE,
pkg = c("e1071","vegan"), method = "neuralnet")
plot(res$abc, param = res$par)
hist(res$abc)
# Cross validation
## Warning: this function is slow
res$cv <- abc::cv4abc(param = res$par, sumstat = res$ss, nval = 1000,
tols = c(0.01, 0.1, 1), method = "neuralnet")
plot(res$cv)
# Multiple community option
# When the input is a site-species matrix, use argument multi="tab"
# See vignette Barro_Colorado for more details
# When the input is a list of communities, use argument multi="seqcom"
comm.obs <- list()
comm.obs[[1]] <- cbind(rep(1,400), coalesc(J = 400, m = 0.5, filt = function(x)
filt_gaussian(x, c(0.2, 0.1)),
pool = comm$pool)$com))
comm.obs[[2]] <- cbind(rep(2,400), coalesc(J = 400, m = 0.5, filt = function(x)
filt_gaussian(x, c(0.5, 0.1)),
pool = comm$pool)$com))
comm.obs[[3]] <- cbind(rep(3,400), coalesc(J = 400, m = 0.5, filt = function(x)
filt_gaussian(x, c(0.8, 0.1)),
pool = comm$pool)$com))
comm.obs <- lapply(comm.obs, as.matrix)
res <- coalesc_abc(comm.obs, comm$pool, multi="seqcom", f.sumstats=f.sumstats,
filt.abc = filt_gaussian, params = params, nb.samp = nb.samp,
parallel = TRUE, pkg = c("e1071","vegan"), tol = 0.1,
method = "neuralnet")
lapply(res$abc, summary)
## End(Not run)