Regression calculator
Enter or paste your data, write the model you want with ~ instead of =, and the calculator fits it. Every parameter comes with a standard error, and you can show the residuals and a 95% confidence band for the fitted curve.
How to use the regression calculator
- 1Add a table from the + menu and type or paste your data into the columns x1 and y1. You can also import a CSV file.
- 2Type the model with
~:y1 ~ m x1 + bfor a line,y1 ~ a x1^2 + b x1 + cfor a quadratic,y1 ~ a e^(b x1)for exponential. - 3Read the fitted parameters, their standard errors, R² and RMSE under the row.
- 4Turn on the 95% band to see the uncertainty in the fitted curve, or Residuals to check the model.
How the fit is computed
Linear models (any model that is linear in its parameters, including polynomials) are solved exactly by least squares using a QR decomposition. That is more accurate than the textbook normal equations, which square the condition number and lose digits on badly scaled data.
Nonlinear models, such as a e^(bx) or a logistic curve, are fitted by the Levenberg–Marquardt algorithm. It minimises the same sum of squared residuals, starting from automatic initial guesses. The exponential is fitted directly rather than by taking logarithms, so large and small values are weighted the same.
Reading the output
- Parameters ± standard error. The ± is one standard error. Roughly, the true value is within two standard errors 95% of the time.
- R² is the fraction of the variation in y that the model explains. Close to 1 is a tight fit, but a high R² does not prove the model is right.
- RMSE is the typical size of a residual, in the units of y.
- The 95% band shows where the true curve plausibly lies, given the data. It is narrowest near the middle of the data and widens at the ends.
- Residuals should look like random scatter around zero. A curved pattern means the model is missing something.
Choosing a model
Start from what you know about the process. Constant rates of change suggest a line, constant percentage growth an exponential, and growth that levels off a logistic curve. Then check the residuals. Adding parameters always raises R², so prefer the simplest model whose residuals look random.
Examples to try
y1 ~ L/(1 + e^(-k(x1 - h)))Frequently asked questions
How do I do a linear regression?
Can it fit exponential and other nonlinear models?
What does R² mean?
Can I import data from a spreadsheet?
What is the confidence band?
Related tools and guides
It opens instantly, with no account and nothing to install.