Skip to contents

Generates species trait data under models that deviate from Brownian Motion. Supports OU (stabilising selection), regime shifts (clade-specific optima), and non-linear inter-trait correlations.

Usage

simulate_non_bm(
  tree,
  n_traits = 4,
  scenario = c("OU", "regime_shift", "nonlinear"),
  alpha = 2,
  theta = 0,
  sigma = 1,
  shift_magnitude = 2,
  seed = NULL
)

Arguments

tree

Object of class "phylo".

n_traits

Integer. Number of traits to simulate (default 4).

scenario

Character. One of "OU", "regime_shift", "nonlinear".

alpha

Numeric. OU pull strength (only for "OU").

theta

Numeric. OU optimum (only for "OU").

sigma

Numeric. BM diffusion rate.

shift_magnitude

Numeric. Regime shift size in SD units (only for "regime_shift").

seed

Integer seed or NULL.

Value

A data.frame with species as rownames.

Examples

tree <- ape::rtree(12)
traits <- simulate_non_bm(tree, n_traits = 2, scenario = "OU", seed = 1)
head(traits)
#>          trait1     trait2
#> t1  0.063568591 -0.1886190
#> t5  0.686826050  0.4826924
#> t8  0.050014474  0.3327469
#> t4 -0.815511105  0.3108378
#> t3  0.008772048 -0.0809873
#> t7  0.197771618  1.0230077