[R] significantly different from one (not zero) using lm

Achim Zeileis Achim.Zeileis at uibk.ac.at
Wed May 1 10:32:08 CEST 2013


On Wed, 1 May 2013, Elaine Kuo wrote:

> Hello,
>
> I am work with a linear regression model:
>
> y=ax+b with the function of lm.
>
> y= observed migration distance of butterflies
>
> x= predicted migration distance of butterflies
>
>
>
> Usually the result will show
>
> if the linear term a is significantly different from zero based on the
> p-value.
>
> Now I would like to test if the linear term is significantly different from
> one.
>
> (because I want to know if the regression line (y=ax+b) is significantly
> from the line with the linear term =1 and the intercept =0)

In addition to the solutions suggested by Paul and Thomas, you could use 
linearHypothesis() from the "car" package. A (non-sensical) example using 
the cars dataset is:

m <- lm(dist ~ speed, data = cars)
linearHypothesis(m, c("(Intercept) = 0", "speed = 1"))

The output is equivalent to the anova() for the offset model that Thomas 
suggested:

m0 <- lm(dist ~ 0 + offset(1 * speed), data = cars)
anova(m0, m)

> Please kindly advise if it is possible
>
> to adjust some default parameters in the function to achieve the goal.
>
> Thank you.
>
>
> Elaine
>
> 	[[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