Fit the species pdfs
.
fit_pdfsp(
climate,
ccs,
bin_width,
shape,
xrange,
use_ccs = TRUE,
climateSpaceWeighting.type = "linear"
)
A vector of climatic values where the species is present.
A ccs
object returned by calib_clim_space
.
The width of the bins used to correct for unbalanced climate state. Use values that split the studied climate gradient in 15-25 classes (e.g. 2°C for temperature variables). Default is 1.
The imposed shape of the species pdfs
. We recommend using
'normal' for temperature variables and 'lognormal' for the
variables that can only take positive values, such as
precipitation or aridity. Default is 'normal' for all.
The climate gradient upon which the pdf
with be defined.
Boolean to indicate if the pdfsp
should be corrected by
the distribution of the modern climate space
A correction factor for the clame space weighting correction to limit the edge effects. Either 'linear' (default), 'sqrt' or 'log'.
The pdf of the species.
# Creating one randomised species
climate_species <- round(stats::rnorm(50, 15, 2), 1)
# Creating one randomised climate space
climate_space <- base::sample(0:300 / 10, 4000, replace = TRUE)
ccs <- calib_clim_space(climate_space, 2)
xrange <- fit_xrange(ccs, "normal", 2)
pdfsp <- fit_pdfsp(climate_species, ccs, 2, "normal", xrange)
plot(xrange, pdfsp, type = "l")
# Testing that the area under the curve is equal to 1.
all.equal(sum(pdfsp * (xrange[2] - xrange[1])), 1)
#> [1] TRUE