Motivating Scenario: You are digging deeper into your summaries of associations between two categorical variables.
Learning Goals: By the end of this subchapter, you should be able to:
Explain the intuition of the multiplication rule for independent events
Calculate and explain the covariance as a deviation from expectations under independence. Again you should be able to do this with basic math and with R code.
In the previous section we calculated UNCONDITIONAL (also known as marginal) proportions (n_case / n_total) of two binary categorical variables. Let’s call these proportions:
We can similarly calculate the UNCONDITIONAL proportion of white-petaled RILs and the joint probability of being both white AND visited (note, I also recalculate the proportion of visited plants):
A common quantification of the association between two binary variables is the covariance. This quantification follows some simple mathematical logic:
If two categorical variables, A & B are independent, the probability of observing both A and B (aka, \(P_{AB}\)) should equal the product of their unconditional probabilities: \[P_{AB \mid \text{independence}} = P_A \times P_B\]
The covariance is the deviation from this expectation: \[COV_{AB} = P_{AB} - P_A \times P_B\]
So for the association between petal color and being visited, the covariance is:
\[COV_{\text{visited, pink}} =P_{\text{visited and pink}} - P_{\text{visited}} \times P_{\text{pink}}\]
Alternatively, R can calculate the covariance with the cov() function. This only works if the values are numbers or logical (TRUE [1] / FALSE [0]). Note the slight mismatch between our calculation due to “Bessel’s correction” (see fyi box, below).
Our answers differ slightly from one another. We used a denominator of \(n\) (which calculates the population covariance), while the sample covariance has a denominator of \(n-1\) (this is known as Bessel’s correction). We will soon see that although the latter is more appropriate – their difference is negligible when n is large. We can convert the population covariance to the sample covariance by multiplying by \(\frac{n}{n-1}\). See the next section for a discussion of the difference between population parameters and sample estimates.
From covariance to correlation
Covariance gives us a numerical measure of how far our data deviate from what we’d expect under independence. In this case, the value is 0.10. But is a covariance of 0.10 big or small? A covariance on its own provides no clue of its strength.
We can convert a covariance to an effect size, known as a correlation (or r). r describes both the strength and sign of the association between variables:
An absolute value of r close to 1 means that x almost perfectly predicts y, while a value close to zero means x has no information about y.
The sign of r describes if x and y increase (\(r > 0\)), or decrease (\(r <0\)) with one another.
We can find r by dividing the covariance by the product of standard deviations:
\[r_{x,y}= \frac{cov_{x,y}}{s_x s_y}\]
We have previously seen the equation for a standard deviation: \[s_x = \sqrt{\frac{\sum{(x_i-\bar{x})^2 }}{n-1}}\]
For a binary variable, this equation is approximately \(s_x=\sqrt{p_x (1-p_x)}\) (ignoring Bessel’s correction).
As in Cohen’s D, what is a “large” or “small” correlation coefficient depends on the study, the question and the field of study, but there are rough guides (see below). So our observed correlation between petal color and being visited by a pollinat 0.45 is large.
Size
Range of \(\lvert r \rvert\)
Not worth reporting
< 0.005
Tiny
0.005 – 0.10
Small
0.10 – 0.20
Medium
0.2 – 0.35
Large
0.35 – 0.50
Very large
0.50 – 0.75
Huge
\(> 0.75\)
Applications to population genetics:
Two population genetic summaries tend to confuse genetics students – deviations from Hardy-Weinberg Equilibrium, and Linkage Disequilibrium. Both can be naturally considered as covariances between two binary variables.
Hardy-Weinberg Equilibrium (HWE)
The Hardy-Weinberg Equilibrium principle states that under numerous assumptions – which essentially ensure that an individual’s two alleles at a locus are chosen independently – genotypes at a locus are simply two random samples of alleles from a population,
Genotype frequencies should be \(p^2\), \(2p(1-p)\), and \((1-p)^2\)
Where \(p\) is the frequency of one allele, A, at a locus.
We can think of this as a covariance between alleles inherited from mom and dad at the same locus.
So \(p^2\) is actually \(p_\text{A maternal} \times p_\text{A paternal}\).
The deviation from HWE, \(F\), is simply the difference between the observed frequency of homozygotes (\(p_\text{AA} = p_\text{A maternal,A paternal}\)) and their expected frequency, \(p^2\). So \(F = p_\text{AA}- p_A^2\).
Linkage Disequilibrium (LD)
Linkage disequilibrium quantifies the statistical association between alleles at different loci. The most standard quantification of linkage disequilibrium is \(D = Cov(A,B) = p_{AB} - p_A p_B\). Where A and B are alleles at two different loci. Although usually quantified as a covariance, other measures of LD include a correlation in allele frequencies between loci.