I made this linear regression that shows how well estimated animal locations (longitude) predict actual animal locations.

estimate <- c(-1.514276, -1.513683, -1.514253, -1.514207, -1.513557, -1.513634, -1.513870, -1.511210, -1.511552, -1.511772, -1.511580, -1.511802, -1.509500, -1.510037, -1.510214)

actual <- c(-1.514255, -1.514053, -1.514527, -1.514223, -1.513672, -1.513729, -1.513934, -1.511118, -1.511567, -1.511658, -1.511585, -1.511830, -1.509438, -1.509843, -1.510080)

lm_longitude <- lm(actual ~ estimate)

lm(formula = actual ~ estimate)

       Min         1Q     Median         3Q        Max 
-2.630e-04 -3.825e-05  8.945e-06  6.530e-05  1.645e-04 

            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.09325    0.02706   3.445  0.00435 ** 
estimate     1.06167    0.01790  59.325  < 2e-16 ***
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.000112 on 13 degrees of freedom
Multiple R-squared:  0.9963,    Adjusted R-squared:  0.996 
F-statistic:  3519 on 1 and 13 DF,  p-value: < 2.2e-16

As you can see, estimated locations are very good predictors for actual locations. I was initially alarmed at the residuals vs fitted values plot. It appears to shows residuals that are correlated with the fitted values:

df_lm_longitude <- ggplot2::fortify(lm_longitude) 
ggplot(df_lm_longitude, aes(.fitted, .resid)) + geom_point() + stat_smooth()

enter image description here

But change the scale of the y axis, and residuals vs fitted values plot looks perfect:

ggplot(df_lm_longitude, aes(.fitted, .resid)) + geom_point() + stat_smooth() + ylim(-0.01, 0.01)

enter image description here

So one of the assumptions of linear regression is that residuals should not be correlated with fitted values. In the model above, the residuals are correlated with the fitted values at a large scale. But zoom out to a small scale, and residuals are not correlated at all?

What resolution should I be using for y axis in residuals vs fitted values plot?


1 Answer 1


Well correlation is a measure of linear association: given that for every value of x (the fitted values), the value of y (the residuals) is constant; the slope is 0. I.e., there's no correlation.

A significance test of the correlation between the fitted values and the residuals confirms this:

cor.test(fitted(lm_longitude), resid(longitude))

Pearson's product-moment correlation

data:  fitted and residual
t = 0, df = 13, p-value = 1
alternative hypothesis: true correlation is not equal to 0

95 percent confidence interval:
-0.5122628  0.5122628

sample estimates:

So you're pretty justified in using the second interpretation. The fact that a pattern seems to emerge on the order of 10^-4 is likely just noise. The scale you use to present the graph of the fitted values against the residuals is less important: use whatever provides a clear display of the data. Either way, there's still no correlation between the two.

Still worried there's a relation? Let's try a third degree polynomial regression, then where res is a vector of the residuals and ftd a vector of the fitted values:

lm(formula = res ~ ftd + I(ftd^2) + I(ftd^3))

Min         1Q     Median         3Q        Max 
-2.241e-04 -3.768e-05  8.900e-08  3.482e-05  1.738e-04 

              Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.0007511  0.0207611  -0.036    0.972
ftd         -0.0109064  0.0137376  -0.794    0.444
I(ftd^2)     0.0003520  0.0090690   0.039    0.970
I(ftd^3)     0.0047866  0.0060009   0.798    0.442

Residual standard error: 9.891e-05 on 11 degrees of freedom
Multiple R-squared:  0.3314,    Adjusted R-squared:  0.1491 
F-statistic: 1.818 on 3 and 11 DF,  p-value: 0.2022

Turns out, there's no significant relationship between these, even if we assume nonlinearity.

It doesn't matter on what scale you visualize the data: objectively, that changes nothing whatsoever. Regardless of how you look at it, either (1) there's really no relationship between the residuals and fitted values or (2) you don't have nearly enough data to conclusively demonstrate that there is.

  • $\begingroup$ Thanks for reply, but you must have done something wrong because estimate and actual are strongly correlated. Also you haven't really answered the question. $\endgroup$
    – luciano
    Aug 1, 2014 at 17:41
  • 1
    $\begingroup$ Estimate and actual should correlate: they're what are being regressed. This correlation is between the residuals and the fitted values. $\endgroup$
    – ChrisW
    Aug 1, 2014 at 17:42
  • $\begingroup$ Ah right I see what you've done. $\endgroup$
    – luciano
    Aug 1, 2014 at 17:46
  • $\begingroup$ (Sorry, edited my original post to add a bit of clarity. Apologies for the confusion! Does that help to answer your question?) $\endgroup$
    – ChrisW
    Aug 1, 2014 at 17:47
  • 3
    $\begingroup$ That pattern is not noise: it suggests a lack of a linear relationship. There are not enough data to tell us whether that suggestion is correct. $\endgroup$
    – whuber
    Aug 1, 2014 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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