From ripley at stats.ox.ac.uk  Sat May  5 10:09:55 2007
From: ripley at stats.ox.ac.uk (ripley at stats.ox.ac.uk)
Date: Sat,  5 May 2007 10:09:55 +0200 (CEST)
Subject: [Rd] Bug in qr.R ? (PR#9655)
Message-ID: <20070505080955.ED82E6264F@slim.kubism.ku.dk>

And the purported bug is what: you failed to say!  This looks most like a 
misreading on your part of the documentation.

The help page says:

complete: logical expression of length 1.  Indicates whether an
           arbitrary  orthogonal completion of the *Q* or *X* matrices
           is to be made, or whether the *R* matrix is to be completed
           by binding zero-value rows beneath the square upper triangle.

You only need to complete R for n < p, as in:

> A <- matrix(1:12, 4)
>
>  qr.R(qr(A),complete=TRUE)
           [,1]       [,2]          [,3]
[1,] -5.477226 -12.780193 -2.008316e+01
[2,]  0.000000  -3.265986 -6.531973e+00
[3,]  0.000000   0.000000  2.641083e-15
[4,]  0.000000   0.000000  0.000000e+00
>  qr.R(qr(A),complete=FALSE)
           [,1]       [,2]          [,3]
[1,] -5.477226 -12.780193 -2.008316e+01
[2,]  0.000000  -3.265986 -6.531973e+00
[3,]  0.000000   0.000000  2.641083e-15


On Fri, 4 May 2007, Dietrich.Trenkler at uni-osnabrueck.de wrote:

> Ladies and Gentlemen,
>
> using
>
> > A <- structure(c(1, 0, 0, 3, 2, 1, 4, 5, -3, -2, 1, 0), .Dim =
> as.integer(c(3,4)))
>
> I get
>
> > dim(A)
> [1] 3 4
>
> >  qr.R(qr(A),complete=TRUE)
>     [,1]      [,2]      [,3]       [,4]
> [1,]   -1 -3.000000 -4.000000  2.0000000
> [2,]    0 -2.236068 -3.130495 -0.8944272
> [3,]    0  0.000000 -4.919350 -0.4472136
> >  qr.R(qr(A),complete=FALSE)
>     [,1]      [,2]      [,3]       [,4]
> [1,]   -1 -3.000000 -4.000000  2.0000000
> [2,]    0 -2.236068 -3.130495 -0.8944272
> [3,]    0  0.000000 -4.919350 -0.4472136
>
> In ?qr.R I find
>
> /qr.R returns R. The number of rows of R is nrow(X) or ncol(X),
> depending on whether complete is TRUE or FALSE./
>
> As you can see, the number of rows stays the same...

But it says it is one of the two values, and that which depends on 
'complete' (but not that different values of 'complete' necessarily give 
different answers, just that they might).  You may have read this as if it 
said 'respectively', but it does not.

[...]

-- 
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



[Rd] Bug in qr.R ? (PR#9655)
ripley at stats.ox.ac.uk