Correlation & Linear Regression Calculator

Enter pairs of numbers (x, y) to find the correlation coefficient and the regression line that explains y from x.

Put each pair on its own line. Separate x and y with a space, a tab, a semicolon, or a comma followed by a space (3, 5). A comma with no space after it, such as 1,000 or 3,5, is not accepted, because it could be a thousands separator, a decimal comma, or the separator between x and y. Write decimals with a period (1.5) and do not use thousands separators. Every line must have exactly two numbers; a line with one or three numbers shows an error with its line number.
Correlation coefficient r —
Details
Correlation coefficient r—
Coefficient of determination R² (= r²)—
Slope of the regression line—
Intercept of the regression line—
Regression line—
Number of pairs—
Mean of x—
Mean of y—

Correlation and the regression line

The calculation uses exact fractions. The square root in r is an approximation unless it comes out exactly, and then the value is labeled "rounded value".

When x never changes, or y never changes

Situation Correlation and R² Regression line
All the x values are the same (the variance of x is 0) Not available Not available (the slope is not determined)
All the y values are the same (the variance of y is 0), and x varies Not available (the correlation coefficient is not defined when y has no variance) Available (slope 0, intercept = the mean of y: a horizontal line)

If both x and y are all the same, it is treated as the case where x has no variance. With only 2 pairs, r is always exactly ±1 (two points always lie on a line), so with very little data the correlation says little.

Notes

The last three points are general statistical cautions. They are not claims taken from a specific source.

Input rules

Examples

Data Result
(1, 2), (2, 3), (3, 5), (4, 4), (5, 6) r = 0.9, R² = 0.81, slope 0.9, intercept 1.3 (y = 0.9 x + 1.3)
(1, 2), (2, 4), (3, 6) r = 1, slope 2, intercept 0

What this calculator does not do

Spearman's rank correlation, significance tests (p-values) and confidence intervals, multiple regression and curve fitting, automatic outlier detection, scatter plots and predicted values are not covered. For the spread of one set of numbers, use the Standard Deviation Calculator, and for the average, the Mean & Median Calculator.

Frequently asked questions

Does a correlation close to 0 mean there is no relationship?

It means there is little linear relationship. A curved relationship may still exist.

If r is close to 1, does x cause y?

No. Correlation does not show causation.

Why does it say the slope cannot be calculated?

If all the x values are the same, the slope of the line is not determined.