(1) Run e.g.
R <- qr.R(cbind(1,x1,x2,,...,y))
(2) Let Rsubm be a submatrix of R consisting of the first m rows
and columns of R, and let zsubm be the vector of the first m
elements of the final column of R. Then solve Rsubm b = y
to get the vector b of coefficients.
Watch out for the effects of pivoting, though. It appears from
the documentation that qr.R() undoes any pivoting (see qr), but
I've not checked this.
There are in addition ways to use lm(y~x1+x2+.., qr=T)$qr,
and then qr.coef
Basically you chop off as many trailing columns of the qr
representation as you do not want, before you call
qr.coef(qr,y)
With this approach, it is not obvious how you handle pivoting,
whereby the decomposition may be given for a version of X
in which columns are permuted.
John Maindonald email : john.maindonald@anu.edu.au
Statistical Consulting Unit, phone : (6249)3998
c/o CMA, SMS, fax : (6249)5549
John Dedman Mathematical Sciences Building
Australian National University
Canberra ACT 0200
Australia
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news