[R] Linear Regression with slope equals 0

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Aug 14 13:58:08 CEST 2007


On Tue, 14 Aug 2007, E.N.D.Grew at exeter.ac.uk wrote:

>
> Hi there, am trying to run a linear regression with a slope of 0.
>
> I have a dataset as follows
>
> t d
> 1 303
> 2 302
> 3 304
> 4 306
> 5 307
> 6 303
>
> I would like to test the significance that these points would lie on a
> horizontal straight line.
>
> The standard regression lm(d~t) doesn't seem to allow the slope to be set.

lm(d ~ 1) does, though, to zero.

More generally you can use offset(), e.g. lm(d ~ offset(7*t)) forces a 
slope of 7.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list