add_bias_to_traits: add_bias_to_traits

View source: R/add_bias_to_traits.R

add_bias_to_traitsR Documentation

add_bias_to_traits

Description

Add small amount of bias to traits to avoid taxa having the same traits.

Usage

add_bias_to_traits(x, fuzzy = TRUE, col_blocks = NULL, SD = 0.001)

Arguments

x

Result of average_traits() or a data.frame with a similar structure.

fuzzy

Are you working with fuzzy traits? Default to TRUE.

col_blocks

A vector that contains the number of modalities for each trait.

SD

The amount of bias.

Details

This function works by adding a small amount of bias to traits. The bias is added with the stats::rnorm() function. Fuzzy data are prepared with the function ade4::prep.fuzzy() of the ade4 package. This function works with positive numeric traits.

Examples


data(macro_ex)
data_bio <- as_biomonitor(macro_ex)
data_agr <- aggregate_taxa(data_bio)
data_ts <- assign_traits(data_agr)
data_ts_av <- average_traits(data_ts)

data_ts_av[1:5, 1:5]

# set col_blocks
col_blocks <- c(8, 7, 3, 9, 4, 3, 6, 2, 5, 3, 9, 8, 8, 5, 7, 5, 4, 4, 2, 3, 8)

add_bias_to_traits(data_ts_av, fuzzy = TRUE, col_blocks = col_blocks)[1:5, 1:5]
add_bias_to_traits(data_ts_av, fuzzy = TRUE, col_blocks = col_blocks, SD = 0.01)[1:5, 1:5]

alexology/biomonitoR documentation built on Oct. 10, 2024, 12:02 a.m.