I want to fit a linear regression line with a specified slope to a data set. I read this thread about doing the same with an explicit intercept.
0+
suppresses the fitting of the intercept; what is the corresponding trick for the slope?
For example, to fit a line with slope 1.5, I tried the following
set.seed(6)
x <- runif(100, -3, 3)
y <- 2 + x + rnorm(100)
model1<-lm(y ~ x)
plot(x,y)
abline(model1,col="red")
abline(coef(model1),1.5,col="dark green")
but second abline function just takes the intercept from model1 and slope 1.5. Whereas I would like the regression line to have slope 1.5, find the best fit to the data points, and then compute intercept from that regression line.