[R] qr test?

rkevinburton at charter.net rkevinburton at charter.net
Wed Feb 17 17:49:41 CET 2010


I am testing 'qr' with an admittedly contrived matrix and I am getting different results than I am from another package. The matrix that I am using is:

x <- matrix(seq(.1, by=.1, length.out=12), 4)

So the whole test is:

x <- matrix(seq(.1, by=.1, length.out=12), 4)
qr(x)

And the output from 'R' is:

$qr
           [,1]       [,2]          [,3]
[1,] -0.5477226 -1.2780193 -2.008316e+00
[2,]  0.3651484 -0.3265986 -6.531973e-01
[3,]  0.5477226 -0.3781696 -1.650163e-16
[4,]  0.7302967 -0.9124744  8.078153e-01

$rank
[1] 2

$qraux
[1] 1.182574 1.156135 1.589436

$pivot
[1] 1 2 3

attr(,"class")
[1] "qr"


The differences that I see is in the last value of qraux. I was expecting  1.83205 not 1.589436. Also the last row of the decomposition shows:

[4,]  0.7302967 -0.9124744  8.078153e-01

I was expecting

     0.73030    -0.91247    -0.55470

So again it is the last element of the array. For the linear algebra gurus out there is this to be expected from the contrived matrix? Is there a "better" matrix that I can use to test that will more or less give consistent agreed upon results for a QR decomposition?

Thank you.

Kevin



More information about the R-help mailing list