View source: R/bootstrap_traits.R
trait_np_bootstrap | R Documentation |
Function for nonparametric bootstrap resampling to calculate community weighted trait mean and higher moments.
trait_np_bootstrap(filled_traits, nrep = 100, sample_size = 200, raw = FALSE)
filled_traits |
output from the trait_fill function. |
nrep |
number of bootstrap replicates |
sample_size |
bootstrap size |
raw |
logical; argument to extract the raw data of the trait
distributions.
The default is |
The observed traits are re-sampled in proportion to their weights,
e.g. the abundance of a species or the biomass.
Values across all individuals
in a community are resampled sample_size
times to incorporate the full
spectrum of trait variation, generating nrep
trait distributions.
From these distributions the function estimates the mean and the higher
moments including variance, skewness and kurtosis.
#' The output of trait_np_bootstrap()
can be summarized using
trait_summarize_boot_moments()
.
a tibble with columns for each grouping variable of filled_traits
(usually the elements of scale_hierarchy and the traits column),
and the moments mean, variance, skewness, and kurtosis.
library(dplyr)
data(community)
data(trait)
# Filter community data to make example faster
community <- community |>
filter(
PlotID %in% c("A", "B"),
Site == 1
)
filled_traits <- trait_fill(
comm = community,
traits = trait,
scale_hierarchy = c("Site", "PlotID"),
taxon_col = "Taxon", value_col = "Value",
trait_col = "Trait", abundance_col = "Cover"
)
boot_traits <- trait_np_bootstrap(filled_traits,
nrep = 20,
sample_size = 200
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.