Simulates a discrete and continuous character following the hOUwie model. The function first evolves a discrete character based on the Q matrix provided. Next, it will evolve a continuous character following the given OU parameters and simulated discrete character. Like the hOUwie model, transitions between discrete states are assumed to take place half-way between nodes.

hOUwie.sim(phy, 
           Q, 
           root.freqs, 
           alpha, 
           sigma.sq, 
           theta0, 
           theta)

Arguments

phy

A phylogenetic tree, in ape “phylo” format.

Q

A transition rate matrix with dimensions nStates by nStates describing rates of change between discrete states.

root.freqs

A vector nStates long with probabilities of the root being in a particular state. For example, for a binary discrete character a root prior of c(1, 0) would fix the root state in state 1.

alpha

A vector nStates long which gives alpha parameter of the OU model. For a BM model set this to be near 0.

sigma.sq

A vector nStates long which gives the evolutionary rate parameter of the OU model.

theta0

A numeric value giving the starting value of the continuous character at the root.

theta

A vector nStates long which gives the phenotypic optima for each regime state.

Details

The simulation protocol follows the hOUwie model where stochastic maps being produced are based on a node-by-node simulation. I.e., we first simulate the node states given the parameters and then branches are paintined based on transitions occuring half-way between the nodes.

Value

data

a dataframe of sp (species), reg (discrete character states), and x (continuous character values).

simmap

the history of the discrete character presented as a stochastic map.

Author

James D. Boyko

Examples

# \donttest{
data(tworegime)
# simulate an OUM model
Q <- matrix(c(-1,1,1,-1), 2, 2)
root.freqs <- c(1, 0)
alpha <- c(2, 2)
sigma.sq <- c(1,1)
theta0 <- 5
theta <- c(5, 10)

simulated_data <- hOUwie.sim(tree, Q, root.freqs, alpha, sigma.sq, theta0, theta)
# }