# How to calibrate lm() predictions when there's a clear linear trend in the errors?

My linear model is showing a clear trend in the errors (red line is what it should be). So my high samples are being underestimated and my low samples are being overestimated. There's a clear linear relationship in the errors.

How can I properly create a function that calibrates each prediction so that it better matches the desired red line? Like so:

• Include an additive constant term in the model rather than forcing the line to pass through zero.
– whuber
Commented Oct 3, 2016 at 22:39

@whuber is correct. I will just expand his answer and give you one demo for details. I will use mtcars data in R. We are using a car's weight to predict the mile per gallon variable.

What you are doing (note, the -1 in formula means do not add intercept to the model):

lm(mpg~wt-1,mtcars)

The way to fix (default settings in R is adding intercept):

lm(mpg~wt,mtcars)

Demo

plot(mtcars$wt,mtcars$mpg)
abline(lm(mpg~wt-1,mtcars))
abline(lm(mpg~wt,mtcars,col=2))