[R] how fit linear model with fixed slope?
Douglas Bates
bates at stat.wisc.edu
Fri Oct 22 16:24:30 CEST 2010
On Fri, Oct 22, 2010 at 9:13 AM, Czerminski, Ryszard
<Ryszard.Czerminski at astrazeneca.com> wrote:
> I want to fit a linear model with fixed slope e.g. y = x + b
> (instead of general: y = a*x + b)
> Is it possible to do with lm()?
Yes. The simplest way is to fit
lm(y - a*x ~ 1)
which will give you the estimate of b, its standard error, etc.
An alternative is to use an offset argument or an offset() expression
in the model formula
lm(y ~ 1 + offset(a*x))
More information about the R-help
mailing list