fit_abundances {gambin} | R Documentation |
Fit a unimodal or multimodal gambin model to a species abundance distribution
Description
Uses maximum likelihood methods to fit the GamBin model (with a given number of modes) to binned species abundances. To control for the effect of sample size, the abundances may be subsampled prior to fitting.
Usage
fit_abundances(abundances, subsample = 0, no_of_components = 1, cores = 1)
fitGambin(abundances, subsample = 0)
Arguments
abundances |
Either a vector of abundances of all species in the sample/community; or the result of |
subsample |
The number of individuals to sample from the community before fitting the GamBin model. If subsample == 0 the entire community is used |
no_of_components |
Number of components (i.e. modes) to fit.The default (no_of_components == 1) fits the standard unimodal gambin model. |
cores |
No of cores to use when fitting. Use |
Details
The gambin distribution is fit to the number of species in abundance octaves,
as specified by the create_octaves
function. Because the shape of species abundance
distributions depend on sample size, abundances of different communities should be compared
on equally large samples. The sample size can be set by the subsample
parameter.
To estimate alpha
from a standardised sample, the function must be run several
times; see the examples. The no_of_components
parameter enables multimodal gambin
distributions to be fitted. For example, setting no_of_components
equal to 2, the bimodal
gambin model is fitted. When a multimodal gambin model is fitted (with g modes), the return values are the alpha
parameters of the g different component distributions, the max octave values for the g component distributions
(as the max octave values for the g-1 component distributions are allowed to vary), and the and the weight parameter(s)
which denote the fraction of objects within each g component distribution. When fitting multimodal gambin models
(particularly on large datasets), the optimisation algorithm can be slow. In such cases, the process
can be speeded up by using the cores
parameter to enable parallel computing.
The plot
method creates a barplot showing the observed number of
species in octaves, with the fitted GamBin distribution shown as black dots.
The summary.gambin
method provides additional useful information such
as confidence intervals around the model parameter estimates.
Value
The fit_abundances
function returns an object of class gambin
, with the alpha
,
w
and MaxOctave
parameters of the gambin mixture distribution,
the likelihood of the fit, and the empirical distribution over octaves.
Examples
data(moths)
fit = fit_abundances(moths)
barplot(fit)
lines(fit, col=2)
summary(fit)
# gambin parameters based on a standardized sample size of 1000 individuals
stand_fit <- replicate(20, fit_abundances(moths, 1000)$alpha) #may take a while on slower computers
print(c(mean = mean(stand_fit), sd = sd(stand_fit)))
# a bimodal gambin model
biMod <- fit_abundances(moths, no_of_components = 2)