pythonmatrixlinear-algebramarkov-chains

Transition matrices to fractional powers


I have a series of cumulative transition matrices (5y, 10y, ..., 30y), and am trying to get the one year annualised transition matrices defined as 1-Year Matrix ^ T = T-year Matrix So I am solving for the one-year matrix as 1-Year Matrix = (T-Year Matrix)^(1/T).

In Python, I am trying the following two methods:

  1. Using inbuilt fractional_matrix_power function in scipy.linalg.

  2. Use the taylor series expansion as to avoid fractional matrices (i.e. 1 Year Matrix = exp ( ln(T-Year Matrix) / T) = 1 + (ln(T-Year Matrix) / 1)/1! + ... where the logarithms are applied after diagonalisation of the matrix.

Both methods seem to be working well, except the resulting 1y matrices for the 30y cumulative matrices have complex numbers (albeit with very small imaginary components). I was wondering whether anybody has faced the same problem, and if there are workarounds? Or maybe does this imply that the 30y matrix is invalid? Or maybe there is an issue with the methodology?


Solution

  • For anybody else that gets the same problem: I solved this by observing that some of the eigenvalues of the matrix were computed as -0 in Python (which taking the logarithm of leads to complex numbers). So I set values of -0 to 0.