BL2.ru

Correlation and Regression Calculator: Pearson r, y = a + bx, Significance

Paste two data columns (x and y). The calculator finds the Pearson correlation coefficient and rates the strength of the relationship on the Chaddock scale, tests its significance with the Student criterion, builds the regressions of y on x and x on y, makes a forecast and draws the scatter plot with the line. The solution is detailed, textbook style.

One pair per line: x and y separated by Tab, space or semicolon. You can paste two columns straight from Excel; the decimal separator is a comma or a dot. A header in the first line is allowed. At least three pairs are needed.
Significance level α
Calculate

What correlation shows

Pair correlation measures how closely two variables x and y are related linearly. The Pearson coefficient r = cov(x, y)/(σx·σy) lies between −1 and 1: the sign gives the direction (direct or inverse), the absolute value gives the strength. Correlation does not prove causation: two variables may grow together because of a third one.

The Chaddock scale

  • ∣r∣ below 0.1 — practically no relationship;
  • 0.1–0.3 — weak;
  • 0.3–0.5 — moderate;
  • 0.5–0.7 — noticeable;
  • 0.7–0.9 — high;
  • 0.9–0.99 — very high.

Regression

The regression of y on x is y = a + b·x, where b = cov(x, y)/σx² and a = ȳ − b·x̄. It is the line with the smallest sum of squared vertical deviations. The regression of x on y is another line: x = a′ + b′·y, and b·b′ = r². The lines coincide only when ∣r∣ = 1. The coefficient of determination r² is the share of the variation of y explained by the linear relationship with x.

Significance of the coefficient

If there is no relationship, the statistic t = r·√(n − 2)/√(1 − r²) follows the Student distribution with n − 2 degrees of freedom. If ∣t∣ exceeds the critical value for the chosen level α (for example 2.228 at α = 0.05 and 10 degrees of freedom), the coefficient is significant. The calculator computes Student quantiles itself, so no table is needed.

Approximation error

The mean approximation error Ā = (1/n)·Σ∣(y − ŷ)/y∣·100% shows by how many percent on average the fitted values differ from the actual ones. An error of up to 8–10% is considered acceptable.

Example

x = 1, 2, 3, 4, 5; y = 2, 4, 5, 4, 5. Means: x̄ = 3, ȳ = 4, σx² = 2, σy² = 1.2, cov = 1.2. Then r = 1.2/(√2·√1.2) = 0.7746, r² = 0.6, the regression is y = 2.2 + 0.6·x. The statistic is t = 0.7746·√3/√0.4 = 2.121, while the critical t at α = 0.05 and k = 3 is 3.182. Since 2.121 is less than 3.182, with five points the relationship is statistically not significant even though it is high on the Chaddock scale: there is too little data.

If you need other fitting functions (parabola, power, exponential), use the least squares calculator.

FAQ

How do I calculate the correlation coefficient in Excel and by hand?
In Excel use CORREL(array1, array2). By hand: find the means x̄, ȳ, then r = (mean(xy) − x̄·ȳ)/(σx·σy). Here you can paste two Excel columns and get the same result with a calculation table and the numbers substituted.
How do I know whether the correlation coefficient is significant?
Compute t = r·√(n − 2)/√(1 − r²) and compare ∣t∣ with the Student critical value at the chosen α and n − 2 degrees of freedom. If ∣t∣ is larger, the null hypothesis of no relationship is rejected. The calculator does this itself and shows the p-value.
How is the regression of y on x different from the regression of x on y?
The first minimizes vertical deviations and is used to predict y from x. The second minimizes horizontal ones and predicts x from y. They are different lines that coincide only when r = ±1; the product of their slopes equals r².
What does high but insignificant correlation mean?
With few observations even a large r can appear by chance. The Student test takes the sample size into account: for five points ∣r∣ must exceed 0.878 at α = 0.05. Collect more data or do not draw conclusions about a relationship.
Can I forecast outside the range of the data?
Formally the equation gives a number for any x, but outside the observed range linearity is not guaranteed, so such a forecast is unreliable. The calculator warns when x is outside the data range.