# Re: [R] QR decomposition and rank of a matrix

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 02 Jul 2004 - 01:32:40 EST

It depends on what you set as tol, of course. The point is that if you get that warning

1. the calculations in the R code would be unreliable
2. the residuals are really of low rank, and it would be statistical nonsense to use their SSq in ANOVA calculation.

Yes, we could make it work in those cases but it is much better to solve the problem at source and transform the response variables.

On Thu, 1 Jul 2004, Alex Nu wrote:

>
> In summary.manova the qr decomposition of a NxN
> matrix
> is calculated and for some cases is giving me
> a rank < N.
>
> However, following suggestions of professor Ripley to
>
> calculate the rank of a Matrix
>
> On 7 Jun 2002, Brian Ripley wrote:
> > For a more reliable answer, look at the SVD
> > (function svd) and look at the
> > singular values. For example (from lda.default)
>
> X.s <- svd(X, nu = 0)
> rank <- sum(X.s\$d > tol * X.s\$d[1])
>
> I'm getting rrank = N,
>
> I wonder wether use this new method for
> calculating the rank inside the manova.R

It's not a `new method' but as old as the hills (and older than most statistics).

```--
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help