how do I check the rank of a matrix ? say A= 1 0 0 0 1 0 then rank(A)=2 what is this function? thanks I did try help.search("rank"), but all the returned help information seem irrelevant to what I want. I would like to know how people search for help information like this. rank(base) Sample Ranks SignRank(stats) Distribution of the Wilcoxon Signed Rank Statistic Wilcoxon(stats) Distribution of the Wilcoxon Rank Sum Statistic friedman.test(stats) Friedman Rank Sum Test kruskal.test(stats) Kruskal-Wallis Rank Sum Test pairwise.wilcox.test(stats) Pairwise Wilcoxon rank sum tests wilcox.test(stats) Wilcoxon Rank Sum and Signed Rank Tests
Have you considered something like the following: matrix.rank <- function(A, eps=sqrt(.Machine$double.eps)){ sv. <- abs(svd(A)$d) sum((sv./max(sv.))>eps) } matrix.rank(A=diag(3)) #[1] 3 A <- array(c(1,1,0,0), dim=c(2,2)) matrix.rank(A) #[1] 1 mingan wrote:> > > how do I check the rank of a matrix ? > > say > > A= 1 0 0 > 0 1 0 > > then rank(A)=2 > > what is this function? > > thanks > > > I did try help.search("rank"), but all the returned help information > seem irrelevant to what I want. > > I would like to know how people search for help information like this. > > > > > > > rank(base) Sample Ranks > SignRank(stats) Distribution of the Wilcoxon Signed Rank > Statistic > Wilcoxon(stats) Distribution of the Wilcoxon Rank Sum > Statistic > friedman.test(stats) Friedman Rank Sum Test > kruskal.test(stats) Kruskal-Wallis Rank Sum Test > pairwise.wilcox.test(stats) > Pairwise Wilcoxon rank sum tests > wilcox.test(stats) Wilcoxon Rank Sum and Signed Rank Tests > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
mingan wrote:> > > how do I check the rank of a matrix ? > > say > > A= 1 0 0 > 0 1 0 > > then rank(A)=2 > > what is this function?Well, calculating the rank is from the computational point of view a very hard problem. See ?qr Uwe Ligges> thanks > > > I did try help.search("rank"), but all the returned help information > seem irrelevant to what I want. > > I would like to know how people search for help information like this. > > > > > > > rank(base) Sample Ranks > SignRank(stats) Distribution of the Wilcoxon Signed Rank > Statistic > Wilcoxon(stats) Distribution of the Wilcoxon Rank Sum > Statistic > friedman.test(stats) Friedman Rank Sum Test > kruskal.test(stats) Kruskal-Wallis Rank Sum Test > pairwise.wilcox.test(stats) > Pairwise Wilcoxon rank sum tests > wilcox.test(stats) Wilcoxon Rank Sum and Signed Rank Tests > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
mingan wrote on 5/4/2005 8:54 AM:> > > how do I check the rank of a matrix ? > > say > > A= 1 0 0 > 0 1 0 > > then rank(A)=2 > > what is this function? > > thanks > > > I did try help.search("rank"), but all the returned help information > seem irrelevant to what I want. > > I would like to know how people search for help information like this. > > > > > > > rank(base) Sample Ranks > SignRank(stats) Distribution of the Wilcoxon Signed Rank > Statistic > Wilcoxon(stats) Distribution of the Wilcoxon Rank Sum > Statistic > friedman.test(stats) Friedman Rank Sum Test > kruskal.test(stats) Kruskal-Wallis Rank Sum Test > pairwise.wilcox.test(stats) > Pairwise Wilcoxon rank sum tests > wilcox.test(stats) Wilcoxon Rank Sum and Signed Rank Tests > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlSee ?qr or ?svd. tol <- 1e-7 qr(A, tol)$rank sum(svd(A)$d > tol) --sundar
qr() returns an estimate of the rank. However the rank of a matrix isn't really computable (or useful) in general in finite precision arithmetic. The Hilbert matrix example (from help(svd)) is a good illustration:> hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") } > qr(hilbert(9))$rank[1] 7 but it's actually an invertible 9 x 9 matrix. Rather you can estimate how far a matrix is from having rank <= k for example. A book on numerical linear algebra would be a good reference. A common approach to statistical analysis of certain kinds of data deals with the ranks of the data values, and that's why you got so many hits for "rank". Reid Huntsinger -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of mingan Sent: Wednesday, May 04, 2005 11:54 AM To: r-help at stat.math.ethz.ch Subject: [R] rank of a matrix how do I check the rank of a matrix ? say A= 1 0 0 0 1 0 then rank(A)=2 what is this function? thanks I did try help.search("rank"), but all the returned help information seem irrelevant to what I want. I would like to know how people search for help information like this. rank(base) Sample Ranks SignRank(stats) Distribution of the Wilcoxon Signed Rank Statistic Wilcoxon(stats) Distribution of the Wilcoxon Rank Sum Statistic friedman.test(stats) Friedman Rank Sum Test kruskal.test(stats) Kruskal-Wallis Rank Sum Test pairwise.wilcox.test(stats) Pairwise Wilcoxon rank sum tests wilcox.test(stats) Wilcoxon Rank Sum and Signed Rank Tests ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html