Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.62.0504191000180.6403@octopus.well.ox.ac.uk>
Date: 2005-04-19T10:00:08Z
From: William Valdar
Subject: refitting lm() with same x, different y
In-Reply-To: <Pine.LNX.4.61.0504181755560.26699@gannet.stats>

> From: Brian Ripley
> 
> 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.

Thanks Brian, that's very helpful. Also thanks to Kevin Wright who 
suggested using lsfit(x,Y) as being faster than lm for a Y matrix.

I've since worked out that I can bypass even more lm machinery by basing 
my permutation test significance thresholds on the RSS from qr.resid().
Since,

     y = QRb + e
   Q'y = Rb + Q'e
   RSS = || Q'y - Rb ||

then I can do

   X.qr <- qr(X)

once, and for every instance of y calculate

   e   <- qr.resid(X.qr, y)
   rss <- e %*% e

recording them in

   rss.for.all.fits[i] <- rss

which gives me an empirical distribution of RSS scores. The degrees of 
freedom in my X matrix are constant throughout (I should have said that 
before), so all RSS's are on a level footing and map trivially to the 
p-value. I can therefore take the RSS at, say, the 5th percentile, turn it 
into a p-value and report that as my 5% threshold.

Thanks again,

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