[R] QR Decompositon and qr.qty

Sebastian Bauer Sebastian.Bauer at charite.de
Tue May 15 16:20:00 CEST 2007


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



More information about the R-help mailing list