# R: Test significance of difference in slopes of same correlations in different groups

Say I have two groups of observations A and B. Each group contains the SAME two set of observations a_1,a_2 and b_1,b_2. For group A, I estimate how well a_1 and a_2 are correlated by computing Spearman's Correlation Coefficient between a_1 and a_2 and likewise for group B. How do I assess the magnitude of the difference?

E.g. think of it this way: Group A is women and group B is men. a_1 is weight and so is b_1. Likewise a_2 and b_2 are heights. How do I asses sif there is a significant difference in how weight and height are connected in men and women?

I guess it comes down to assuming linearity and then constructing and comparing two linear models, one for men and one for women?

You should rather construct one linear model, containing the sex and the height as explanatory variables plus their interaction. (The response being the weight.) Then, the significance of the interaction term tells you whether there is a ''difference in how weight and height are connected in men and women''. (Given, of course, the model is diagnostically correct.)

In R:

 summary( lm( Weight ~ Height * Sex, data = YourData ) )


and then look for the Height:Sex term.

• Thanks for the input, I have been suggested to take a closer look at this site for comparing the two Spearman's Correlation Coefficients: quantpsy.org/corrtest/corrtest.htm I'm not sure exactly how to 'attack' this question though...? – LeonDK Mar 16 '15 at 13:04
• @LeonDK : The regression approach I suggested generalizes the Pearson (linear) correlation coefficient. That link pertains to Spearman's correlation coefficient. You should decide whether it is acceptable to use linear correlation in your particular problem - if so, then I believe my suggestion should work. – Tamas Ferenci Mar 16 '15 at 13:19
• Note that Spearman correlation could be the same for quite different relationships, and different for the same underlying relationship. – Nick Cox Mar 16 '15 at 13:22
• You can also see the related answer posted here: stats.stackexchange.com/questions/141325/… – Jordan Collins Mar 16 '15 at 13:28
• @tamas-ferenci : How do I "...decide whether it is acceptable to use linear correlation in your particular problem"? I should probably add, that I will be comparing in the neighbourhood of 1,000,000 correlations in group A vs. group B... – LeonDK Mar 16 '15 at 18:16

The question here should be turned around. Consider

1. I am interested in (e.g.) the relationship between height and weight for men and women.

2. A linear model is one way to approach this.

3. Spearman correlation is a descriptive method that could be used.

Point 1 really is primary here statistically just as it should be scientifically.

Then in point 2 linearity (whether linearity in variables or linearity in parameters) is something to be checked, rather than assumed, but there are easy graphs to help as well as formal tests.

On point 3, Spearman correlation has its uses, but they do not loom large here. You will find formal ways of comparing correlations but they won't really illuminate point 1.

• Thanks for the input. I'm not studying height and weight in men and women, that was purely for illustrative purposes :-) – LeonDK Mar 16 '15 at 13:10
• OK; answer edited accordingly. – Nick Cox Mar 16 '15 at 13:20
• I am interested in identifying if the height-weight relationship is DIFFERENT between men and women and if so HOW different. I.e. I 'need' a p-value quantifying how DIFFERENT the Men:height-weight relationship is compared to women:heigh-weight - Make sense? – LeonDK Mar 16 '15 at 18:22
• @Tamas Ferenci has addressed this. You need to translate "different relationship" into a hypothesis about parameter values, just as answering a question in ordinary conversation of whether men and women are similar or different demands a precise criterion (or is meaningless otherwise). Even with simple linear relationships, intercepts may differ, slopes may differ, etc. – Nick Cox Mar 16 '15 at 20:00