I'm not a advanced R user. I mainly use it for matrix algebra calculation. I have a large matrix (9400 by 9400; 675.1 MB) which I wuold like to invert. I have tried "solve" function and "chol2inv", and I get "Error in...'a' must be a complex matrix". I have also tried with "ginv" function from MASS package, and I got the error message "Error in svd(X) : infinite or missing values in 'x'". I'm sure my matrix does not have null (all zeros) columns or rows. I have checked using: Remove columns with zero values from a dataframe and I get the same matrix. There are not NA values neither, I have tested using Determine the number of NA values in a column. My matrix is numeric and a square matrix ("is.numeric" and "is.matrix" answer TRUE, "dim" 9400x9400). When using "is.singular.matrix" from matrixcalc package, the error message again is Error in determinant.matrix(x, logarithm = TRUE, ...) : 'a' must be a complex matrix . Thus, I don't know why R can't calculate the inversion. Please, do you have any idea how I could solve my problem? Thanks a lot
我不是高级的R用户。我主要用它来计算矩阵代数。我有一个大矩阵(9400×9400;(675.1 MB)我想倒转。我试过“解”函数和“chol2inv”,我得到了“……”“a”必须是一个复杂的矩阵。我还尝试了“ginv”函数从MASS package中,我得到了错误消息“svd(X)中的错误:‘X’中的无穷大或缺失值”。我确定我的矩阵没有空(所有零)列或行。我已经检查过:从dataframe中删除具有0值的列,然后得到相同的矩阵。没有NA值,我已经测试过使用确定一个列中的NA值的数量。我的矩阵是数值型和方阵(“是”。数字"和"。矩阵“回答正确,”dim“9400x9400)。当使用“is.singular。矩阵“从矩阵的包,错误信息再次是错误的行列式。矩阵(x,对数= TRUE,…):a必须是一个复杂的矩阵。因此,我不知道为什么R不能计算反演。拜托,你知道我怎么解决我的问题吗?非常感谢
1 个解决方案
#1
0
The problem was with the infinites. R transforms 0/0 to infinite, but I didn't think about it because the error message was a bit too vague.
问题在于无限大。R将0/0转换为无穷大,但我没有考虑它,因为错误信息有点太模糊了。
Matrix[is.infinite(Matrix)] <- 0
solves my problem.
矩阵[is.infinite(Matrix)] <- 0解决了我的问题。
#1
0
The problem was with the infinites. R transforms 0/0 to infinite, but I didn't think about it because the error message was a bit too vague.
问题在于无限大。R将0/0转换为无穷大,但我没有考虑它,因为错误信息有点太模糊了。
Matrix[is.infinite(Matrix)] <- 0
solves my problem.
矩阵[is.infinite(Matrix)] <- 0解决了我的问题。