Scatter Plot Correlation Calculator
Calculate Pearson and Spearman correlation coefficients from paired data with significance test.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
Scatter Plot Correlation Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: r = SS_XY / sqrt(SS_XX * SS_YY)
Worked example โ Pearson r = 0.9948 | R-squared = 98.96% | Spearman rho = 1.0 | p < 0.0001
Formula
r = SS_XY / sqrt(SS_XX * SS_YY)
Where r is the Pearson correlation coefficient, SS_XY = sum of (xi - x-mean)(yi - y-mean), SS_XX = sum of (xi - x-mean)^2, SS_YY = sum of (yi - y-mean)^2. Spearman rho uses the same formula applied to ranks instead of raw values.
Worked Examples
Example 1: Study Hours vs Exam Scores
Problem:Hours studied (x): 1, 2, 3, 4, 5, 6, 7, 8 and exam scores (y): 52, 58, 63, 70, 74, 80, 85, 91. Find Pearson and Spearman correlations.
Solution:n = 8, x-mean = 4.5, y-mean = 71.625 SS_XX = 42, SS_YY = 1206.875, SS_XY = 224 Pearson r = 224 / sqrt(42 * 1206.875) = 224 / 225.17 = 0.9948 R-squared = 0.9896 (98.96%) Spearman rho = 1.0 (perfect monotonic) t-statistic = 0.9948 * sqrt(6 / 0.0104) = 23.89, p < 0.0001
Result:Pearson r = 0.9948 | R-squared = 98.96% | Spearman rho = 1.0 | p < 0.0001
Example 2: Temperature vs Ice Cream Sales
Problem:Temperature (F): 60, 65, 70, 75, 80, 85, 90 and sales ($): 100, 125, 140, 180, 210, 260, 300. Find the correlation and regression line.
Solution:n = 7, x-mean = 75, y-mean = 187.86 Pearson r = 0.9935 R-squared = 0.9871 (98.71%) Slope = 6.393, Intercept = -291.57 Regression: y = 6.393x - 291.57 Spearman rho = 1.0 (monotonically increasing)
Result:r = 0.9935 | y = 6.393x - 291.57 | Very strong positive correlation
Frequently Asked Questions
What is correlation and how is it measured?
Correlation measures the strength and direction of the linear relationship between two variables. It ranges from -1 to +1, where +1 indicates a perfect positive linear relationship (as one variable increases, the other increases proportionally), -1 indicates a perfect negative linear relationship (as one increases, the other decreases proportionally), and 0 indicates no linear relationship. The most common measure is the Pearson correlation coefficient (r), which quantifies linear relationships. The Spearman rank correlation coefficient (rho) measures monotonic relationships and is more robust to outliers. Correlation does not imply causation; two variables can be highly correlated due to a common third variable or coincidence.
What is the difference between Pearson and Spearman correlation?
Pearson correlation measures the strength of the linear relationship between two continuous variables, assuming both are approximately normally distributed with no extreme outliers. It uses actual data values in its calculation. Spearman rank correlation converts data to ranks first, then computes Pearson correlation on the ranks. This makes Spearman robust to outliers, applicable to ordinal data, and able to detect monotonic (consistently increasing or decreasing) relationships that may not be linear. For example, an exponential relationship y = 2^x would have Pearson r less than 1 because the relationship is not linear, but Spearman rho would be exactly 1 because the relationship is perfectly monotonic. Use Pearson when data is continuous, roughly normal, and you expect linearity. Use Spearman otherwise.
How do you interpret the R-squared value?
R-squared (coefficient of determination) is the square of the Pearson correlation coefficient and represents the proportion of variance in one variable that is explained by its linear relationship with the other variable. An R-squared of 0.81 means 81 percent of the variation in y is accounted for by the linear relationship with x, while 19 percent is unexplained. R-squared ranges from 0 to 1 (or 0 to 100 percent). In the social sciences, R-squared values of 0.25 to 0.50 are common and considered meaningful. In physics or engineering, R-squared above 0.95 is expected. Context matters enormously for interpretation; a high R-squared does not validate the model, and a low R-squared does not mean the relationship is unimportant.
What does statistical significance of correlation mean?
Statistical significance tests whether the observed correlation is likely to have occurred by chance if the true population correlation were zero. The test uses a t-statistic calculated as t = r * sqrt((n-2) / (1-r^2)), which follows a t-distribution with n-2 degrees of freedom. A small p-value (typically below 0.05) means the correlation is statistically significant, meaning it is unlikely to be zero in the population. However, significance depends heavily on sample size: with large samples (n > 500), even tiny correlations like r = 0.10 become significant. Conversely, meaningful correlations may fail significance tests with small samples. Always report the correlation coefficient alongside the p-value, not just whether the result is significant.
What are the assumptions of Pearson correlation?
Pearson correlation requires several assumptions for valid inference. Both variables should be continuous and measured on interval or ratio scales. The relationship should be approximately linear; Pearson correlation can underestimate the strength of curvilinear relationships. Both variables should be approximately normally distributed, especially for hypothesis testing with small samples. Observations should be independent of each other. There should be no significant outliers, as a single extreme point can dramatically inflate or deflate the correlation coefficient. Homoscedasticity (equal variance of y across x values) is assumed. When these assumptions are violated, consider Spearman rank correlation, Kendall tau, or data transformations before computing Pearson correlation.
Why does correlation not imply causation?
Correlation measures association, not causation, for several important reasons. First, the relationship may be spurious, driven by a confounding variable. Ice cream sales and drowning rates are positively correlated because both increase in summer, not because ice cream causes drowning. Second, the causal direction may be reversed; we might observe correlation between X and Y when Y actually causes X. Third, there may be no causal relationship at all; with enough variables, some will correlate by pure chance (the multiple comparisons problem). Fourth, correlation measures linear association only and can miss nonlinear causal relationships. Establishing causation requires controlled experiments, temporal precedence, elimination of confounders, and theoretical justification.
How does sample size affect correlation results?
Sample size affects correlation results in multiple ways. With very small samples (n less than 10), correlation estimates are unstable and can be misleadingly high or low just by chance. Confidence intervals around the correlation are wide, making precise estimation difficult. As sample size increases, correlation estimates become more stable and confidence intervals narrow. For significance testing, larger samples make it easier to detect small correlations; a correlation of r = 0.10 is not significant with n = 30 but is highly significant with n = 1000. The recommended minimum sample size for meaningful correlation analysis is typically n = 30 or more. For detecting small effects (r around 0.10 to 0.20), sample sizes of several hundred may be needed.
What is covariance and how does it relate to correlation?
Covariance measures how two variables change together, calculated as the average of the products of deviations from their respective means. A positive covariance means both variables tend to be above or below their means simultaneously. A negative covariance means when one is above its mean, the other tends to be below. The problem with covariance is that its magnitude depends on the scales of the variables, making it hard to interpret. Correlation solves this by standardizing covariance: r = covariance(X, Y) / (stddev(X) * stddev(Y)). This normalization confines the result to the range -1 to +1, making it scale-independent and directly interpretable. Covariance is used in portfolio theory, principal component analysis, and multivariate statistics.
How do outliers affect correlation coefficients?
Outliers can dramatically distort Pearson correlation. A single outlier far from the main data cloud can either inflate or deflate the correlation coefficient, depending on its position. An outlier in the direction of the trend increases the absolute value of r, while an outlier perpendicular to the trend decreases it. For example, in a dataset with near-zero correlation, adding one point at (100, 100) can push r close to 1.0. This sensitivity is a major weakness of Pearson correlation. Spearman rank correlation is much more resistant to outliers because it uses ranks rather than actual values, limiting the influence of any single extreme observation. Always create a scatter plot to visually check for outliers before interpreting correlation statistics.
Can correlation be used with non-linear relationships?
Pearson correlation specifically measures linear relationships and will underestimate the strength of nonlinear relationships. A perfect parabolic relationship y = x^2 with symmetric x values might produce Pearson r near zero despite a deterministic relationship. For monotonic nonlinear relationships (where y consistently increases or decreases with x, just not at a constant rate), Spearman rank correlation is appropriate and will give a coefficient near +1 or -1. For general nonlinear relationships, consider the distance correlation (which can detect any dependence), mutual information (from information theory), or specific nonlinear measures like the eta coefficient. Alternatively, transform variables (logarithm, square root) to linearize the relationship before computing Pearson correlation.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎScatter Plot Calculator
Calculate scatter plot with inputs, formulas, and instant results.
๐งฎCorrelation and Covariance Calculator
Calculate correlation and covariance with inputs, formulas, and instant results.
๐งฎCorrelation Calculator
Calculate correlation with inputs, formulas, and instant results.
๐งฎBox Plot Calculator
Generate box plot statistics (Q1, Q2, Q3, IQR, whiskers, outliers) from a data set.
๐งฎAnnulus Area Calculator
Calculate annulus area with inputs, formulas, and instant results.
๐งฎArea Calculator
Calculate area with inputs, formulas, and instant results.
๐งฎArea of a Rectangle Calculator
Calculate the area, perimeter, and diagonal of a rectangle. Find missing sides from known area. Convert between metric and imperial area units.
๐งฎArea of Crescent Calculator
Calculate area of crescent with inputs, formulas, and instant results.