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

Common Mistakes to Avoid

How to Interpret Results

Related Standards & References

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.