[R] linear model coefficients

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jul 28 17:50:39 CEST 2003


On Mon, 28 Jul 2003, Joerg Schaber wrote:

> I wonder if there is a possibility to avoid that R sets one level of a 
> factor equal zero in a model fit.
> 
> More precisely, I want to fit a two-way unbalanced linear model: o ~ 0 + 
> x + y
> x is a factor with 10 levels, y is a factor with 9 levels. In order to 
> get a unique solution
> i set the intercept =0 and impose that sum(y)=0 i.e.
> res <- lm(o ~ 0 + x + y, contrasts=list(y=("contr.sum")))
> 
> However, R keeps returning only 8 coefficients for y. I assume that 
> internally one coefficient is always set to zero. But when I impose 
> "contr.sum", setting one coef to zero is no longer really nessasary, 
> isn't it?

No coefficient is set to 0: only 8 are defined: see the help for contr.sum 
and the exposition in chapter 6 of MASS.

> So my questions is, if there is a way yo avoid that, or am I completely 
> mistaken?

The second.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list