Correlation, confounding, and practical interpretation

Measure a relationship and check how outliers, subgroup mix, and study design affect the claim.

On this page

Choose a measure and inspect the data

Pearson correlation measures linear association. Spearman correlation uses ranks and can describe a monotonic but nonlinear relationship. Look at a scatter plot, check constant variables and outliers, and use rows where both values are available.

from scipy.stats import pearsonr, spearmanr

x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
print(round(float(pearsonr(x, y).statistic), 2))
print(round(float(spearmanr(x, y).statistic), 2))
Example output
0.98
1.0

Check other explanations

A relationship between promotions and sales can reflect season, store size, or product mix. Compare relevant subgroups and document limits before making a causal claim. A randomized design or another justified causal method is needed to estimate effects in many settings.

Official references