How to use the curve fit calculator
- Paste your x and y pairs, one pair per line, with a comma, space or tab between the numbers. At least three pairs are needed.
- Leave Model to show on "Best fit by R squared", or choose one of the five curves. The comparison table always lists every model that can be fitted to your data.
- Enter an x value under Predict y at x to see what the chosen curve gives there. A prediction inside the range of your data is far more reliable than one outside it.
- Look at the residuals table. If the leftovers show a pattern, such as all positive in the middle and negative at the ends, the curve misses something.
Formula
Linear: y = a + b x Quadratic: y = a + b x + c x^2
Exponential: y = a e^(b x), fitted as ln y = ln a + b x
Logarithmic: y = a + b ln x Power: y = a x^b, fitted as ln y = ln a + b ln x
R squared = 1 - (sum of squared residuals) / (total variation of y)
Linear and quadratic fits solve the least squares equations directly. The other three are straight lines after a transformation, so they are fitted on the transformed scale and converted back. R squared is always measured on your original y values, so the five models can be compared fairly.
Eight points that grow fast
Take x = 1 to 8 and y = 2.9, 4.1, 6.2, 8.8, 13.1, 18.7, 27.4 and 39.6. The R squared values on y are 0.8867 for the line, 0.9946 for the quadratic, 0.9999 for the exponential, 0.6741 for the logarithmic curve and 0.8441 for the power curve.
The best fit is y = 1.9795 e^(0.375076 x), which grows about 45.5% for each step in x. At x = 10 it predicts 84.2347, while the quadratic y = 5.78571 - 2.81429 x + 0.861905 x^2 predicts 63.8333. Both fit the data well, and they disagree outside it, which shows why predictions beyond your data deserve caution.
Choosing between models
A higher R squared means the curve follows these points more closely, but a flexible curve can always follow points more closely. The adjusted R squared and the standard error in the table take the number of coefficients into account, so they are fairer when you compare a quadratic with a two-coefficient model.
Think about the process too. Growth that multiplies by a similar factor each step suggests an exponential, a quantity that changes by a fixed amount suggests a line, and a relation that follows a power of size, such as area against length, suggests a power curve. The fit cannot decide that for you.
When a model cannot be fitted
Exponential and power curves need every y to be above 0, because they use ln y. Logarithmic and power curves need every x above 0. The quadratic needs three different x values. A model that cannot be fitted is marked "not fitted" in the comparison table instead of giving a wrong number. For a straight line only, the Linear Regression Calculator gives more detail about the slope and the correlation.
More statistics tools
For reliability, risk and distribution questions, try the Odds Ratio and Relative Risk Calculator, Grouped Data Statistics Calculator and Skewness and Kurtosis Calculator.
Assumptions and limits
- Each pair is a separate observation, and x is known much more precisely than y.
- The spread of y around the curve is roughly the same everywhere. Fitting ln y gives more weight to small y values than a fit on y itself would.
- No weighting of points and no removal of outliers is applied.
- Predictions use the fitted curve as written, with no interval around them.
Frequently asked questions
Why can R squared be lower than the value I get in a spreadsheet for an exponential trendline?
Many spreadsheets report R squared on the logarithm of y. This page reports it on the original y values and also shows the transformed value, so you can match either convention.
What does the standard error of the fit mean?
It is the usual size of a residual, in the units of y, after allowing for the number of coefficients: the square root of the sum of squared residuals divided by the points minus the coefficients.
Can I fit a curve through just three points?
The page allows it, but a quadratic through three points passes through every one of them, so R squared is 1 and tells you nothing. A warning appears when there are no more points than coefficients.
How do I read a negative residual?
A negative residual means the point lies below the curve, so the curve predicted more than the measured value. Residuals of a straight line or quadratic fit always add up to zero.