Grouped Pearson Correlation & Simpson’s Paradox Calculator

Paste pairs with group names. See Pearson r for the pooled data, each group and all group-centered pairs. Separate within-group and between-group cross-products to understand the role of group averages.

Grouped data analysis

Check whether pooling reverses correlation

Grouped observations

Enter group name, x and y on each line, separated by commas or tabs. Repeat the same group name for its other observations.

Every group’s correlation reverses direction when the data are pooled.

Correlation with and without group centering

Pooled Pearson r
-0.83569117
Group-centered Pearson r
1

Scatter and cross-products

Scatter of all entered observationsSelected pair 1 in A lies at x 1 and y 7. Pooled correlation -0.83569117.Observed xObserved y
  • A
  • B
  • Pooled fit

Pair 1 · A

Observed x
1
Observed y
7
Centered x
-1
Centered y
-1

Cross-product decomposition

The within-group and between-group sums add to the pooled sum.

Within groups
4
Between means
-45
Pooled total
-41

Coefficients by group

2 of 2 groups have defined coefficients.

  • A

    3 pairs · Pearson r 1

    Mean x 2 · Mean y 8

  • B

    3 pairs · Pearson r 1

    Mean x 7 · Mean y 2

Export the grouped correlation worksheet

Save the entered pairs, centered pairs and exact covariance components.

View CSV text

How to use this calculator

  1. Paste each row as group name, x and y. Use the same spelling for observations in one group.
  2. Compare the pooled coefficient, the coefficient after group centering and each group’s coefficient.
  3. Switch between pooled points, group-centered points and the cross-product components. Use the pair slider to inspect the raw and centered values.
  4. Download exact centered sums, group means, coefficient signs and squared values and all observed and centered pairs as CSV.

The Formula

The mathematical logic powering this calculation is:

For any set of pairs, Sxy = Σ(x−x̄)(y−ȳ), Sxx = Σ(x−x̄)² and Syy = Σ(y−ȳ)². Pearson r = Sxy/√(Sxx Syy) when both squared sums are positive. The pooled calculation centers on the grand means. For the group-centered calculation, subtract each pair’s own group means and combine those deviations. Group-centered r uses the summed within-group products, so it can differ from the average of the individual correlations.

The pooled cross-product is the sum of the within-group cross-product and the between-group cross-product. The between-group term is Σ n_g(x̄_g−x̄)(ȳ_g−ȳ) across groups g with count n_g. The same decomposition applies to squared x and y deviations. Since deviations sum to zero inside each group, the mixed terms vanish. Dividing the cross-product components by total count minus one gives additive contributions to the pooled sample covariance.

The tool identifies a uniform reversal when the pooled correlation and every defined group correlation have opposing nonzero signs and every group has a defined r. If the combined group-centered coefficient reverses the pooled direction without all groups meeting that condition, the result labels only the combined reversal. Constant variables and groups with a single pair have undefined group coefficients.

Enter 2–48 signed decimal pairs across two to six distinct names, with a consistent unit for each column. Values use up to six decimal places between −1 billion and 1 billion. Group names start with a letter or digit and can include spaces, underscores or hyphens up to 24 characters. Arithmetic uses exact fractions through the centered products and squared r. The displayed magnitude of r uses a numerical square root. The worksheet describes the supplied data.

Worked Example

If you input:

  • A: (1, 7), (2, 8), (3, 9)
  • B: (6, 1), (7, 2), (8, 3)

Result:

Both groups have r = +1, and the group-centered coefficient is also +1. The pooled r is about −0.836. The within-group cross-product 4 and the between-group term −45 sum to −41.

Frequently Asked Questions

Why can two positive group correlations give a negative pooled correlation?

The group means may move in a different direction from the observations within groups. The negative between-group cross-product can outweigh the positive within-group contribution.

Is the group-centered coefficient an average of the group coefficients?

It combines each group’s centered x and y deviations and computes one coefficient from them. Group size and the scale of deviations both influence the result.

Why is a group correlation undefined?

Pearson r needs positive variation in both variables. A single observation or a constant coordinate gives a zero denominator.

Does a reversal decide which coefficient to use?

The relevant coefficient depends on what comparison is meaningful. A pooled coefficient describes the combined population represented by the rows. Centering describes how observations move relative to their own group means.

Can I compare labels with spaces or accents?

Yes. Names can start with a letter or digit and can contain letters, digits, spaces, underscores or hyphens. Names are matched exactly after trimming outside whitespace.

Similar Calculators