This question already has answers here:
A^k for matrix multiplication in R?

(6个答案)


已关闭8年。




我正在尝试计算以下矩阵的-0.5幂:
S <- matrix(c(0.088150041, 0.001017491 , 0.001017491, 0.084634294),nrow=2)

在Matlab中,结果为(S^(-0.5)):
S^(-0.5)
ans =
 3.3683   -0.0200
-0.0200    3.4376

最佳答案

> library(expm)
> solve(sqrtm(S))
            [,1]        [,2]
[1,]  3.36830328 -0.02004191
[2,] -0.02004191  3.43755429

关于r - 如何在R中计算矩阵的幂,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16172731/

10-10 14:15