I have a dataset of ~400 subjects. For each subject, I have about 18 variables (V1...V18), all of those continuous and measured at the same timepoint.

A paper I'm working on would benefit from showing that one of those variables (say V1) has a significant correlation with one of three other variables (say V2, V3, or V4) – all of these are measuring different aspects of the same illness. And I have found some significant correlations between the pairs (V1–V2, V1–V3, V1–V4). However, I have another variable, say V5, that is more strongly correlated to all of them (V1–V4). When I correct (linearly) for V5, the correlations between V1–(V2/V3/V4) is no longer significant/there.

So at this point, any critic could say that the V1 is correlated to V5, V5 is correlated to V2/3/4, and that I can't make the point I want to make. However, I have reason to believe that subgroups of the subjects (more susceptible to the illness), will show strong correlation between V1 and V2–4 that is independent of V5. Is there any way to find these subgroups?

I would like to find some partition(s), A < Vx < B, in which there is a significant correlation between V1 and V2/V3/V4, that I can show is independent of V5. Alternatively, if there's a way to quantify how much of the correlation between V1 and V2–4 is due to correlation between V1–V5 and how much is independent, that would be a good solution as well.

I have been reading a lot about two-way ANOVA, thinking about doing it between V1 as rows, V5 as columns, and one of V2–4 as outcome. But even if I do this (which would take significant effort, since I couldn't find a simple Python implementation), I'm not sure if it would advance me towards my goals. Any help is appreciated.

  • $\begingroup$ Sounds like a potential mediation problem. Might be worth performing the usual mediation analyses if V5 would make theoretical sense as a mediator. $\endgroup$ Commented Jun 22, 2014 at 23:59

1 Answer 1


I guess some procedure of blind search could be designed in order to test correlations in various partitions of your sample. Assume that you indeed find a sub-sample in which what you think must hold, appears to hold. What keeps me from attributing it to small-sample variability and reject it?

Nothing, except if the subjects in this subgroup have a set of characteristics that "separates" them from the other subjects, and justifies viewing them as a meaningful subset of the data.

And in your question, it appears that you do have a theoretical argument about your issue :"if subjects are more susceptible to the illness, then $V_2, V_3, V_4$ stop being uncorrelated with $V_1$ conditional on $V_5$."

So, instead of activating a blind mechanical search, wouldn't it be more valid (and probably less computationally intensive), to start by constructing a metric for the "susceptibility to illness" degree, then separate your sample according to this criterion, and then calculate, on the sub-samples acquired thus, correlations etc?

I cannot say whether you will get the results you think you should get, but I am certain that the results from such a procedure would be considered more scientifically acceptable.

On another aspect of your question, the Law of Total Covariance states that

$$\operatorname{Cov}(V_1,V_i)=\operatorname{E}\left[\operatorname{Cov}(V_1,V_i \mid V_5)\right]+\operatorname{Cov}\left[\operatorname{E}(V_1\mid V_5),\operatorname{E}(V_i\mid V_5)\right],\;\; i=2,3,4$$

The first component of the right-hand-side can be thought of as the "part" of covariance between $V_1$ and $V_i$ that is "independent of $V_5$" (in the sense of "what remains after conditioning on $V_5$").


To apply the Law of Total Covariance, one can calculate the second term of the right hand side.
1) Regress $V_1 = a+bV_5+u_{1,5}$ and obtain $\hat V_1 = \operatorname{\hat E}(V_1\mid V_5) $ (not the residuals)
2) Regress $V_i = c+dV_5+u_{i,5}$ and obtain $\hat V_i = \operatorname{\hat E}(V_i\mid V_5)$ (not the residuals)
3) Calculate the covariance of these two series

4) Subtract what you found in step 3) from $\operatorname{\hat Cov}(V_1,V_i)$ as it is calculated from the sample. The result is an estimate of the "independent from $V_5$" part of covariance between $V_1$ and $V_i$

  • $\begingroup$ Yes, it would be more valid / interesting to find such a metric and divide the samples intelligently. However, the evidence I have concerning subgroups come from a different experiment, and I can't deduce anything from it on the variables in question (that's why it would be so awesome to find something here - as these are two independent experiments). $\endgroup$
    – tktk
    Commented Jun 23, 2014 at 7:48
  • $\begingroup$ Regarding what you wrote on the law of total covariance - pardon my newbiness, can you direct me in how to actually apply this to the data? $\endgroup$
    – tktk
    Commented Jun 23, 2014 at 7:49
  • $\begingroup$ You write in your question: "when I correct linearly for V5 etc etc". How did you actually implement this "linear correction"? $\endgroup$ Commented Jun 23, 2014 at 14:11
  • $\begingroup$ def CorrectVectorBy(tocorrect, correctby): a, b, r, p, _ = linregress(correctby, tocorrect) return tocorrect - (a * correctby + b) $\endgroup$
    – tktk
    Commented Jun 23, 2014 at 17:19
  • $\begingroup$ I am not quick in deciphering man-machine language. Does this mean that you regressed, say $V_2 = a + bV_5$ and then calculated the correlation coefficient $Corr (V_1, \hat U_{2,5})$, where $\hat U_{2,5}$ are the residuals from said regression?? $\endgroup$ Commented Jun 23, 2014 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.