# Why is it necessary to fix a matrix diagonal and after this calculate the exponential to assess transition probabilities?

I'm learning markov chains in order to compute estimations of transition probabilities, and I found an example of the estimator construction for continuous time markov chains:

http://www.rinfinance.com/agenda/2015/talk/AlexanderMcNeil.pdf

(pages 10 -12)

In its presentation, the author specifies that it's necessary to fix matrix diagonal and replace it by the negative of row sums without considering it's initial value:

    D <- rep(0, dim(Lambda.hat))
Lambda.hat <-rbind(Lambda.hat,D)
diag(Lambda.hat) <- D
rowsums <- apply(Lambda.hat,1,sum)
diag(Lambda.hat) <- -rowsums


After that, he computes estimated transition probabilities:

    P.hat <- expm(Lambda.hat)


The output is consistent because each row adds up to one so it seems it works. Although, I don't understand why it was necessary to make these two steps and would really appreciate any help.

As described at https://en.wikipedia.org/wiki/Continuous-time_Markov_chain#Transient_behaviour , the transition probability matrix is calculated as $e^{t Q}$, where t is the length of time, in units corresponding to the intensity parameter entries in Q. The author in your link performed such calculation with annual intensity rates and t = 1, and therefore the transition probability matrix in his example corresponds to a one year period. The mathematics works out that if the row sums of Q equal zero (as they must), then the row sums of the transition probability matrix equal one, as is the case in the example in the link.