Skip to main content

Regression calculator with R², r and residuals

Paste two columns of data, type the model you want with a ~, and the Grapher finds the parameters by least squares. For a straight line you get r and R², the residuals and a plain-English explanation of what the numbers mean.

The free IB Math Revision Grapher: A straight line fitted to seven points of practice data, with “What this model means” open under the fit
A straight line fitted to seven points of practice data, with “What this model means” open under the fit. Open it in the full Grapher.

How to do it

  1. Put your data in a table. Copy two columns from a spreadsheet and paste them into an empty line: they become a table with lists x₁ and y₁. Or press + Table and type the values. Column headings like “Time (s)” become the axis labels.
  2. Type the model with ~. On a new line type y_1 ~ m x_1 + b. The ~ means “fit this”: the Grapher chooses m and b to make the sum of squared residuals as small as possible, and draws the line.
  3. Read m, b, r and R². The parameters appear under the line, with r (for a straight line) and R². Open What this model means for each parameter in context, how to read r and R², and whether the residuals show a pattern.
  4. Check the residuals. Tap residual plot under the fit for a small graph of the residuals against x, or type (x_1, e_1) to plot them on the main graph. A random scatter about zero supports the model; a curve or a trend means it is missing something.
The Grapher showing a straight line fitted to data points, with the gradient, intercept, r and R² and the What this model means panel
A straight-line fit with its parameters, r and R², and the plain-English explanation under it.

Good to know

Frequently asked questions

How do I find the line of best fit and r?

Put the data in a table (lists x₁ and y₁), then type y_1 ~ m x_1 + b. The Grapher shows m, b, the correlation coefficient r and R², and draws the line.

What is the difference between r and R²?

r (Pearson's correlation coefficient) measures how close the points are to a straight line, from −1 to 1, and is shown for straight-line fits. R² (the coefficient of determination) is the fraction of the variation in y that the model explains; it is shown for every model. For a straight line, R² = r².

Does it show the residuals?

Yes. Each fit makes a residual list (e₁ for the first fit). Tap “residual plot” under the fit for a small graph of the residuals, or type (x_1, e_1) to plot them.

Is it free, and do I need an account?

It is free and needs no sign-in. A free account only adds saving to My graphs, so you can open your graphs on any device.

Learn more

More Grapher guides

The Grapher is our own free tool (graph.mathrevision.co.uk), built for IB, A Level and IGCSE students. It is not an exam calculator: practise on your own GDC for calculator papers.