# [R] QR Decompositon and qr.qty

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue May 15 15:32:41 CEST 2007

```You've missed the complete=TRUE argument (and also crossprod) as in

crossprod(qr.Q(qr(m), TRUE),
matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4))

On Tue, 15 May 2007, Sebastian Bauer wrote:

> Dear R people,
>
> I do not have much knowledge about linear algebra but currently I need
> to understand what the function qr.qty is actually doing. The
> documentation states that it calculates t(Q) %*% y via a previously
> performed QR matrix decomposition.
>
> In order to do that, I tried following basic example:
>
> m<-matrix(c(1,0,0,0,1,0,0,0,1,0,0,1),ncol=3) # 4x3 matrix
> qr.qty(qr(m),matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4))
>
>      [,1] [,2] [,3] [,4]
> [1,]   -1   -2   -1   -2
> [2,]   -4   -5   -1   -2
> [3,]    3    4    1    2
> [4,]   -2   -3   -1   -2
>
> As far as I understood the documentation a call such as
>
> t(qr.Q(qr(m)))%*%matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4)
>
> should produce the same result, but this produces a 3 by 4 rather than a
> four by four matrix as t(qr.Q(qr(m))) has only three rows.
>
>      [,1] [,2] [,3] [,4]
> [1,]   -1   -2   -1   -2
> [2,]   -4   -5   -1   -2
> [3,]    3    4    1    2
>
>
> So the last line is missing. Any hints how R adds the last line would be
> appreciated.
>
> Regards,
> Sebastian
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>

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

```