trait_np_bootstrap: Bootstrap traits

View source: R/bootstrap_traits.R

trait_np_bootstrapR Documentation

Bootstrap traits

Description

Function for nonparametric bootstrap resampling to calculate community weighted trait mean and higher moments.

Usage

trait_np_bootstrap(filled_traits, nrep = 100, sample_size = 200, raw = FALSE)

Arguments

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 raw = FALSE. If raw = TRUE, nrep is restricted to 1 to avoid memory issues.

Details

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().

Value

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.

Examples

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
)

richardjtelford/traitstrap documentation built on July 3, 2024, 1:46 a.m.