simulate_ou_model {castor} | R Documentation |

Given a rooted phylogenetic tree and an Ornstein-Uhlenbeck (OU) model for the evolution of a continuous (numeric) trait, simulate random outcomes of the model on all nodes and/or tips of the tree. The function traverses nodes from root to tips and randomly assigns a state to each node or tip based on its parent's previously assigned state and the specified model parameters. The generated states have joint distributions consistent with the OU model. Optionally, multiple independent simulations can be performed using the same model.

simulate_ou_model(tree, stationary_mean, spread, decay_rate, include_tips=TRUE, include_nodes=TRUE, Nsimulations=1, drop_dims=TRUE)

`tree` |
A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge. |

`stationary_mean` |
Numeric. The mean (center) of the stationary distribution of the OU model. |

`spread` |
Numeric. The standard deviation of the stationary distribution of the OU model. |

`decay_rate` |
Numeric. Exponential decay rate (stabilization rate) of the OU model (in units 1/edge_length_units). |

`include_tips` |
Include random states for the tips. If |

`include_nodes` |
Include random states for the nodes. If |

`Nsimulations` |
Number of random independent simulations to perform. For each node and/or tip, there will be |

`drop_dims` |
Logical, specifying whether the returned |

For each simulation, the state of the root is picked randomly from the stationary distribution of the OU model, i.e. from a normal distribution with mean = `stationary_mean`

and standard deviation = `spread`

.

If `tree$edge.length`

is missing, each edge in the tree is assumed to have length 1. The tree may include multi-furcations (i.e. nodes with more than 2 children) as well as mono-furcations (i.e. nodes with only one child). The asymptotic time complexity of this function is O(Nedges*Nsimulations), where Nedges is the number of edges in the tree.

A list with the following elements:

`tip_states` |
Either |

`node_states` |
Either |

Stilianos Louca

`simulate_bm_model`

, `simulate_mk_model`

, `simulate_rou_model`

# generate a random tree tree = generate_random_tree(list(birth_rate_intercept=1),max_tips=10000)$tree # simulate evolution of a continuous trait tip_states = simulate_ou_model(tree, stationary_mean=10, spread=1, decay_rate=0.1)$tip_states # plot histogram of simulated tip states hist(tip_states, breaks=20, xlab="state", main="Trait probability distribution", prob=TRUE)

[Package *castor* version 1.6.8 Index]