开发者

Linear model with Constraints

开发者 https://www.devze.com 2023-01-18 10:52 出处:网络
I\'m quite new to R and I have a following problem: I have a simple 2-factor linear model: Rate~factor1 + factor2 //factor1 has 8 categorical values, factor2 has 6 categories;

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

I have a simple 2-factor linear model:

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

And want to put const开发者_开发问答raints 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 couldn't figure out how to modify it...


It's described in chapter 6 of MASS (Modern Applied Statistics with S). Use the contrasts arg of lm (take a look at ?contr.sum and ?model.matrix.default for examples).

0

精彩评论

暂无评论...
验证码 换一张
取 消