Given a stochastic matrix, return the rate matrix (infinitesimal generator) that would generate it when exponentiated over the interval of unit time.
Value
a list with two elements: gamma
negative diagonal of the rate
matrix, mat
matrix of row normalized off-diagonal elements
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.
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)
#> Error in movement_prob2rate(tau = moveMat): 'tau' has some rows that do not sum to 1, please normalize