[R] QR decomposition and rank of a matrix

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jul 1 17:32:40 CEST 2004

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 

Brian D. Ripley,                  ripley at 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

More information about the R-help mailing list