[R] How to fit an linear model withou intercept

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Aug 23 13:21:27 CEST 2007


On 23-Aug-07 09:56:33, Michal Kneifl wrote:
> Please could anyone help me?
> How can I fit a linear model where an intercept has no sense?
> Thanks in advance..
> 
> Michael

Presumably you mean "where a non-zero intercept has no sense"?

Suppose the model you want to fit is like

  Response ~ B+C+X+Y

Then

[A]
  lm(Response ~ B+C+X+Y)

will give you an intecept. But:

[B]
  lm(Response ~ B+C+X+Y - 1 )

will in effect force a zero intercept -- it removes the "Intercept"
term (which is implicit in the form [A]) from the model, thus in
effect giving it coefficient zero.

In "real life", the model at [A] corresponds to the equation

  Response = a*1 + b*B + c*C + x*X + y*Y + error

where a,b,c,x,y are the coefficients, so the "terms in the model"
are 1 , B , C , X , Y.

The model at [B] corresponds to

  Response = b*B + c*C + x*X + y*Y + error

so the "terms in the model" are B , C , X , Y -- i.e. the same
as before but with the term "1" removed, which is what is effected
by adding the term "-1" to the model formula.

Hoping this helps,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Aug-07                                       Time: 12:21:24
------------------------------ XFMail ------------------------------



More information about the R-help mailing list