0

I have a Hessian Matrix in R which is symmetric but when I take the inverse is not symmetric. Is there a reason why is that?

> H
            Y2:x0       Y2:x1       Y2:x2      Y3:x0      Y3:x1      Y3:x2
Y2:x0  80.7330275 138.3925827  30.7587900 -2.0733863 -0.6488755  0.5873648
Y2:x1 138.3925827 322.0118582 123.6994074 -0.6488755 -0.3966589  0.1935496
Y2:x2  30.7587900 123.6994074  80.2100552  0.5873648  0.1935496 -0.1668824
Y3:x0  -2.0733863  -0.6488755   0.5873648 16.3776543  3.8121818 -4.5735735
Y3:x1  -0.6488755  -0.3966589   0.1935496  3.8121818  1.5476827 -1.0977709
Y3:x2   0.5873648   0.1935496  -0.1668824 -4.5735735 -1.0977709  1.2788706
> is.symmetric.matrix(H)
[1] TRUE
> is.symmetric.matrix(solve(H))
[1] FALSE

I am using the library(matrixcalc) and I couldn't find why the this possible.

JesZ
  • 25
  • 4
  • 3
    It's a rounding issue with the `solve` function (heck, `H == solve(solve(H))` is probably not even true), but the inverse of a symmetric matrix is symmetric (if the inverse exists). – mickey Jan 24 '19 at 17:40
  • If you need more, dput() your matrix... – Christoph Jan 24 '19 at 17:52
  • 1
    And you should always try to avoid inverting a matrix. – Roland Jan 24 '19 at 17:55
  • If you wanted to enforce the matrix to be numerically symmetric, then copy the lower triangle to the upper triangle as in [this question](https://stackoverflow.com/questions/26166569/copy-upper-triangle-to-lower-triangle-for-several-matrices-in-a-list) – mickey Jan 24 '19 at 17:58
  • I would try `chol2inv(chol(H))`. – Stéphane Laurent Jan 31 '19 at 11:55

0 Answers0