[R] ANCOVA for linear regressions without intercept

Peter Ehlers ehlers at ucalgary.ca
Fri Apr 1 18:04:31 CEST 2011


See inline.

On 2011-03-31 22:22, Yusuke Fukuda wrote:
> Thanks Bert.
>
> I have read "?formula" again and again, and I'm still struggling;
>
>> lm(body_length ~ head_length-1)
>
> This removes intercept from each individual regression (for male, female, unknown).
>
> When they are taken together,
>
>> lm(body_length ~ sex*head_length)
>
> This shows differences in slopes and intercepts between the regressions (but I want to compare the slopes of the regressions WITHOUT intercepts).
>
> If I put
>
>> lm(body_length ~ sex:head_length-1)
>
> This shows slopes for each sex without intercepts, but NOT differences in the slope between the regressions.

You probably want:

  lm(body_length ~ head_length + sex:head_length-1)

or, in short form:

  lm(body_length ~ head_length/sex-1)

You might then compare the model 'without intercepts'
(i.e. with intercepts forced to zero) with a model that
includes intercepts. If the intercepts turn out to
be significantly nonzero, what will you do?

Peter Ehlers

>
> I also tried
>
>> lm(body_length ~ sex*head_length-1)
>> lm(body_length ~ sex*head_length-sex-1)
>
> But none of them worked.
>
> Would anyone be able to help me? All I want to do is to compare the slopes of three linear regressions that go through the origin (0,0) so that I can say if their difference is significant or not.
>
> Thanks for your help.
>
>
>
> ________________________________________
> From: Bert Gunter [mailto:gunter.berton at gene.com]
> Sent: Friday, 1 April 2011 12:56 AM
> To: Yusuke Fukuda
> Cc: r-help at r-project.org
> Subject: Re: [R] ANCOVA for linear regressions without intercept
>
> If you haven't already received an answer, a careful reading of
>
> ?formula
>
> will provide it.
>
> -- Bert
> On Wed, Mar 30, 2011 at 11:42 PM, Yusuke Fukuda<Yusuke.Fukuda at nt.gov.au>  wrote:
>
> Hello R experts
>
> I have two linear regressions for sexes (Male, Female, Unknown). All have a good correlation between body length (response variable) and head length (explanatory variable). I know it is not recommended, but for a good practical reason (the purpose of study is to find a single conversion factor from head length to body length), the regressions need to go through the origin (0 intercept).
>
> Is it possible to do ANCOVA for these regressions without intercepts? When I do
>
> summary(lm(body length ~ sex*head length))
>
> this will include the intercepts as below
>
>
> Coefficients:
>                        Estimate Std. Error t value Pr(>|t|)
> (Intercept)            -6.49697    1.68497  -3.856 0.000118 ***
> sexMale                -9.39340    1.97760  -4.750 2.14e-06 ***
> sexUnknown             -1.33791    2.35453  -0.568 0.569927
> head_length             7.12307    0.05503 129.443<  2e-16 ***
> sexMale:head_length     0.31631    0.06246   5.064 4.37e-07 ***
> sexUnknown:head_length  0.19937    0.07022   2.839 0.004556 **
> ---
>
> Is there any way I can remove the intercepts so that I can simply compare the slopes with no intercept taken into account?
>
> Thanks for help in advance.
>
> Yusuke Fukuda
>
> ______________________________________________
> 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