Calculating quality / exactness of linear fit

54 Views Asked by At

I'm doing a standard least-squares fit of data points. I'm wondering if the computation for the least-squares fit can also easily produce a measure of "quality" of the fit. Perhaps there is a better mathematical term for this measure, but what I mean is this: if the data form a perfect straight line, the quality should be 1. If the data form a square box (which really gives no guidance at all for a linear fit) the quality should be 0. If the data show a noisy but definite trend, the quality value should be intermediate.

Is there a better name for this measure? Is it easily calculated while calculating the least-squares fit?

1

There are 1 best solutions below

2
On

Yes, there is a standard measure for this, it's called $R^2$ and every statistics package that runs your OLS regression will also report it. It's value is between 0 (fit does not explain the variance in the data) and 1 (perfect fit, as you suggest). It's exactly what you are describing. See the wiki entry for the precise formula if you want to calculate it by hand.