[R] Contr.sum and coefficient tests

Ben Bolker bbolker at gmail.com
Thu Jul 23 22:59:04 CEST 2015


François Collin <stxfc <at> nottingham.ac.uk> writes:

> 
> Dear all,
 
> I would like to run a linear model which includes two factors:

> - The first one has two levels, including a reference level. Thus I
> have to use the treatment contrast (contr.treatment, reference level
> effect = 0, then the intercept).

> - The second is a 6-level factor without reference contrast nor
> order. So, I would like to use sum contrat: sum of the effects = 0.

> The problem arises when it comes to the coefficient test. I
> understand it is not relevant to test the reference level for the
> first factor as the reference level is set to 0. However, using sum
> contrast for the second factor, I would have expected the test of
> each level to be included in the classical summary print of the lm
> function result but it is not. And here is my problem, how can I
> have every coefficients tested and printed in the summary output
> when my factor is studied from this sum.contrast standpoint?

  [some context snipped to make gmane happy -- sorry ]

  I think you should look at the effects package or the lsmeans
package (or possibly the multcomp package, if you want to be careful
about the number of (non-orthogonal) tests) -- the issue is that
summary.lm always reports on the *parameters* estimated.  If some
parameters are not independently estimable (e.g. the effect corresponding
to the last level can be reconstructed from the parameter values
for all of the preceding levels), then summary.lm() won't give
them to you.

  In fact, these packages will (probably) give you the results you
want even if the original model uses default treatment contrasts.


More information about the R-help mailing list