What regression does
Regression finds the curve of a chosen shape that best fits your data points. An exponential model fits things that grow or shrink by a steady percentage: bacteria, compound interest, cooling, radioactive decay, viral spread. Linear fits steady amounts of change, power fits area and volume scaling, and logarithmic fits growth that keeps slowing down.
How it's calculated
Linear regression is ordinary least squares. It picks the line that makes the sum of squared vertical distances to the points as small as possible:
r = Σ(x − x̄)(y − ȳ) ÷ √[Σ(x − x̄)² · Σ(y − ȳ)²], R² = r²
The curved models are made straight by taking logs, fitted as a line, then transformed back:
| Model | Straight line fitted | Then |
|---|---|---|
| Exponential, y = a·e^(bx) | ln y against x | a = e^(intercept), b = slope. Also y = a·Bˣ with B = e^b |
| Power, y = a·x^b | ln y against ln x | a = e^(intercept), b = slope |
| Logarithmic, y = a + b·ln x | y against ln x | a = intercept, b = slope |
Important: the exponential and power fits are transformed fits. They minimize squared errors in ln y, not in y. This is the standard log-transform method, but a direct nonlinear least-squares fit can give slightly different a and b, and gives more weight to large y values. So the page reports two R² values: the R² of the straight-line fit to ln y, and an R² measured on y itself, 1 − Σ(y − ŷ)² ÷ Σ(y − ȳ)².
Worked example
The default data (x = 0 to 5, y = 2.0, 3.1, 4.4, 6.9, 10.2, 15.1) looks like steady percentage growth. Fitting a line to (x, ln y) gives slope 0.403732 and intercept 0.70313, so
Each step of 1 in x multiplies y by about 1.497, so y doubles every ln 2 ÷ 0.4037 ≈ 1.717 units of x. The correlation of ln y with x is r ≈ 0.99967, so R² ≈ 0.99933.
Limitations
- Exponential fits need every y above 0, power fits need every x and y above 0, and logarithmic fits need every x above 0, because logs of 0 or negatives don't exist. The calculator names the first point that breaks the rule.
- A high R² doesn't prove the model is right. Look at the residuals. If they curve in a pattern instead of scattering randomly, try another model.
- Predicting far outside your x range (extrapolation) is risky, especially with exponential models, which grow without limit.
- One outlier can pull a least-squares fit a long way. Check the residual table for any point that sits far from the rest.