[R] How to specify a fixed intercept for linear model
Michael Bedward
michael.bedward at gmail.com
Sat Dec 4 04:49:01 CET 2010
The offset arg is your friend...
x <- 1:10
y <- 42 + 2*x + rnorm(length(x), 0, 0.5)
# we suspect the intercept might be 42 !
lm( y ~ 0 + x, offset=rep(42, length(x)))
Michael
On 4 December 2010 13:42, cborley87
<christopher.borley at students.plymouth.ac.uk> wrote:
>
> Hi,
>
> Im fitting some simple linear models to data from the olympic running events
> with lm(Logtime~Logdistance), the models contain an intercept and one slope
> parameter.
>
> I have fitted a separate model for each years data and as the intercept
> changes very little between years i am trying to simplify the models so that
> they all have the same intercept (calculated from the mean of the previous
> intercepts).
>
> I have seen a few posts relating to zero intercepts but cannot figure out
> how to set to a specific value to the parameter.
>
> Any help would be greatly appreciated.
>
> Thanks.
>
> Chris.
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-specify-a-fixed-intercept-for-linear-model-tp3072044p3072044.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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