假设我有一个非常大的这种形式的相关矩阵:
t1.rep1 = rnorm(n=100,mean=10,sd=)
t2.rep1 = t1.rep1 + rnorm(n=100,mean=3,sd=2)
t3.rep1 = t1.rep1 + rnorm(n=100,mean=2,sd=2)
t1.rep2 = rnorm(n=100,mean=2,sd=1)
t2.rep2 = t1.rep2 + rnorm(n=100,mean=0.5,sd=0.5)
t3.rep2 = t1.rep2 + rnorm(n=100,mean=0.7,sd=0.9)
t1.rep3 = rnorm(n=100,mean=2,sd=1)
t2.rep3 = t1.rep3 + rnorm(n=100,mean=0.5,sd=0.5)
t3.rep3 = t1.rep3 + rnorm(n=100,mean=0.7,sd=0.9)
Sigma = matrix(
c(cov(t1.rep1, t1.rep1), 0, 0, cov(t1.rep1, t2.rep1), 0, 0, cov(t1.rep1, t3.rep1), 0, 0,
0, cov(t1.rep2, t1.rep2), 0, 0, cov(t1.rep2, t2.rep2), 0, 0, cov(t1.rep2, t3.rep2), 0,
0, 0, cov(t1.rep3, t1.rep3), 0, 0, cov(t1.rep3, t2.rep3), 0, 0, cov(t1.rep3, t3.rep3),
cov(t2.rep1, t1.rep1), 0, 0, cov(t2.rep1, t2.rep1), 0, 0, cov(t2.rep1, t3.rep1), 0, 0,
0, cov(t2.rep2, t1.rep2), 0, 0, cov(t2.rep2, t2.rep2), 0, 0, cov(t2.rep2, t3.rep2), 0,
0, 0, cov(t2.rep3, t1.rep3), 0, 0, cov(t2.rep3, t2.rep3), 0, 0, cov(t2.rep3, t3.rep3),
cov(t3.rep1, t1.rep1), 0, 0, cov(t3.rep1, t2.rep1), 0, 0, cov(t3.rep1, t3.rep1), 0, 0,
0, cov(t3.rep2, t1.rep2), 0, 0, cov(t3.rep2, t2.rep2), 0, 0, cov(t3.rep2, t3.rep2), 0,
0, 0, cov(t3.rep3, t1.rep3), 0, 0, cov(t3.rep3, t2.rep3), 0, 0, cov(t3.rep3, t3.rep3)),
nrow = 9, ncol = 9)
我的相关矩阵是西格玛。
我想计算它的逆数,即
Sigma.inv = solve(Sigma)
实际上,我的西格玛要大得多,相反,这需要很长时间。
有没有办法使用矩阵的稀疏性和结构以更快/更有效的方式计算 Sigma 的逆?
我需要迭代计算这个逆向,所以计算逆向的快速方法将大大有助于我的算法速度。
您提供的Sigma
实际上是块对角线:
x = c(1,4,7,2,5,8,3,6,9)
Sigma[x,x]
[,1] [,2] [,3] [,4] [,5] [,6] ...
[1,] 0.9494388 1.130673 0.9825316 0.000000 0.000000 0.000000 ...
[2,] 1.1306727 4.983144 1.2112634 0.000000 0.000000 0.000000 ...
[3,] 0.9825316 1.211263 5.0771423 0.000000 0.000000 0.000000 ...
[4,] 0.0000000 0.000000 0.0000000 1.211892 1.223293 1.328587 ...
[5,] 0.0000000 0.000000 0.0000000 1.223293 1.469146 1.242400 ...
[6,] 0.0000000 0.000000 0.0000000 1.328587 1.242400 2.377406 ...
...
块对角矩阵可以更快地反转。只需将每个块替换为其反向块即可。