sim.morpho: Simulate a continuous morphological alignment

View source: R/morpho.R

sim.morphoR Documentation

Simulate a continuous morphological alignment

Description

Simulate a continuous morphological alignment using rTraitCont and later allowing to account for population noise and correlation among characters.

Usage

sim.morpho(tree, n, c = 0, R, ...)

Arguments

tree

Phylo, object with a phylogenetic tree (see rTraitCont).

n

Numeric, number of morphological traits to be simulated.

c

(Optional) numeric, vector with variances for the speccies within a population to add as population noise to the simulated morphological traits (see details).

R

(Optional) matrix, correlation matrix (see details).

...

Further arguments passed to rTraitCont (see details).

Details

The function rTraitCont simulates continuous traits and can take different parameters to adjust the simulation (e.g. the model, the rate drift, etc.). These parameters are the ones the user can pass to the argument ... in sim.morpho. The default values that sim.morpho uses are model = "BM", sigma = 1, ancestor = F, and root.value = 0. For this kind of simulation, sim.morpho allows only ancestor = F, so please do not change this parameter. In the rTraitCont package, the parameter model can be model = BM, model = OU, or a function model = FUN provided by the user. Currently, sim.morpho supports only the first two.

The parameter c contains the population noise, which is used to simulate the noise matrix. Each parameter follows a normal distribution, x ~ N(0,c). If the variances are assumed to be the same for all characters within the species, then the length of c is 1 and equals to the value of this variance. If it differs, then a vector of length n has to be provided specifying the variance for each of the characters.

The simulated noise is later added to the morphological data previously generated, so we obtain the noisy matrix. If a correlation matrix, R, is provided, then it is added to the noisy matrix. See object sim.R for an example of its format and data-raw/sim.R to understand how it can be generated. Note that the correlation matrix needs to be of class "matrix" and symmetric.

Value

M

Matrix with the simulated morphological continuous data accounting for noise and, if provided, for population variance and trait correlation too.

Author(s)

Sandra Alvarez-Carretero and Mario dos Reis

See Also

write.morpho

Examples

# A) Simulation setup: Simulate a morphological alignment
#    with n = 100 continuous characters for a phylogeny
#    defined in object 'tree', with the default parameters in
#    'sim.morpho' to run 'rTraitCont'.
#    Population noise and character correlation are not considered,
#    i.e. c = 0 and R not provided.

     sim.morpho( tree = sim.tree, n = 100 )


# B) Simulation setup: Simulate a morphological alignment
#    with n = 100 continuous characters for a phylogeny
#    defined in object 'tree', but with different parameters
#    than the default ones in 'sim.morpho' to run
#    'rTraitCont'. Population noise and trait correlation are not
#    considered, i.e. c = 0 and R not provided.

     sim.morpho( tree  = sim.tree, n = 100,
                         model = "OU", sigma = 0.2, alpha = 2 )


# C) Simulation setup: Simulate a morphological alignment
#    with n = 100 continuous characters for a phylogeny
#    defined in object 'tree', with the default parameters in
#    'sim.morpho' to run 'rTraitCont'.
#    Population noise is low, c = 0.25, but trait correlation is not
#    considered, i.e. R not provided.

     sim.morpho( tree = sim.tree, n = 100, c = 0.25 )


# D) Simulation setup: Simulate a morphological alignment
#    with n = 100 continuous characters for a phylogeny
#    defined in object 'tree', with the default parameters in
#    'sim.morpho' to run 'rTraitCont'.
#    Population noise is low, c = 0.25, and a correlation
#    matrix to simulate trait correlation (rho = 0.50) is provided.

     sim.morpho( tree = sim.tree, n = 100, c = 0.25, R = sim.R )


dosreislab/mcmc3r documentation built on March 29, 2024, 6:45 p.m.