I want to calculate a linear regression using the lm() function in R. Additionally I want to get the slope of a regression, where I explicitly give the intercept to lm
lm
I have used both offset and I(). I also find offset easier to work with (like BondedDust) since you can set your intercept.
Assuming Intercept is 10.
plot (lin$x, lin$y) fit <-lm(lin$y~0 +lin$x,offset=rep(10,length(lin$x))) abline(fit,col="blue")