[R] how fit linear model with fixed slope?

Dimitris Rizopoulos d.rizopoulos at erasmusmc.nl
Fri Oct 22 16:19:45 CEST 2010


yes, you can use an offset, e.g.,

x <- runif(100, -3, 3)
y <- 2 + x + rnorm(100)

lm(y ~ x)
lm(y ~ offset(x))


I hope it helps.

Best,
Dimitris


On 10/22/2010 4:13 PM, Czerminski, Ryszard 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()?
>
> Regards,
> Ryszard
>
>
> --------------------------------------------------------------------------
> Confidentiality Notice: This message is private and may ...{{dropped:11}}
>
> ______________________________________________
> 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.
>

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/



More information about the R-help mailing list