Correlation
Correlation summarizes the direction and strength of the linear relationship between two quantitative variables in a single unit-free number. The Pearson coefficient is the standard bivariate summary in measurement and prediction — reliability, validity, and item statistics are all correlations — but it compresses a two-dimensional relationship into one number and inherits its behavior from the raw scores, which makes scatterplot, outlier, nonlinearity, and range-restriction checks part of any responsible use. This page treats the coefficient itself: its definition from covariance, its properties, its geometric and regression readings, and inference for the population correlation . Monotone association is treated in rank correlation, dichotomized variables in correlations involving binary variables, and selection effects in range restriction and selection corrections.
Throughout, is the number of observed pairs , .
From covariance to correlation
The raw material is covariance. For a population, the covariance of and is the average product of deviations from the population means,
where and are the population means. Covariance is positive when the two deviations tend to share their sign — above-average with above-average — and negative when they tend to oppose it. Its magnitude, however, is uninterpretable on its own: it is expressed in the product of the two variables’ units, so the same association produces different covariances under different measurement units.
The correlation divides covariance by the two standard deviations, removing the scale. In the population,
with and the population standard deviations; is estimated from paired observations by the sample means , , the sample standard deviations , (divisor ), and the sample covariance :
A positive sign indicates that above-average values of one variable accompany above-average values of the other; a negative sign, the reverse.
The divisor cancels. Covariance and variance both depend on the versus convention (variability), but does not: computing the numerator covariance and both standard deviations with divisor instead of multiplies all three by the same factor, which cancels in the ratio. Any consistent convention gives the same . This immunity is special to the full formula. Collapsed shortcut formulas — such as the point-biserial expressions that pair a standard deviation with a multiplier — can mix conventions and change the value; that hazard and its remedies are treated in correlations involving binary variables.
Three equivalent computational forms
The same can be written three ways, each convenient in a different setting.
Standardized-score form. Let and be the -scores of the two variables. Then
the average product of the paired -scores (with the convention; divisor gives the same value for the same reason as above). Each case contributes positively when its two -scores lie on the same side of zero and negatively when they lie on opposite sides, which is the most direct reading of what averages.
Centered-sum form. Dropping the divisors entirely,
the sum of cross-products of the centered scores divided by the square roots of the two sums of squares. This form contains no at all and is the identity behind the geometric reading below.
Raw-score (computational) form. Expanding the deviations gives a formula in raw sums alone:
This is the hand-calculation form: it needs only the five sums , , , , . The three forms are algebraically identical; in finite-precision arithmetic the raw-sum form can suffer catastrophic cancellation when the scores are large relative to their spread, the same hazard noted for the computational variance, so the centered form is preferred in software.
Worked example
For and : the raw sums are , , , , , so the computational form has numerator and denominator . The centered quantities are with sums of squares and , so the centered-sum form gives . All three forms return
Sign, range, and invariance properties
Sign and range. The coefficient satisfies , with the endpoints attained exactly when the points lie on a straight line. The sign gives the direction of the linear association; the magnitude, its strength relative to the best straight line.
Location invariance. Adding a constant to either variable leaves unchanged: is built from deviations from means. If , then . Shifting the origin of either scale — raw scores versus deviation scores, Celsius versus Kelvin — does nothing.
Scale invariance. Multiplying either variable by a positive constant also leaves unchanged, and multiplying by a negative constant changes only the sign: for nonzero constants and . Reversing the scoring direction of one variable — reverse-keyed items, “lower is better” criteria — reverses the sign of and nothing else.
These are two separate properties, and together they make unit-free: any positive rescaling of either variable (centimeters to inches, raw scores to -scores) leaves exactly as it was. This is why a single number can summarize association between variables measured in unrelated units.
What invariance does not cover. is not invariant under nonlinear transformations. A strictly monotone transformation, such as taking logs of a positive variable or ranking observations, preserves ordering but changes the spacings on which depends; a nonmonotone transformation such as squaring can alter the relationship further. Applying Pearson’s coefficient after rank transformation yields Spearman’s .
Geometry: correlation as an angle
Center each variable and regard the results as vectors in -dimensional space, and . The centered-sum formula is the cosine of the angle between these vectors:
Three consequences follow immediately. A cosine lies in , which is the range bound. The endpoints occur exactly when the two centered vectors are collinear — when the data lie on a straight line. And means the centered vectors are orthogonal: the linear components of the two variables are perpendicular, however much other structure they share. (Both vectors must be nonzero: a variable with no variance has no correlation with anything.)
Correlation and simple linear regression
The least-squares line for predicting from is with
and in standardized units the line is simply : the slope of the regression of the standardized outcome on the standardized predictor is the correlation. With the sum of squared residuals around the line and the sum of squared deviations of about its mean, the squared coefficient,
is the proportion by which the least-squares line reduces the deviation sum of squares. Regressing on produces a different slope but the same . The residuals from the least-squares line are exactly uncorrelated with — a property of the least-squares fit, not evidence of independence.
Scope. The identity between and a “proportion of variance explained” holds for the simple straight-line regression — one predictor, fitted by least squares. Adding predictors or curvature to the model can raise the achievable above , and a strong curved relationship can leave at zero. Whenever is read as “variance explained,” the phrase means variance linearly associated with the single other variable, as elaborated under interpretation below.
Interpreting r
Interpretation through r²
The squared coefficient, , is the coefficient of determination: the proportion of the variance in that is linearly associated with variance in . An observed between a selection score and a job-performance measure, for instance, gives : nine percent of the variation in performance is associated with variation in the test score, and the remaining 91 percent is associated with other sources.
Two cautions frame this interpretation. First, is a descriptive proportion of linearly associated variance — it quantifies association, not a causal explanation, and “variance explained” is a figure of speech for that association, not a demonstrated mechanism. Second, squaring a non-extreme correlation shrinks its magnitude toward zero and can make a substantively useful predictor look negligible; report itself alongside .
Association is not causation
is symmetric in and — it contains no direction of influence — and an association between two measured variables may be produced by affecting , by affecting , by a third variable affecting both, or by design features of the study. No value of , however large, distinguishes these. Causal readings require design (randomization, longitudinal structure) and theory, not the coefficient; the role of correlation evidence within validity arguments is treated in validity.
Zero correlation is not independence
Uncorrelated means only that the linear component of the association is zero. If and are independent (with finite variances), then necessarily; but does not imply independence. Take any distribution symmetric about zero with a finite third moment and let : then , yet is a deterministic function of . The bivariate normal family is the standard exception — there, zero correlation and independence are equivalent — and that equivalence is a property of that family, not of correlation in general.
What r does not capture
- Outliers. Pearson’s is not resistant to outliers: a single extreme point can manufacture or destroy an apparent linear relationship. Because the coefficient gives no warning, inspect the scatterplot before trusting it, and consider robust alternatives when extreme observations are genuine.
- Nonlinearity. captures only linear structure. A curved relationship can yield a correlation near zero despite a strong systematic relationship; an inverted-U relation between test anxiety and examination performance is one example. A monotone but curved relation can be summarized with rank correlation. A nonmonotone relation should instead be modeled directly, for example with polynomial terms or a suitable transformation.
- Range restriction. Selection and restricted sampling distort the observed correlation — most familiarly attenuating it, as when only applicants above an admissions cutoff are observed, though the direction of the distortion depends on how the range was restricted. Correcting for restriction is treated in range restriction and selection corrections.
- Categorical and ordinal variables. is defined for quantitative variables. When one or both variables are dichotomous, the correlation is still meaningful but requires specialized formulas and interpretations — see correlations involving binary variables; ordinal variables are the natural home of the rank coefficients.
- Pooled groups. Combining samples that differ in location or spread can create or mask association within the combined data. Examine subgroups separately before pooling.
The scatterplot is the check for all five: shape (linearity, curvature), extreme points, the range actually covered, and whether the “variables” are in fact quantitative and single-population.
Inference for ρ
What the procedures assume
The procedures below are statements about the population correlation estimated by . They require:
- Independent pairs. The pairs are drawn independently from one bivariate distribution. Repeated measurements of the same persons, dyads or classrooms (clustered data), and serially correlated observations violate this: the effective sample size is smaller than , and the and Fisher procedures overstate precision.
- Bivariate normality of — the assumption under which the statistic has exactly a distribution and the Fisher approximation is derived. Bivariate normality entails normal marginals, a linear conditional mean of given , and a constant conditional standard deviation (see probability). Moderate departures matter little in large samples, but outliers and heavy tails destabilize itself.
- No distorting selection. The pairs observed are the pairs sampled: selection on either variable changes what estimates (range restriction).
Testing ρ = 0
Let denote the population correlation and the sample correlation from independent pairs. For the null hypothesis , the test statistic
follows a distribution with degrees of freedom under the null (assuming bivariate normality), and is referred to the family in the usual way — see hypothesis testing and t tests. One- or two-sided alternatives are handled as in any test.
This procedure tests zero only. It cannot be reused with a nonzero null value substituted in.
Nonzero nulls: the Fisher z transformation
When , the sampling distribution of is skewed, so the statistic above does not apply. Fisher’s variance-stabilizing transformation
is approximately normally distributed for bivariate normal data:
with the approximation accurate in moderate to large samples. To test with , compute
and refer to the standard normal distribution. The same machinery underlies the confidence interval logic of estimation, and itself serves as an effect size in many applications.
Worked example
Suppose from pairs, and the question is whether this is compatible with (two-sided). The transformed values are , , and , giving
with two-sided . The null hypothesis that is not rejected at conventional levels.
Confidence intervals by back-transformation
The interval procedure extends the test and is the preferred form for reporting:
- Transform the estimate: .
- Compute the standard error, , which does not depend on .
- Form the interval on the scale, ; for a 95% interval, .
- Back-transform both endpoints with : the interval for is .
Applying this to the worked example: , , and the margin is , so the -scale interval is . Back-transforming with gives the 95% interval
The interval sits asymmetrically around (it extends below and above), reflecting the skew of ‘s sampling distribution that the transformation exists to handle. It contains , consistent with the nonrejection above.
Two procedural notes
First, carry the transformation at full precision: rounding to two decimals before forming the statistic shifts it to about and the p-value to about — enough to matter when a result sits near a decision threshold. Second, failing to reject is not evidence that equals : a nonrejection means the data are compatible with the null value, and establishing approximate equality requires an equivalence-testing approach, not a failed significance test.
Correlation matrices
For variables, the pairwise correlations form a correlation matrix: ones on the diagonal, in cell . Every correlation matrix is positive semidefinite — it is the covariance matrix of the standardized variables — and a sample matrix computed from one common set of complete cases inherits this. A matrix built by pairwise deletion, where each correlation uses whichever pairs are complete for that variable pair, need not be positive semidefinite, a technical hazard for anything downstream that requires a valid covariance structure, such as factor models. Pairwise matrices of tetrachoric correlations carry the same hazard for a second reason; see correlations involving binary variables.
Correlation in measurement
Many classical summaries in measurement are correlations or functions of correlations, so the coefficient’s properties and pathologies propagate through the field:
- Item analysis. Item discrimination is summarized by item–total and item–rest correlations; for dichotomous items these are point-biserial correlations, with their own ceilings and conventions. The part–whole inflation of uncorrected item–total correlations and the screening rules built on them are treated in classical item analysis and correlations involving binary variables.
- Reliability. Test–retest and parallel-form designs estimate reliability as a correlation between two measurements; under classical test theory the reliability coefficient equals the correlation between parallel forms, and internal-consistency functions of the inter-item correlations are collected in internal consistency.
- Validity. Relations-to-other-variables evidence is largely correlational: the validity coefficient is the correlation between test scores and a criterion. Raw coefficients are attenuated by measurement error in both measures (the correction for attenuation) and distorted by selection in criterion samples (range restriction). Comparisons across instruments or studies should consider differences in reliability and selection; any corrections should be applied consistently, with assumptions stated and adjusted values reported alongside the observed coefficients.
- Latent structure. Factor analysis begins from the correlation (or covariance) matrix of the items; for binary and ordinal items the choice of coefficient determines what the matrix means (factor models and reliability).
An analysis workflow
- Plot first. Inspect the scatterplot — shape, extreme points, range covered — before computing anything, and plot subgroups separately if the sample mixes populations.
- Confirm the variable types. Both variables quantitative? Ordinal or dichotomous variables route to the rank or binary coefficients linked above.
- Check distorting conditions. Outliers, curvature, range restriction, and pooling are each handled or modeled deliberately, not discovered after the fact.
- Compute and on the data actually analyzed, reporting and how missing data were treated (listwise versus pairwise deletion, with the matrix caution above).
- For inference, verify independent pairs, then choose the procedure by the null: the statistic for ; the Fisher transformation for any other null and for intervals.
- Back-transform interval endpoints and report , , the confidence interval, and together.
- Interpret with the caveats attached: linear association, not causation; where measurement error or selection is present, correct before comparing coefficients across instruments or studies, and report corrections alongside the observed values.
Failure modes
- Reading as “no relationship”: curvature and dependence without correlation both hide structure from .
- Trusting without the scatterplot; a single outlier can manufacture or destroy the apparent linear relationship.
- Comparing correlations across samples with different ranges without selection corrections, or assuming restriction always attenuates (middle deletion can inflate — see range restriction).
- Substituting a nonzero null into the zero-null statistic.
- Rounding intermediate values inside the Fisher computation, shifting the statistic and p-value near thresholds.
- Interpreting a nonrejection as evidence that equals the null value.
- Applying the or Fisher procedures to dependent pairs — clustered, dyadic, or repeated-measures data — which overstates precision.
- Reporting only (which shrinks toward zero) or only (which invites the “variance explained” misreading).
- Treating “variance explained” as causal explanation.
- Applying Pearson’s to ordinal or binary data without the specialized coefficients’ ceilings and convention cautions.
Related notes
- Rank correlation — monotone association without linearity or distributional assumptions.
- Correlations involving binary variables — point-biserial, biserial, phi, and tetrachoric family members.
- Range restriction and selection corrections — how selection distorts and how to correct it.
- Classical item analysis — item-level use of correlations in test construction.
- Classical test theory — the error model behind attenuation and reliability-as-correlation.