Linear Correlation
This calculator computes the Pearson linear correlation coefficient for paired data \((x,y)\).
It measures the strength and direction of a linear relationship between two variables.
What the calculator reports
-
Correlation coefficient \(r\), which always satisfies \(-1 \le r \le 1\).
Values near \(1\) indicate strong positive linear association; values near \(-1\) indicate strong negative linear association; values near \(0\) indicate little linear association.
-
Coefficient of determination \(r^2\), which is the proportion of variation in \(y\) explained by a straight-line relationship with \(x\).
-
(Optional) A hypothesis test about the population correlation \(\rho\) using a \(t\)-statistic and a p-value.
Formulas used (summary)
The calculator uses the standard sample correlation formula:
\[
r = \frac{SS_{xy}}{\sqrt{SS_{xx}\,SS_{yy}}}
\]
where
\[
SS_{xx}=\sum (x_i-\bar{x})^2,\quad
SS_{yy}=\sum (y_i-\bar{y})^2,\quad
SS_{xy}=\sum (x_i-\bar{x})(y_i-\bar{y})
\]
For testing \(H_0:\rho=0\) (with \(n\) pairs), the test statistic is:
\[
t = r\sqrt{\frac{n-2}{1-r^2}},\quad \text{df}=n-2
\]
How to use the calculator
-
Enter your paired data as two columns (x, y) in the textarea.
You can separate values using commas, tabs, semicolons, or spaces.
-
Or upload a CSV file (the calculator will parse it and load the data).
A header row like
x,y is allowed.
-
(Optional) Choose \(\alpha\) and the alternative hypothesis if you want a correlation significance test.
-
Click Calculate to see the graphs first, then the computed results and step-by-step work.
-
Use Copy clean CSV (and other copy/download buttons) to export your cleaned data and results.
Input example
Paste data like this (one pair per line):
x,y
10,22
15,25
20,29
25,35
Notes and tips
- Correlation is about linear patterns. A curved (nonlinear) relationship can produce \(r\) near \(0\) even if the variables are related.
- Correlation does not imply causation. A strong \(r\) alone does not prove that changes in \(x\) cause changes in \(y\).
-
If all \(x\) values are identical (or all \(y\) values are identical), then \(SS_{xx}=0\) (or \(SS_{yy}=0\)) and \(r\) is undefined.
The calculator will report an error in that case.