sim_jive: Simulate JIVE process

Description Usage Arguments Details Value Author(s) Examples

View source: R/sim_jive.R

Description

Generate random values of trait mean and variance simulated under a JIVE process along a phylogenetic tree

Usage

1
2
3
4
sim_jive(phy, map = NULL, models = list(mean = c("BM"), logvar =
  c("OU")), pars = list(mean = c(root = 0, sigma_sq = 0.1), logvar =
  c(root = 2, theta = 1, sigma_sq = 0.1, alpha = 1)), sampling = c(1, 7),
  bounds = list(c(-Inf, Inf), c(-Inf, Inf)), var.f = NULL)

Arguments

phy

Phylogenetic tree

map

list containing the mapping of regimes over each edge (see details)

models

list giving model specification for the simulation of trait evolution. Supported models are c("OU", "BM", "WN"). The user can also specify if the assumptions of the model should be relaxed (see details)

pars

list giving parameters used for the simulation of trait evolution (see details). Name of parameters must be explecitly entered (see details)

sampling

vector of size 2 giving the min and max number of individual per species

bounds

list giving traits bounds

var.f

alternative function to model intraspecific variation of the form: function(n, pars) with n, number of individuals and pars, parameters of the model

Details

map : the list must be ordered in the same order than phy$edge. Each element represents an edge and contains a vector indicating the time spent under each regime in the branch. The name of the regimes must appear on the map models : trait evolution can be simulated using Ornstein-Uhlenbeck (OU), Brownian Motion (BM) or White Noise (WN) processes. Multiple regimes can be defined for both models and will apply on thetas: c("OU", "theta"), sigmas: c("OU", "sigma") or alphas: c("OU", "alpha") for OU and on sigmas only for WN: c("WN", "sigma") and BM: c("BM", "sigma"). While using the OU model, the user can also relax the stationarity of the root: c("OU", "root") and relax several assumptions at the same time c("OU", "root", "theta") pars : list containing parameters depending on the chosen model. Elements of that lists must be vectors of size 1 or n, with n = number of regimes in the map. Each element of pars must be named with the corresponding parameter abbreviation. Parameters used in the different models:

White Noise model (WN):

Brownian Motion model (BM):

Ornstein Uhlenbeck model (OU):

Value

A list of length two containing a numeric matrix named "evo_traits" giving simulated traits representing intraspecific variation and a data.frame called "obs" containing species name in the fisrt column and individual observation of the trait in the second.

Author(s)

Theo Gaboriau

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library(phytools)
phy <- pbtree(n = 50)
Q <- cbind(c(-.002, .002), c(.002, -.002))
phy <- sim.history(phy, Q = Q)
# MBM and VOU
jive_phy <- sim_jive(phy = phy, map = phy$maps)

# MWN + sigma and VOU + theta + root + alpha
jive_phy <- sim_jive(phy = phy, map = phy$maps, 
   models = list(mean= c("WN", "sigma"), logvar = c("OU")),
   pars = list(mean = c(root = 0, sigma_sq1 = 0.1, sigma_sq2 = 0.5), 
              logvar = c(root = 10, theta1 = 5, theta2 = 10,
                         sigma_sq = 0.1, alpha1 = 0.2, alpha2 = 0.8))
 )


# With a different model of intraspecific variation:
unif.f <- function(n, pars){
 runif(n, pars[1] - exp(pars[2])/2, pars[1] + exp(pars[2])/2)
}

unif_phy <- sim_jive(phy = phy, map = phy$maps, models = list(mid=c("BM"), logrange=c("OU")),
 pars = list(mid = c(root = 0, sigma_sq = 0.1),
             logrange = c(root = 2, theta = 1, sigma_sq = 0.1, alpha = 1)),
 var.f = unif.f)

bite documentation built on April 22, 2020, 5:09 p.m.

Related to sim_jive in bite...