| expm | R Documentation |
Compute the the matrix exponential expm(A) by scaling and squaring.
expm(A, tol = 1e-08)
A |
Square matrix. |
tol |
level of accuracy required (default = 1e-8). |
This function follows the scaling and squaring algorithm from Sherlock (2021), except that we compute the full
matrix exponential. It differs from the standard Taylor scaling and squaring algorithm reviewed by Ruiz et al (2016) and found in common texts,
by doing uniformization if the matrix is a generator matrix from a continuous time Markov chain. If using the matrix exponential to create a
transition probability matrix in a HMM context just once, this function may be efficient. If dimension is large, we recommend avoiding the
matrix exponential and using expAv instead. Note that for computation efficiency, when the columns are non-positive, matrix uniformization
is done by A* = A + rho I, where rho = max(abs(diag(A))). When the row sums of the matrix are not zero, then uniformization is not done,
and the number of iterations to reach tolerance are approximated based on the a bound of the spectrum, similar to RTMB (Kristensen, 2025).
a matrix that is ans = exp(A).
Paul van Dam-Bates
Sherlock, C. (2021). Direct statistical inference for finite Markov jump processes via the matrix exponential. Computational Statistics, 36(4), 2863-2887.
Ruiz, P., Sastre, J., Ibáñez, J., & Defez, E. (2016). High performance computing of the matrix exponential. Journal of computational and applied mathematics, 291, 370-379.
Kristensen K (2025). _RTMB: 'R' Bindings for 'TMB'_. R package version 1.7, commit 6bd7a16403ccb4d3fc13ff7526827540bf27b352, <https://github.com/kaskr/RTMB>.
A <- rbind(c(-1, 0.25, 0.75), c(0, -2, 2), c(0.25, 0.25, -0.5))
Lambda <- diag(c(0.25, 0.1, 0))
expm((A-Lambda)*2.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.