Balancing gender in an experiment Say a study aims to see if two variables A and B are correlated in the general population. It isn't clear to me how extraneous variables like gender should be treated when the sample is selected. Each of the two methods of "controlling" for gender that I am aware of (see below) seems non-ideal, so is it a case of selecting the "least unideal" one for the study at-hand?
1) You only use subjects of one gender, because you don't want gender to even exist as a variable. Surely then, any effect you find is vulnerable to the doubt that perhaps it only exists in that gender but not in the other?
2) You use 50% males and 50% females and thus claim that the effect exists in the general population because it exists in your gender-matched sample. Surely though, what you have proved then is an effect that exists when averaging across genders, and thus may even be an effect that perhas doesn't exist when looking within each gender separately.
It seems to me that even if gender effects are not of interest, if an interaction between gender and the independent variable exists, it still needs to be decomposed (broken up), such that potentially, the effect remains in only one gender but not in the other. Method 1) doesn't know what might be happening in the case of the other gender while method 2) averages together what could well be two very different effects, thus possibly either masking two individually-existing effects or creating an artificial effect that does not exist in each gender individually.
Confusing! Help please?
 A: The law of total covariance says:
\begin{align}
Cov(A,B) &= E_G\{Cov(A,B)|G\} + Cov_G(E\{A|G\},E\{B|G\}) 
\end{align}
In your application, the conditioning variable is G, gender.  There are two terms.  The first term is sometimes called the within term.  It is easy to understand.  If $A$ and $B$ are correlated within the population of men and are also correlated within the population of women, then it seems reasonable that $A$ and $B$ should be correlated in the overall population according to an average of these two covariances.  This is what the first term says.  It is the average of the covariance, within men, between $A$ and $B$ and the covariance, within women, between $A$ and $B$.  You would calculate:
\begin{align}
E_G\{Cov(A,B)|G\} &= P\{G=Male\} \cdot Cov(A,B|G=Male)\\ 
                  &+ P\{G=Female\} \cdot Cov(A,B|G=Female)
\end{align}
The two covariances within each gender you can calculate with your data.  If you are thinking
of a target population which is 50\% male and 50\% female, then you just set the two probabilities that way.  If you are wanting to describe your sample, then you set the two probabilities according to how they are in your sample.
But, there is the second term, the between term (or the "composition effects" term).  Even if $A$ and $B$ are uncorrelated within men and uncorrelated within women, they may be correlated in the overall population.  How?  Maybe $A$ is higher among men and $B$ is higher among women.  This would give a negative correlation between the two.  Anyway, calculate this second term as (abbreviating male as $M$ and female as $F$):
\begin{align}
Cov_G(E\{A|G\},E\{B|G\}) &= E\{A|G=M\} \cdot E\{B|G=M\} \cdot P\{G=M\} \\
                         &+  E\{A|G=F\} \cdot E\{B|G=F\} \cdot P\{G=F\} \\
&-\left(E\{A|G=M\}P\{G=M\}+E\{A|G=F\}P\{G=F\}\right) \cdot \left(E\{B|G=M\}P\{G=M\}+E\{B|G=F\}P\{G=F\}\right)
\end{align}
So, to decompose a population covariance using gender as a conditioning variable, you are going to break up the population covariance into three pieces---ie the population covariance is going to be the weighted sum of three pieces:


*

*The covariance between $A$ and $B$ among males 

*The covariance between $A$ and $B$ among females

*The covariance coming from any average differences between $A$ and $B$ between males and females

A: Asking if there's a correlation, and asking about the origin of that correlation are different.  There's a (negative) correlation in the population between hair length and height. That's because of gender - women have longer hair (on average), women are shorter (on average). 
The fact that this is correlation is because both are causally related to gender is irrelevant to whether or not there's a correlation.
