Correlation and Linear Regression Calculator

Calculate Pearson's r, R-squared, the regression line and its p-value from paired data.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Step 1: Open Correlation and Linear Regression Calculator and add your input

    Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.

  2. 2
    Step 2: What Correlation and Linear Regression Calculator does

    Calculate Pearson's r, R-squared, the regression line and its p-value from paired data.

  3. 3
    Step 3: Read the result and compare

    The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.

  4. 4
    Step 4: Copy or save it

    Copy the result or download it. For an important decision, confirm it with the official source or an adviser.

About this tool

Type one pair of numbers per line (x, y) and optionally a value of x to predict. The calculator gives the slope and intercept of the least-squares line, Pearson's correlation r, R-squared, the p-value, the standard error of the slope and the predicted y.

Formulas

slope = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)². intercept = ȳ − slope × x̄. Pearson's r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² Σ(y − ȳ)²). R² is the share of the variation in y explained by x. The p-value uses t = r √((n − 2) ÷ (1 − r²)) with n − 2 degrees of freedom.

Caution

Correlation does not prove causation. Look at a scatter plot for curvature and outliers, and avoid predicting far outside the range of x.

Input

One pair per line, separated by a comma or a space.

Worked example

Six points (1, 2.1), (2, 3.9), (3, 6.2), (4, 7.8), (5, 10.1), (6, 12.2) give y = 2.02x − 0.02, r = 0.9991, R² = 0.9982, p < 0.0001, and a prediction of 14.12 at x = 7.

Tips for best results

Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.

Quick facts

Embed this calculator on your site

Copy this code to show the calculator on your own page. A link back to shobfree.com is included.

Frequently asked questions

What is a strong correlation?

Above about 0.7 in absolute value, depending on the field.

Does r = 0 mean no relationship?

Only no straight-line relationship.

How many points do I need?

At least 3, preferably many more.

Can I predict outside my data?

It is risky; extrapolation may fail.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages