Simulate species occurrence and abundances (counts) along gradients.
An R package to simulate species abundances (counts) along gradients
One of the key ways quantitative ecologists attempt to understand the properties and behaviour of the methods they use or dream up is through the use of simulated data. There are a number of computer programmes for simulating ecological data along gradients, such as Peter Minchin's COMPAS, but none (that I am aware of) that are available for R on CRAN. Dave Robert's coenoflex package for R would be a useful alternative but currently is archived on CRAN because of some problems in the Fortran code underlying the package.
Rather than have to reinvent the wheel each time I wanted to simulate some new data for a paper or to work on a new approach, I decided to start my own R package to contain a range of simulators encapsulating different response models, numbers of gradients, etc.
At the moment, coenocliner is limited in what it can do practically. There is a single response model, the Gaussian response, which is a symmetric model of the parameters; the optimum, tolerance and height of the response curve. Count data can be generated from this model from either a Poisson or negative binomial distribution, using the parameterised Gaussian response as the expectation or mean of the distribution.
Additional response models include:
A further feature of coenocliner that I hope to develop is to
include simulation wrapper functions that replicate the simulation
methods used in research papers. A working example is simJamil
,
which produces simlations from a Gaussian logit response following
the scheme described in Jamil & ter Braak (2013).
I would like to see coenocliner be as inclusive as possible; if you have code to simulate ecological species or community data that is just sitting around, consider adding it to coenocliner. In the meantime, I'm happy just having something tangible for my own use without having to remember the expressions for some of the response models.
Currently coenocliner is licensed under the GPL v2, but I'm happy to reconsider this if you want to contribute code under a more permissive licence.
No binary packages are currently available for coenocliner. If you have the correct development tools you can compile the package yourself after downloading the source code from github. Once I work out how to link git with svn I'll start a project on R-forge which will host binary packages of coenocliner.
If you use Hadley Wickham's devtools package then you can install coenocliner directly from github using functions that devtools provides. To do this, install devtools from CRAN via
install.packages("devtools")
then run
devtools::install_github("gavinsimpson/coenocliner")
Jamil and ter Braak (2013) Generalized linear mixed models can detect unimodal species-environment relationships. PeerJ 1:e95; DOI 10.7717/peerj.95
NegBin()
and ZINB()
incorrectly specified the gamma part of the
distribution. The shape
argument to rgamma()
should have been
1/alpha
where alpha
was used previously.
Also clarified the paramterization of the negative binomial used
by NegBin()
and ZINB
as the NB2 version.
NegBin()
and ZINB()
allow for vector alpha
inputs. #25
R CMD check
in the
development version of R.Jari Oksanen is now listed as a contributor to the package having added several new stochastic distributions.
The object returned by coenocline()
now has S3 class "coenocline"
and inherits from the "matrix"
class.
A print()
method has been added for coenocline()
which displays
some summary information and the first n
lines of the simulated
counts. The print()
method uses a new internal function modelled
on the way dplyr prints data frames.
A stack()
method for coenocline()
was added. This makes it much
easier to reshape the simulated count data into a format suitable for
use with ggplot or lattice graphics, or R's modelling
functions.
An enhanced plot()
method for coenocline()
objects is provided,
which can draw 1-d plots of single gradient simulations.
A persp()
method is now provided which can produced 3-d perspective
plots od simulations with 2 gradients.
Two new stochastic distributions were added by Jari Oksanen
A new extractor function is provided, locations()
, which extracts
the gradient locations at which counts were simulated.
gamma
parameter for the second gradient
was being ignored, and the value of gamma
for the first gradient
was used instead.An R package for coenocline simulation; generating simulated species abundance or occurence data along one or two gradients
First public release of coenocliner on CRAN
Species response can be parameterised using either the classic Gaussian response model or the generalise beta response model
Random count or occurence data can be simulated from species responses using random draws from a Poisson, Negative Binomial, Binomial, Beta-binomial, ZIP, ZINB, or Bernoulli distribution with the parameterised response curve taken as the mean or expectation of the distribution to draw from
The main user-facing function is coenocline()
. See ?coenocliner
and ?coenocline
for further details and examples of usage
A basic overview and introductory tutorial for coenocliner is available.
Run browseVignettes("coenocliner")
in R to access the PDF, R code and
sources.