[R] R versus SAS: lm performance

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue May 11 15:13:51 CEST 2004


Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:

> > Hmm. Shouldn't be all that much faster, but it will produce the Type I
> > SS as you go along, whereas R probably wants to fit the 15 different
> > models. 
> 
> Nope, R can read off the Type I SSQs from the QR decomposition so only one 
> fit is done.  (Effectively you remove the effect of one column at a time, 
> and you get the change in residual/regression SSq as a side effect. Take 
> a look at anova.lm, which just aggregates squared effects over terms.)

OK, thanks.
 
> > I'm still surprised that R/S-PLUS manages to use a full 15 minutes on
> > a single response variable. It might be due to the singularities --
> > the SAS code indicated that there was a nesting issue with the "A"
> > factor in the last 4-factor interaction. If so, a reformulation of the
> > model might help. 
> 
> I think we need to understand this better.  My guess (but only a guess) is 
> that the model matrix has very many columns and is highly singular.  If 
> the singularity is by design, a reformulation will help.

It's certainly not a completely balanced factorial: 

1344=2*2*2*2*2*2*3*7

so it could be one in several way, but not with a main effects with 4 DF. 

An even less well-founded guess is that it might help to replace the
last term with interaction(Ar,Ba,Ti,Pr,drop=TRUE) (if I remembered the
names correctly). 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list