`我试图获得
的逆矩阵 [,1] [,2] [,3]
[1,] 1 rou 0
[2,] rou 1+rou^2 rou
[3,] 0 rou 1
手动计算的逆矩阵应为
1 rou rou^2
1/(1-rou) rou 1 rou
rou^2 rou 1
以rou = 0.3为例
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
手动计算的逆矩阵是以下矩阵
[,1] [,2] [,3]
[1,] 1.0989011 0.3296703 0.0989011
[2,] 0.3296703 1.0989011 0.3296703
[3,] 0.0989011 0.3296703 1.0989011
在R中使用solve(a)
或ginv(a)
,我得到了
[,1] [,2] [,3]
[1,] 1.0989011 -0.3296703 0.0989011
[2,] -0.3296703 1.0989011 -0.3296703
[3,] 0.0989011 -0.3296703 1.0989011
我想知道为什么会出现负面迹象。以前有人遇到过这个问题吗?如何解决?
提前致谢!
跟进:我检查了%*%求解(a),它是
[,1] [,2] [,3]
[1,] 1.000000e+00 0 0
[2,] -6.938894e-18 1 0
[3,] 0.000000e+00 0 1
跟进2: 我发现我的错误是在计算辅助因子矩阵时忘记添加某些元素的负号