1
$\begingroup$

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.

enter image description here

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

enter image description here

$\endgroup$
  • 3
    $\begingroup$ Include an additive constant term in the model rather than forcing the line to pass through zero. $\endgroup$ – whuber Oct 3 '16 at 22:39
3
$\begingroup$

@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))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.