[R] 12th Root of a Square (Transition) Matrix
Peter Langfelder
peter.langfelder at gmail.com
Fri Nov 4 21:04:26 CET 2011
Is it just me or are you confusing the 12th root of a matrix with
taking the 12th root of each entry? Because your formula involving the
eigenvectors and eigenvalues calculates the 12th root of the matrix,
while
round(nth_root^12,4)
will print out a matrix whose components are powers of 12 of the
nth_root, which is very different. To find the 12th power of a matrix,
you can either search for an appropriate function, or do
res = nth_root;
for (p in 1:11)
res = res %*% nth_root
then compare res to your original matrix M.
Peter
On Fri, Nov 4, 2011 at 3:34 AM, clangkamp <christian.langkamp at gmxpro.de> wrote:
> I have tried this method, but the result is not working, at least not as I
> expect:
> I used the CreditMetrics package transition matrix
> rc <- c("AAA", "AA", "A", "BBB", "BB", "B", "CCC", "D")
> M <- matrix(c(90.81, 8.33, 0.68, 0.06, 0.08, 0.02, 0.01, 0.01,
> 0.70, 90.65, 7.79, 0.64, 0.06, 0.13, 0.02, 0.01,
> 0.09, 2.27, 91.05, 5.52, 0.74, 0.26, 0.01, 0.06,
> 0.02, 0.33, 5.95, 85.93, 5.30, 1.17, 1.12, 0.18,
> 0.03, 0.14, 0.67, 7.73, 80.53, 8.84, 1.00, 1.06,
> 0.01, 0.11, 0.24, 0.43, 6.48, 83.46, 4.07, 5.20,
> 0.21, 0, 0.22, 1.30, 2.38, 11.24, 64.86, 19.79,
> 0, 0, 0, 0, 0, 0, 0, 100
> )/100, 8, 8, dimnames = list(rc, rc), byrow = TRUE)
>
> then followed through with the steps:
>
> nth_root <- X %*% L_star %*% X_inv
>
> But the check (going back 12 to the power again) doesn't yield the original
> matrix. Now some rounding errors can be expected, but I didn't expect a
> perfectly diagonal matrix, when the initial matrix isn't diagonal at all.
>> round(nth_root^12,4)
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
> [1,] 0.9078 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0
> [2,] 0.0000 0.9053 0.0000 0.0000 0.0000 0.0000 0.0000 0
> [3,] 0.0000 0.0000 0.9079 0.0000 0.0000 0.0000 0.0000 0
> [4,] 0.0000 0.0000 0.0000 0.8553 0.0000 0.0000 0.0000 0
> [5,] 0.0000 0.0000 0.0000 0.0000 0.7998 0.0000 0.0000 0
> [6,] 0.0000 0.0000 0.0000 0.0000 0.0000 0.8285 0.0000 0
> [7,] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.6457 0
> [8,] 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1
>
> Any takers
>
>
> -----
> Christian Langkamp
> christian.langkamp-at-gmxpro.de
>
> --
> View this message in context: http://r.789695.n4.nabble.com/12th-Root-of-a-Square-Transition-Matrix-tp2259736p3989618.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Sent from my Linux computer. Way better than iPad :)
More information about the R-help
mailing list