Re: [R] refitting lm() with same x, different y

From: Prof Brian Ripley <>
Date: Tue 19 Apr 2005 - 02:59:05 EST


As a first shot, use lm with a matrix response. That fits them all at once with one QR-decomposition. No analogue for glm or lmer, though, since for those the iterative fits run do depend on the response.


On Mon, 18 Apr 2005, William Valdar wrote:

> Dear All,
> Is there is a fast way of refitting lm() when the design matrix stays
> constant but the response is different? For example,
> y1 ~ X
> y2 ~ X
> y3 ~ X
> ...etc.
> where y1 is the 1st instance of the response vector. Calling lm() every time
> seems rather wasteful since the QR-decomposition of X needs to be calculated
> only once. It would be nice if qr() was called only once and then the same
> QR-factorization used in all subsequent fits. However, I can't see a way to
> do this easily. Can anybody else?
> Why do I want to do this? I'm fitting ~1000 different X's to a response
> vector (for biologists: 1000 genetic markers to a measured phenotype with
> 2000 cases) and wish to establish global significance thresholds for multiple
> testing. The fits have a complex dependency structure that makes the
> Bonferroni correction inappropriate. So I intend to refit all ~1000 X's with
> a shuffled response many times. However, this runs too slow for my needs.
> Of course, not having to redo QR will only help if QR is a rate limiting step
> in lm(), so if anybody can tell me it's not, then that would be very helpful
> too. I would also like to do this for glm() and lmer() fits. Ideally.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Tue Apr 19 03:10:33 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:15 EST