movement_prob2rate {MGDrivE2} | R Documentation |
Convert Stochastic Matrix to Rate Matrix
Description
Given a stochastic matrix, return the rate matrix (infinitesimal generator) that would generate it when exponentiated over the interval of unit time.
Usage
movement_prob2rate(tau)
Arguments
tau |
a row normalized stochastic matrix |
Details
Warning: if the matrix provided has diagonal-only rows (i.e., the location is independent), the rate matrix will return 0 in that row, as there is no movement rate that can generate that scenario.
Value
a list with two elements: gamma
negative diagonal of the rate
matrix, mat
matrix of row normalized off-diagonal elements
Examples
# generate random matrix for example
# This represents a 3-node landscape, with random movement between nodes
moveMat <- matrix(data = runif(n = 9), nrow = 3, ncol = 3)
moveMat <- moveMat/rowSums(moveMat)
moveRate <- movement_prob2rate(tau = moveMat)
[Package MGDrivE2 version 2.1.0 Index]