27 / Predictive analytics
Correlation and association
Correlation summarises association between paired measurements. Pearson’s coefficient measures linear co-movement, while Spearman’s coefficient uses ranks to describe monotonic association. Both can help investigate business relationships, but neither by itself explains causation or proves that changing one variable will change the other.
The business question
Do two business measurements move together, and what can that pattern legitimately tell us?
- Explore relationships between demand, staffing, waiting time and output.
- Screen candidate predictors before building a forecasting or regression model.
- Check whether several dashboard indicators are largely describing the same pattern.
How the method works
Each observation needs an x value and a y value describing the same relevant unit or period. Pearson’s correlation standardises their covariance by both standard deviations. The result lies between −1 and +1: a positive value indicates that larger x values tend to accompany larger y values, and a negative value indicates opposite linear movement.
Standardisation removes units from the coefficient. That makes association strengths easier to compare, but it also means r cannot tell a manager how many rand of revenue correspond to one additional rand of advertising. A near-zero Pearson value rules out neither a curved relationship nor a useful relationship within customer subgroups. A scatter plot and the original units remain essential.
Spearman’s coefficient applies a correlation calculation to ranks and can capture a consistently increasing or decreasing relationship that is not straight. Ties and sample size influence its inference. For Pearson’s conventional significance test, independence and the specified null-distribution assumptions matter. Trending time series can produce impressive correlations simply because both move over time.
The calculation
| Symbol | Meaning |
|---|---|
| r | Pearson sample linear correlation. |
| ρ | Spearman sample rank correlation in this module. |
| x_i, y_i | Measurements paired on the same observational unit. |
| mean_x, mean_y | Sample averages used to centre each measurement. |
A worked business example
ILLUSTRATIVE SCENARIO
Illustrative monthly advertising spend and revenue for a small retailer, both measured in thousands of rand.
Inputs
- Advertising spend: 1, 2, 3, 4, 5, 6.
- Revenue: 7, 9, 10, 13, 12, 16.
- Six paired months; use these values as an arithmetic illustration, not an adequate marketing study.
Work through the numbers
- The sample means are 3.5 and approximately 11.1667.
- The centred cross-product sum is 28.5; the centred sums of squares are 17.5 and approximately 50.8333.
- Pearson r = 28.5/√(17.5×50.8333) ≈0.9555.
- Spearman rank correlation is approximately 0.9429; Pearson’s conventional two-sided p-value is about 0.002920.
Six months of co-movement do not establish an advertising return. Seasonality, store growth, discounts or higher budgets in already busy months could explain the pattern. The coefficient is not a percentage sales increase or an ROI.
Explore the decision
Explore linear and rank association. The live explorer has its own example inputs; it is separate from the worked calculation above.
Enable JavaScript to use this calculator. The worked example and executable Python remain available.
Apply it at work
- Define the unit, period, relevant population and timing of both variables.
- Plot the paired observations and check missing values, unusual points, subgroups and time trends.
- Choose a coefficient that matches the association question and report sample size with any interval or test.
- Use the relationship to form a prediction model or controlled business experiment rather than assuming a causal lever.
Check these assumptions
- Pairs are correctly aligned and measured on appropriate numerical or ordered scales.
- Independent pairs are needed for ordinary significance calculations; repeated or time-dependent observations require adjustment.
- Pearson’s coefficient is most informative for linear patterns; Spearman’s targets monotonic ordering.
- The sample has enough variation and is not dominated by recording errors, selected ranges or one extreme point.
Common mistakes and how to avoid them
- Correlation between two rising business series can be driven by time rather than a useful direct relationship.
- Combining different customer groups can hide or reverse within-group patterns.
- Treating r² as a causal explanation or r as a return percentage misstates what was calculated.
How this can help the business
- An operations analyst can identify relationships worth modelling while avoiding duplicated dashboard measures.
- A manager can use a plausible association to design an experiment before spending money on the presumed cause.
Use correlation as a diagnostic and modelling clue. Require a suitable design and an economic mechanism before treating the relationship as an intervention target.
When to use another approach
Use scatter plots, partial or regression analysis for covariates, time-series methods for dependence, or randomised experiments for causal questions.
Reproduce the worked example in Python
The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.
Show executable code and recorded output
import numpy as np
from scipy import stats
spend = np.array([1,2,3,4,5,6])
revenue = np.array([7,9,10,13,12,16])
pearson = stats.pearsonr(spend, revenue)
spearman = stats.spearmanr(spend, revenue)
print("Pearson r and p:", round(pearson.statistic, 4), round(pearson.pvalue, 6))
print("Spearman rank correlation:", round(spearman.statistic, 4))Recorded output
Pearson r and p: 0.9555 0.00292 Spearman rank correlation: 0.9429
Sources and further reading
Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.