Simulate multivariate Ornstein-Uhlenbeck evolutionary sequence data sets
Source:R/sim.multi.OU.R
sim.multi.OU.Rd
Function to simulate a multivariate Ornstein-Uhlenbeck evolutionary sequence data set.
Arguments
- ns
number of samples in time-series
- anc
the ancestral trait values
- optima
the optimal trait values
- A
the pull matrix.
- R
the drift matrix
- vp
within-population trait variance
- nn
vector of the number of individuals in each sample (identical sample sizes for all time-series is assumed)
- tt
vector of sample ages, increases from oldest to youngest
Note
The Ornstein Uhlenbeck model is reduced to an Unbiased Random Walk when the alpha parameter is zero. It is therefore possible to let a trait evolve as an Unbiased Random Walk by setting the diagonal element for that trait to a value close to zero (e.g. 1e-07). Elements in the diagonal of A cannot be exactly zero as this will result in a singular variance-covariance matrix.
Examples
##Define the A and R matrices
A_matrix<-matrix(c(4,-2,0,3), nrow=2, byrow = TRUE)
R_matrix<-matrix(c(4,0.2,0.2,4), nrow=2, byrow = TRUE)
## Generate an evoTS object by simulating a multivariate dataset
data_set<-sim.multi.OU(40, optima = c(1.5,2),A=A_matrix , R = R_matrix)
## plot the data
plotevoTS.multivariate(data_set)