Correlation Heatmap
Compute and visualize Pearson correlation matrix. Analyze linear relationships between numeric variables. The heatmap shows correlation coefficients from -1…
Analyze linear relationships between numeric variables. The heatmap shows correlation coefficients from -1 (strong negative) to +1 (strong positive).
What Is Pearson Correlation?
The Pearson correlation coefficient (r) measures the strength and direction of the linear relationship between two continuous variables. It ranges from −1 (perfect negative linear relationship) through 0 (no linear relationship) to +1 (perfect positive linear relationship).
The correlation matrix displays pairwise r values for all variable combinations. A heatmap visualization makes it easy to spot strongly correlated pairs — critical for identifying redundant features in data analysis, detecting multicollinearity in regression, and understanding variable relationships in exploratory data analysis.
Correlation does not imply causation. Two variables may be highly correlated due to a common confounding factor. The p-value tests whether the observed correlation is statistically significant (typically p < 0.05), but significance depends on sample size — with large datasets, even trivially small correlations can be statistically significant.
Formula: r = [nΣxᵢyᵢ − ΣxᵢΣyᵢ] / √[(nΣxᵢ² − (Σxᵢ)²)(nΣyᵢ² − (Σyᵢ)²)] |r| interpretation: 0.0–0.3: weak 0.3–0.7: moderate 0.7–1.0: strong
Example Calculation
Variables X = [1,2,3,4,5], Y = [2,4,5,4,5]. Σx=15, Σy=20, Σxy=67, Σx²=55, Σy²=86, n=5. r = (335−300)/√((275−225)(430−400)) = 35/√(50×30) = 35/38.73 ≈ 0.904 — a strong positive correlation.
When to Use This Calculator
- A data analyst performing exploratory data analysis to identify which variables are strongly related before building predictive models
- A researcher detecting multicollinearity among predictor variables before running regression analysis
- A quality engineer investigating which process parameters are correlated with product defects or yield
- A financial analyst examining relationships between asset returns for portfolio diversification decisions
Common Mistakes to Avoid
- Interpreting correlation as causation — two variables moving together does not mean one causes the other; a third variable (confound) may drive both
- Ignoring non-linear relationships — Pearson correlation only measures linear association; two variables can have a strong non-linear relationship (e.g., quadratic) with r near zero
- Treating statistical significance as practical importance — with large sample sizes, even tiny correlations (r = 0.05) can be statistically significant (p < 0.05) but have no practical meaning
- Not checking for outliers before computing correlation — a single extreme data point can inflate or deflate the Pearson r dramatically; inspect scatter plots first
How to Interpret Results
- Correlation values near +1 or -1 indicate strong linear relationships; near 0 indicates no linear relationship (but not necessarily no relationship)
- The strongest correlation pair highlighted in results identifies the most tightly linked variables — useful for feature selection or multicollinearity detection
- Clusters of high correlations in the heatmap suggest groups of related variables that may be measuring the same underlying factor
Related Standards & References
- Pearson, K. (1896), 'Mathematical Contributions to the Theory of Evolution. III. Regression, Heredity, and Panmixia' — formalization of the product-moment correlation coefficient
- Fisher, R. A. (1925), Statistical Methods for Research Workers — significance testing for correlation coefficients
- NIST/SEMATECH e-Handbook of Statistical Methods — reference procedures for correlation analysis and scatter-plot interpretation
Frequently Asked Questions
What is the difference between Pearson and Spearman correlation?
Pearson measures linear relationships between continuous variables and assumes normal distributions. Spearman uses ranks instead of raw values, making it suitable for ordinal data, non-linear monotonic relationships, and data with outliers. Use Spearman when the relationship is monotonic but not necessarily linear.
How do I interpret p-values in a correlation matrix?
A p-value < 0.05 indicates the correlation is statistically significantly different from zero at the 95% confidence level. However, with many pairwise comparisons, apply a multiple testing correction (e.g., Bonferroni: divide 0.05 by the number of tests) to avoid false positives.