Skip to content
Prev 295923 / 398503 Next

setting parameters equal in lm

Hello,

Your model is equivalent of

y = b1(X1 + X3) + b2X2

(plus error)

So, use I() to add X1 and X3. You don't need to create an extra variable 
X13 <- X1 + X3. See the help page for it. The point on function formula.

?I

linMod2 = lm(Y ~ -1 + I(X1  + X3) + X2, data=data.set)
summary(linMod2)
# The same.
linMod3 = lm(Y ~ 0 + I(X1  + X3) + X2, data=data.set)
summary(linMod3)

With set.seed(1) your common slope is

coef(linMod2)
I(X1 + X3)         X2
  0.4237869  3.3626984

Also, I find it better to put 'library', 'require', etc as the first 
lines of code.

Hope this helps,

Rui Barradas

Em 29-05-2012 04:14, Dustin Fife escreveu: