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
#> t3   0.13365531  0.0799620
#> t5  -0.12663440 -0.4001733
#> t4   0.23489123  0.4053132
#> t6  -0.90657646  0.3271975
#> t12 -0.04863159 -0.1110146
#> t10  0.38184567  1.0706760