-2

`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

Yukun
  • 315
  • 4
  • 15
  • 1
    Have you considered that your math might be off? Have you checked that `a %*% your_inverse` is close to the identity? `a %*% solve(a)` is. – flodel Dec 15 '14 at 23:48
  • R is not Mathematica. Use a different tool if you want symbolic algebra. – IRTFM Dec 16 '14 at 03:01
  • No, you don't wanna invert a matrix. http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/ – Khashaa Dec 16 '14 at 06:10

1 Answers1

5

I think you made a mistake in your hand calculations. This is the correct result:

enter image description here

Click here for an easy way to make these sort of calculations.

elyase
  • 39,479
  • 12
  • 112
  • 119