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

William Valdar valdar at well.ox.ac.uk
Mon Apr 18 18:06:05 CEST 2005


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.

Many thanks,

William

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dr William Valdar               ++44 (0)1865 287 717
Wellcome Trust Centre           valdar at well.ox.ac.uk
for Human Genetics, Oxford      www.well.ox.ac.uk/~valdar




More information about the R-help mailing list