get_random_mk_transition_matrix {castor}R Documentation

Create a random transition matrix for an Mk model.

Description

Create a random transition matrix for a fixed-rates continuous-time Markov model of discrete trait evolution ("Mk model"). This may be useful for testing purposes.

Usage

get_random_mk_transition_matrix(Nstates, rate_model, min_rate=0, max_rate=1)

Arguments

Nstates

The number of distinct states represented in the transition matrix (number of rows & columns).

rate_model

Rate model that the transition matrix must satisfy. Can be "ER" (all rates equal), "SYM" (transition rate i–>j is equal to transition rate j–>i), "ARD" (all rates can be different) or "SUEDE" (only stepwise transitions i–>i+1 and i–>i-1 allowed, all 'up' transitions are equal, all 'down' transitions are equal).

min_rate

A non-negative number, specifying the minimum rate in off-diagonal entries of the transition matrix.

max_rate

A non-negative number, specifying the maximum rate in off-diagonal entries of the transition matrix. Must not be smaller than min_rate.

Value

A real-valued quadratic matrix of size Nstates x Nstates, representing a transition matrix for an Mk model. Each row will sum to 0. The [r,c]-th entry represents the transition rate r–>c. The number of unique off-diagonal rates will depend on the rate_model chosen.

Author(s)

Stilianos Louca

See Also

exponentiate_matrix, get_stationary_distribution

Examples

# generate a 5x5 Markov transition rate matrix
Q = get_random_mk_transition_matrix(Nstates=5, rate_model="ARD")

[Package castor version 1.7.0 Index]