`I am trying to get an inverse matrix of
[,1] [,2] [,3]
[1,] 1 rou 0
[2,] rou 1+rou^2 rou
[3,] 0 rou 1
the inverse matrix calculated by hand should be
1 rou rou^2
1/(1-rou) rou 1 rou
rou^2 rou 1
Take rou=0.3 as an example
a=matrix(c(1,0.3,0,0.3,1.09,0.3,0,0.3,1),nrow=3)
a
[,1] [,2] [,3]
[1,] 1.0 0.30 0.0
[2,] 0.3 1.09 0.3
[3,] 0.0 0.30 1.0
Its inverse matrix calculated by hand is the following matrix
[,1] [,2] [,3]
[1,] 1.0989011 0.3296703 0.0989011
[2,] 0.3296703 1.0989011 0.3296703
[3,] 0.0989011 0.3296703 1.0989011
by using solve(a)
or ginv(a)
in R, I got
[,1] [,2] [,3]
[1,] 1.0989011 -0.3296703 0.0989011
[2,] -0.3296703 1.0989011 -0.3296703
[3,] 0.0989011 -0.3296703 1.0989011
I am wondering why there are negative signs. Had anyone met this problem before? How to fix it?
Thanks in advance!
Follow up: I checked a%*%solve(a) and it is
[,1] [,2] [,3]
[1,] 1.000000e+00 0 0
[2,] -6.938894e-18 1 0
[3,] 0.000000e+00 0 1
Follow up 2: I found my mistake is that I forgot to add the negative signs for some elements when calculating cofactor matrix