Understand the idea
Pick any two of your numeric columns. Do they tend to rise together (positive correlation), does one rise as the other falls (negative), or is there no consistent pattern (near zero)? The correlation coefficient answers that in one number: +1 means a perfect rising straight-line relationship, -1 a perfect falling one, and 0 means no linear relationship at all.
With more than two variables, the matrix just does this for every pair at once, so you can scan a whole table (or a color-coded heatmap) instead of running the comparison one pair at a time. The diagonal is always 1 (every variable is perfectly correlated with itself) and the matrix is a mirror image across that diagonal.
A correlation, however strong, never by itself tells you that one variable CAUSES the other to change. Two things can move together because one drives the other, because both are driven by some third thing, or by pure coincidence in a small sample: the number cannot tell those apart.
Pearson correlation measures straight-line association; Spearman correlation and Kendall's tau work from ranks, so they measure any steadily rising or falling association and are less swayed by outliers. A correlation heatmap colors each cell of the correlation matrix so that strong positive and negative pairs stand out.
Practitioner explanation
KernelStats offers three coefficients: Pearson r (linear association, requires roughly interval data), Spearman rho (rank correlation, robust to monotonic-but-nonlinear trends and to outliers), and Kendall tau (concordance of pairwise rankings, more conservative and more robust still, preferred at small n or with many tied ranks). Missing-value handling defaults to pairwise (each pair uses its own complete cases, maximizing the data used per pair at the cost of pairs potentially resting on different subsamples) with listwise (one common complete-case subset across all variables) offered as the stricter alternative.
Pearson correlations additionally carry a 95% confidence interval built on the Fisher z-transform (z = arctanh(r), approximately normal with SE = 1/sqrt(n-3)), then transformed back to the r scale, which is why the reported interval is asymmetric around r whenever r is far from 0. Significance stars are the per-pair, UNADJUSTED p-value against H0: true correlation = 0; with many variables this is many simultaneous tests, so the stars are NOT adjusted for multiplicity. The card instead reports how many pairs stay significant after a Holm step-down adjustment at a 5% family-wise level (statistics.n_significant_holm_05) and shows a multiple-comparisons warning that points to Multiple Testing Correction, which adjusts a set of p-values you supply; Exploratory Data Analysis (EDA) also adjusts across its whole family of pairs. Treat unadjusted stars in a large matrix as leads to check, not findings.
How the p-values are computed follows R's cor.test defaults, and each pair's p_method records the route. Pearson uses the t-test above. Spearman gives an exact p-value (AS 89) when neither variable has tied values and n < 1290, and otherwise the t-approximation applied to rho. Kendall tau-b gives an exact p-value when there are no ties and n < 50, and otherwise a normal approximation with a tie-corrected variance. In plain words: with small samples and no repeated values the card computes the p-value from every possible ordering of the data rather than from a bell-curve shortcut, and it falls back to the shortcut only when there are repeated values or the sample is large; at small n the two can land on opposite sides of .05.
r == 0 does not mean 'unrelated': Pearson r is blind to any non-linear relationship (a strong U-shape can show r near 0), which is why the card's notes tell you to inspect the scatter plot of any pair before trusting its coefficient. The card itself draws a heatmap of the matrix and (for more than two variables) a bar chart of the strongest pairs; it does not draw the scatter plots, so open them with Scatter Plot.
When to use it
Consider it when
You have two or more numeric variables and want to see, at a glance, which pairs move together and how strongly, typically before modeling, or to screen for multicollinearity among predictors.
Use caution when
When the relationship is expected to be curved rather than monotonic (Pearson and Spearman will both understate or miss it; look at the scatter plot instead), when you need to control for a third variable's influence (use partial correlation), or when you intend to interpret any correlation causally without a design that supports that claim.
Formulas and symbols
Pearson correlation coefficient
The covariance of x and y rescaled by their standard deviations, so it no longer depends on the measurement units.
Fisher-z confidence interval (Pearson)
A symmetric interval is built on z and transformed back to r with tanh, giving an interval that is asymmetric in r near +/-1.
Significance test for a correlation
Under the null that the true correlation is 0, t follows a Student's t distribution with n-2 degrees of freedom (Pearson case).
Assumptions and checks
- Normality (of residuals, not of the raw data). Pearson's r and its p-value assume the two variables are approximately normal; strong non-normality (skew, heavy tails, outliers) distorts the p-value and the confidence interval around r more than it distorts r itself.
In KernelStats: Shapiro-Wilk per variable (for 3 to 5000 observations), reported on the card only when Pearson's method is used; Spearman and Kendall do not require it and the card does not run this check for them.
- Linearity. Pearson's r captures only straight-line association; a strong curved (nonlinear) relationship can produce a small or even zero Pearson r despite the variables being clearly related, understating the true association.
In KernelStats: For Pearson only, the card's 'Linearity (quadratic-term check) & outliers' row refits every pair with an added squared term (in both directions) and flags curvature when the squared term adds at least 2% explained variance with p < .01 on a partial F-test (pairs with fewer than 10 complete cases are skipped); the same row counts 1.5 x IQR outliers per variable. A curve that a squared term does not capture (a step or an S-shape) can still pass, so inspect the scatterplot directly.
- Spearman and Kendall measure monotonic (consistently increasing or decreasing) association; a relationship that reverses direction partway through (e.g. U-shaped) is understated by all three coefficients, not just Pearson's.
In KernelStats: Not checked by KernelStats: monotonicity is not tested for any method; inspect the scatterplot before trusting the coefficient chosen.
Alternatives
- Partial Correlation. You suspect the association between two variables is driven by a third variable and want to see what remains after holding it constant.
- Linear Regression. You want to quantify the relationship as a predictive equation (slope, intercept) rather than just its strength, or you have more than two variables and want to model one as a function of the others jointly.
- Exploratory Data Analysis (EDA). You are screening many pairs at once and need the multiple-testing-adjusted verdicts rather than each pair's raw, unadjusted p-value.
Worked example
Scenario
Pearson correlations among bill length, bill depth, flipper length, and body mass across 342 penguins.
Result
Flipper length and body mass correlate at r = 0.87, 95% CI [0.84, 0.89], p < .001; bill length and bill depth correlate at r = -0.23, p < .001.
Interpretation
Flipper length and body mass move together very strongly and consistently: larger-flippered penguins are reliably heavier. The bill length/depth correlation is real (a large sample makes even a modest r statistically significant) but weak in practical terms, and its negative sign is driven by species differences in bill shape, worth checking with a scatter plot colored by species before reading too much into the pooled number.
Dataset: penguins.csv
Common misconceptions
Misconception
A strong correlation between two variables means one causes the other.
Correction
Correlation only measures how consistently two variables move together, never why. A third, unmeasured variable can drive both (a confounder), the causal arrow can run the opposite direction from the one assumed, or the association can be a coincidence of the sample. Establishing causation requires a design (randomization, or a carefully argued natural experiment), not a bigger correlation.
Read more: Misconception: correlation implies causation
Misconception
A correlation of r = 0 means the two variables are unrelated.
Correction
Pearson's r only measures LINEAR association. Two variables can have a strong, perfectly deterministic, curved relationship (for example y = x^2 over a symmetric range of x) and still show r near 0. Always look at the scatter plot, or use Spearman/Kendall for a monotonic-but-nonlinear relationship, before concluding two variables are unrelated.
References
- NIST/SEMATECH e-Handbook of Statistical Methods, §6.5.2.1 Correlation, NIST/SEMATECH (2012), §6.5.2.1.
- Statistical Power Analysis for the Behavioral Sciences, Cohen, J. (1988).
