# A visual explanation regarding a generalised Pearson's correlation for two variables

This is a textbook exercise that might be seen as a generalisation of Pearson's product-moment correlation coefficient between two variables, with multiple groups each having variable sizes:

Let there be $$k$$ groups of data of size $$n_j$$ on two variables $$(x,y)$$, with means $$(\bar x_j,\bar y_j)$$, variances $$(s_{xj}^2,s_{yj}^2)$$, and correlation coefficient $$r_j$$; $$j=1,2,\ldots,k$$. Then the correlation coefficient of the combined data of size $$\sum_{j=1}^kn_j$$ is given by

$$r=\frac{\sum_{j=1}^kn_jr_js_{xj}s_{yj}+\sum_{j=1}^k n_j(x_j-\bar x)(y_j-\bar y)}{\sqrt{\sum_{j=1}^kn_js_{xj}^2+\sum_{j=1}^kn_j(\bar x_j-\bar x)}\sqrt{\sum_{j=1}^kn_js_{yj}^2+\sum_{j=1}^kn_j(\bar y_j-\bar y)}}\quad,$$

where $$\bar x$$ and $$\bar y$$ are the grand means of $$x$$ and $$y$$ respectively.

The exercise also asks to explain from the above formula that $$r_j$$ may be zero for each $$j$$ and yet $$r$$ may be non-zero

While I am not that interested in an analytical derivation of the above expression, I would like to have an intuitive understanding of the fact that the individual correlations may vanish and still the overall correlation may be non-zero. But I am not looking for this verification from the formula. Is there a visual explanation that one can come up with?

By the way, is there a particular name for $$r$$ as defined above? Any reference where this shows up in descriptive statistics will be great.

• The $r$ defined above is just the ordinary Pearson correlation computed from $x$ and $y$ across all the groups. So it isn't a generalisation and it doesn't have a special name. Commented Aug 5, 2018 at 10:26