transition.matrix: Makes a transition matrix

View source: R/utilities.R

transition.matrixR Documentation

Makes a transition matrix

Description

Utility function for generating discrete characters evolution transition matrices.

Usage

transition.matrix(type, states, rates = runif, self = TRUE, ...)

Arguments

type

the type of transition matrix, either "equal rates", "stepwise", "symmetric", or "all rates different". See details.

states

the number of states.

rates

either a fixed value for a rate to attribute to each possible transitions or a function to generate the rates (default is runif). See details.

self

logical, whether to allow reverting states (i.e. transition rates from state A to the same state A; TRUE; default) or not (FALSE).

...

if rates is a function, any optional arguments to be passed to it.

Details

The following transition rate matrices are currently implemented:

  • "equal rates" (or "ER") where all transitions are equal (including no transition if self = TRUE).

  • "stepwise" (or "Dollo") transitions are allowed only in a step wise way (e.g. state 1 to 2 and 2 to 3 are allowed but not 1 to 3).

  • "symmetric" ("SYM") where transitions between states are all different but not directional (e.g. the change of state 1 to 2 is equal to 2 to 1). If self = TRUE, the non transitions (e.g. from state 1 to 1) are equal.

  • "all rates different" (or "ARD") where all transitions are different. Note that if rates is a give value (rather than a function), then all rates are actually equal.

If rates is a function that generates negative values or a negative value, the output transition matrix always returns absolute values.

Value

Returns a squared "matrix".

Author(s)

Thomas Guillerme

See Also

make.traits discrete.process

Examples

## A two states equal rates matrix with a rate of 1
## and no stationary rates (no probability of staying in the same state)
transition.matrix(type = "equal rates", states = 2, rates = 1, self = FALSE)

## Two different 6 states stepwise matrix with a random absolute normal rate
transition.matrix(type = "stepwise", states = 6, rates = rnorm)
transition.matrix(type = "stepwise", states = 6, rates = rnorm)



treats documentation built on June 8, 2025, 1:43 p.m.