Statistics & graphs · SL/HL

Regression, r & R²

Fit a straight line to paired measurements.

Your values

Number formats & units

Use decimal dots in datasets. Single values also accept decimal commas and scientific notation such as 1.2e-3 or 1.2 × 10⁻³.

Linear Regression, r & R² Calculator inputs

Calculated locally. No account or input upload.

Result & working

Example

The calculator is loading. The worked example is also shown below.

Copy & export

Formula & example

The relationship

m=SxySxxm=\frac{S_{xy}}{S_{xx}}
c=yˉ−mxˉc=\bar y-m\bar x
r=SxySxxSyyr=\frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}
R2=1−SSESSTR^2=1-\frac{\mathrm{SSE}}{\mathrm{SST}}
What the variables mean
SymbolMeaning
rrPearson correlation coefficient, from −1 to +1.
R2R^{2}Coefficient of determination for the fitted trend.

Worked example

X data
1 2 3 4 5
Y data
2.1 4.2 5.8 8.1 10.2
X-axis label
Independent variable
Y-axis label
Dependent variable

y = 2.01x + 0.05

Follow the example steps
  1. OLS fit: y = 2.01x + 0.05
  2. Pearson r = 0.9986784
  3. R² = 0.9973585

Common mistakes

Keep each x paired with the y measured with it.

Incorrect approach

Original pairs (1, 5), (2, 3): sort y alone to get (1, 3), (2, 5).

Correct approach

Keep (1, 5), (2, 3): the fitted gradient is −2.

More checks before you submit
  • A high R² does not prove the chosen model is biologically correct.
  • Do not use linear regression blindly on strongly curved relationships.
Method notes

Correlation describes association; it does not by itself demonstrate causation. Inspect the graph and biological context.