I’m quite new to R and I have a following problem:

I have a simple 2-factor linear model:

`# factor1 has 8 categorical values, factor2 has 6 categories Rate ~ factor1 + factor2 model1 <- lm(Rate~factor1+factor2, data=myData)`

And want to put constraints SUM of factor1 coefficients = 0, the same for factor2.

None of the manuals gives any clue how to do this.

I found a link to similar problem here but it is different and I couldnt figure out how to modify it…

**Answer**

You can do this using contrasts:

```
options(contrasts=c('contr.sum', 'contr.sum'))
```

See `?contr.sum`

for more information.

UPDATE: A little googling reveals a page which might be a little clearer:

- Samuel E. Buttrey, Setting and Keeping Contrasts

**Attribution***Source : Link , Question Author : Vytautas , Answer Author : whuber*