[R] linear model with interaction / segments
markus.gesmann at web.de
Sat Aug 29 13:56:18 CEST 2009
Suppose I have the following data:
plot(y~x, df, t="b")
How can I fit a model which estimates the slopes between x = 1-5, 5-6,
Adding the factor f:
df$f <- gl(2,5)
Allows me to fit a linear model with interaction
lm(y ~ x:f, data=df)
which gives me the slope of 1 and 2 between 1-5, and 6-10
respectively, however it can not cope with the change from 5 to 6.
I would appreciate if someone could point me into the right direction.
More information about the R-help