Rank of a matrix in R

余生颓废 提交于 2021-01-16 08:46:52

问题


I want to test the rank of a matrix, is there someone who can recommend a package/function in R for this?


回答1:


You can try the function qr ("qr", because it performs a QR decomposition):

#define a matrix for this example
M <- matrix(data = rnorm(12), ncol = 3)

#run the function qr() 
qr(M)$rank

#Alternative: load the Matrix package...
require(Matrix)

#...and run the function rankMatrix()
rankMatrix(M)[1]



回答2:


http://cran.r-project.org/web/packages/Matrix/Matrix.pdf, page 101

http://cran.r-project.org/web/packages/matrixcalc/matrixcalc.pdf, page 12




回答3:


You can use the Library pracma: Practical Numerical Math (Provides a large number of functions from numerical analysis and linear algebra, numerical optimization, differential equations, time series, plus some well-known special mathematical functions.).

Install it using the below command in the R console: install.packages("pracma", repos="http://R-Forge.R-project.org") You can use the library then : library(pracma) Rank(Your Matrix object)



来源:https://stackoverflow.com/questions/10881392/rank-of-a-matrix-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!