Hmm, looks like I'm 'answering' my own question here...
library(Matrix)
data(KNex)
mm <- KNex$mm
str(mmQR <- qr(mm))
# new stuff:
R <- mmQR@R
Rdiag <- diag(R)
rank <- sum(Rdiag > max(dim(mm))*.Machine$double.eps*abs(R[1,1])) #
this is the matlab default I think?
# 712
for comparison, rankMatrix f
Dear list,
Can anyone tell me how to obtain the rank of a sparse Matrix, for
example from package Matrix (class dgCMatrix)? Here is an example of
QR decomposition of a sparse matrix (from the sparseQR class help).
library(Matrix)
data(KNex)
mm <- KNex$mm
str(mmQR <- qr(mm))
Similarly, using the
> "AR" == Alex Roy
> on Tue, 4 Aug 2009 09:56:42 +0200 writes:
AR> Dear all, Rank of a matrix depends on which factors?
AR> Only on rows or coumns? or both ? If there is a
AR> collinearlity in the variables ( columns ) does it
AR> effects the rank?
This has nothing
Dear all,
Rank of a matrix depends on which factors? Only on rows or
coumns? or both ? If there is a collinearlity in the variables ( columns )
does it effects the rank?
> X<-matrix((rnorm(1)),50)
> dim(X)
[1] 50 200
> qr(X)$rank
[1] 50
> X[,2]<-X[,30]
> qr(X)$rank
[1] 50
> X[
4 matches
Mail list logo