[R] LM intercept

Greg Snow Greg.Snow at imail.org
Tue Oct 14 04:36:50 CEST 2008


One clarification:

If groups is a numeric variable, then dropping the intercept forces it to 0 and therefore fits a line that goes through the origin, but if group is categorical (which seems likely with a name like group), then while it forces the intercept to 0, the dummy variable encoding steals the freed up degree of freedom and fits a full set of variables.  What effect this has depends on what question you are trying to answer.  The degrees of freedom of the 2 models and the predicted values of the 2 models will be identical (so full-reduced tests will result in 0/0 but with a limit of 0 giving a p-value of 1.0).  The coefficients for the intercept model (assuming default treatment contrasts) measure the difference between each level of group and the reference (first) level.  In the no-intercept model, the coefficients measure the mean of each group (cell means model).  The overall F-test in the intercept case tests the null that all group means are equal.  The F test for the non-intercept model tests the null that all the means equal 0 (can be a very different test).

So if you are looking at predicted values, the -1 makes no difference at all, if you are looking at the F test then dropping the intercept can make a major change of what question is being answered.

Hope this helps,

________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Michael Just [mgjust at gmail.com]
Sent: Monday, October 13, 2008 2:59 PM
To: Rolf Turner
Cc: r-help
Subject: Re: [R] LM intercept

Great,
Thanks,
Michael

On Mon, Oct 13, 2008 at 3:56 PM, Rolf Turner <r.turner at auckland.ac.nz>wrote:

>
> On 14/10/2008, at 9:42 AM, Michael Just wrote:
>
>  What is the difference when including or not including the intercept when
>> using lm()?
>>
>> x.noint <- lm(weight ~ group - 1))# omitting intercept
>> x <- lm(weight ~ group))
>>
>> This has nothing to do with forcing the intercept to 0, correct?
>>
>
> On the contrary.  This is *exactly* what it means.
>
>        cheers,
>
>                Rolf Turner
>
> ######################################################################
> Attention:This e-mail message is privileged and confidential. If you are
> not theintended recipient please delete the message and notify the
> sender.Any views or opinions presented are solely those of the author.
>
> This e-mail has been scanned and cleared by MailMarshal
> www.marshalsoftware.com
> ######################################################################
>

        [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list