Metric to quantify how randomly dispersed the points are around the horizontal axis in a residual plot Residual plots can be used to assess whether a linear regression model is appropriate for the data {1-2}: if the points in a residual plot are randomly dispersed around the horizontal axis, a linear regression model is appropriate for the data; otherwise, a non-linear model is more appropriate. Is there any standard metric to quantify how randomly dispersed the points are around the horizontal axis in a residual plot?

Examples of residual plots:
The first plot shows a random pattern, indicating a good fit for a linear model:

The patterns  in the following plot  are non-random (U-shaped), suggesting a better fit for a non-linear model.


References:


*

*{1} http://stattrek.com/statistics/dictionary.aspx?definition=Residual%20plot 

*{2} http://blog.minitab.com/blog/adventures-in-statistics/why-you-need-to-check-your-residual-plots-for-regression-analysis
 A: The whole reason for plotting residuals is so as to use your eye rather than to rely on a numerical metric. There many different ways in which residuals can fail to be random. Metrics can only be written for particular different types of failure, whereas your eye and your marvelous pattern recognizing brain can respond to anything unexpected.
If you are fitting a simple linear regression and your only aim is to check whether a nonlinear relationship would be better, then you can try a non-parametric curve. In R, the code might go like this:
    fit.linear <- lm(y~x)
    library(splines)
    NS <- ns(x,df=3)
    fit.nonlinear <- lm(y~NS)
    anova(fit.linear, fit.nonlinear)

The above code fits a cubic regression spline with (in effect) 3 parameters and then uses an anova to test whether the nonlinear curve is a significant improvement over the linear. The ns function constructs a matrix of natural basis vectors for the regression spline.
Alternatively you could fit a polynomial trend, but splines tend to be more flexible and stable.
Here's an example run. The metric here is the p-value, which is 6.5e-9.
    > x <- 1:40
    > y <- rnorm(40)+((x-20)/10)^2
    > plot(x,y)
    > fit.linear <- lm(y~x)
    > library(splines) # import ns() function
    > NS <- ns(x,df=3)
    > fit.nonlinear <- lm(y~NS)
    > anova(fit.linear, fit.nonlinear)
    Analysis of Variance Table

    Model 1: y ~ x
    Model 2: y ~ NS
      Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
    1     38 90.309                                  
    2     36 31.698  2    58.611 33.283 6.537e-09 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

    > lines(x,fitted(fit.linear))
    > lines(x,fitted(fit.nonlinear),col="red")


