Matrix rank in R

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

+13
source share
4 answers

You can try the qr function ("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] 
+22
source

rankMatrix () in Matrix package - rankMatrix ()

0
source

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

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

-1
source

Source: https://habr.com/ru/post/1415951/


All Articles