Linear Regression with a known fixed intercept in R

You could subtract the explicit intercept from the regressand and then fit the intercept-free model:

> intercept <- 1.0
> fit <- lm(I(x - intercept) ~ 0 + y, lin)
> summary(fit)

The 0 + suppresses the fitting of the intercept by lm.

edit To plot the fit, use

> abline(intercept, coef(fit))

P.S. The variables in your model look the wrong way round: it’s usually y ~ x, not x ~ y (i.e. the regressand should go on the left and the regressor(s) on the right).

Leave a Comment