Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

crestr (version 1.2.1)

fit_pdfsp: Fit the species pdfs.

Description

Fit the species pdfs.

Usage

fit_pdfsp(climate, ccs, bin_width, shape, xrange, use_ccs = TRUE)

Value

The pdf of the species.

Arguments

climate

A vector of climatic values where the species is present.

ccs

A ccs object returned by calib_clim_space.

bin_width

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.

shape

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.

xrange

The climate gradient upon which the pdf with be defined.

use_ccs

Boolean to indicate if the pdfsp should be corrected by the distribution of the modern climate space

Examples

Run this code
# 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)

Run the code above in your browser using DataLab