PCMSim.Rd
Generate trait data on a tree according to a multivariate stochastic model with one or several regimes
PCMSim( tree, model, X0, SE = matrix(0, PCMNumTraits(model), PCMTreeNumTips(tree)), metaI = PCMInfo(X = NULL, tree = tree, model = model, SE = SE, verbose = verbose), verbose = FALSE )
tree | a phylo object specifying a rooted tree. |
---|---|
model | an S3 object specifying the model (see Details). |
X0 | a numeric vector of length k (the number of traits) specifying the trait values at the root of the tree. |
SE | a k x N matrix specifying the standard error for each measurement in
X. Alternatively, a k x k x N cube specifying an upper triangular k x k
factor of the variance covariance matrix for the measurement error
for each node i=1, ..., N.
Default: |
metaI | a named list containing meta-information about the data and the model. |
verbose | a logical indicating if informative messages should be written during execution. |
numeric M x k matrix of values at all nodes of the tree, i.e. root,
internal and tip, where M is the number of nodes: M=dim(tree$edge)[1]+1
,
with indices from 1 to N=length(tree$tip.label) corresponding to tips, N+1
corresponding to the root and bigger than N+1 corresponding to internal nodes.
The function will fail in case that the length of the argument vector X0 differs
from the number of traits specified in metaI$k
. Error message:
"PCMSim:: X0 must be of length ...".
Internally, this function uses the PCMCond
implementation
for the given model class.
N <- 10 L <- 100.0 tr <- ape::stree(N) tr$edge.length <- rep(L, N) for(epoch in seq(1, L, by = 1.0)) { tr <- PCMTreeInsertSingletonsAtEpoch(tr, epoch) } model <- PCMBaseTestObjects$model_MixedGaussian_ab PCMTreeSetPartRegimes(tr, c(`11` = 'a'), setPartition = TRUE) set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion") X <- PCMSim(tr, model, X0 = rep(0, 3))