Q:

What is a good way to measure the "linearity" of a dataset? 

I have an empirically gathered dataset which relates two variables.  Over a small range the relationship appears linear, however over a larger range there is clearly some second order polynomial relationship as can be seen in the image at http://imgur.com/W7f9p. 
I'm trying to get a measure of linearity for different ranges considered.  E.g. at 20 < x < 60 or 100 < x < 120 it is very linear, but at 20 < x < 180 it is not very linear.  I have tried to fit a straight line to the data and calculate the R^2 data (goodness of fit) but this shows that the straight line over the larger range has a better fit than over the smaller range.  While this may be true with MS Excel, from the image it is clear that the larger range is less linear...if you hold the side of a piece of paper against the points. 
Is there a better way to measure the "linearity" of a dataset?   

A:

Fit a quadratic instead of a linear function.  The absolute value of the estimate of the highest coefficient of the quadratic serves as a sensible measure of linearity, which is zero if the data lie exactly on a line.  Moreover, if the data come from a linear model with Gaussian noise, the Gauss-Markov theorem guarantees that the coefficient estimates are unbiased, hence under repetition of the fit with multiple data from the same model distribution, the expected value of the coefficient will be zero.  
Of course in a single fit, one usually doesn't get zero, so one would have to 
use some test for the significance of the coefficients. 

A:

One way to go would be to run a hierarchical regression with your Y-axis variable as the outcome/criterion.  In step/block 1 you would enter your X variable as a predictor, and in step/block 2, enter a product term (X squared or multiplied against itself).  The X squared term represents your quadratic component.  The standardized regression weights (betas) for X and X squared would give you some sense of the "strength" of the linear and quadratic components relative to each other, and the change in R-squared from step/block 1 to step/block 2 is an indication of how much better the model fits the data when you have added in the quadratic component. 
See Ch.  8 in Keith, T. Z. (2005).  Multiple regression and beyond.  Allyn & Bacon.  978-0205326440

