Tutorials › VEE Mathematical Statistics › Covariance of Indicator Variables

VEE Mathematical Statistics · Covariance and Correlation · Tutorial 319 of 880

Covariance of Indicator Variables

Learn how event probabilities determine the covariance of their indicators and what positive, zero, and negative values say about the events.

Intermediate 10 min read

What You'll Learn

  • Define an indicator random variable and find its expectation and product with another indicator.
  • Derive covariance from the probability of the intersection of two events.
  • Determine the sign of covariance by comparing the intersection probability with the independence baseline.
  • Check whether proposed marginal and intersection probabilities are feasible.
  • Distinguish independence of two events from zero covariance for arbitrary random variables.

Why Event Indicators Have a Useful Covariance Formula

Many questions about dependence begin with two yes-or-no outcomes: whether a test is positive, whether a claim exceeds a threshold, or whether a specified event occurs. Replacing each yes-or-no outcome with an indicator turns it into a random variable, so covariance can summarize whether the two events tend to occur together more or less often than their marginal probabilities alone would suggest.

The key calculation is short, but its interpretation depends on keeping three probabilities distinct: the probability of the first event, the probability of the second event, and the probability that both events occur. The intersection probability is what determines the covariance once the marginal probabilities are fixed.

Definition: For an event \(A\), its indicator random variable is \(I_A\), defined by \(I_A=1\) when \(A\) occurs and \(I_A=0\) when \(A\) does not occur. For events \(A\) and \(B\), write \(p=P(A)\), \(q=P(B)\), and \(r=P(A\cap B)\). Then \(I_A I_B=1\) exactly when both \(A\) and \(B\) occur, and is zero otherwise.

An indicator is bounded, so its expectation and variance are finite. In fact, \(E[I_A]=p\) and \(\operatorname{Var}(I_A)=p(1-p)\). More generally, covariance is defined when \(E[|X|]\), \(E[|Y|]\), and \(E[|XY|]\) are finite; finite second moments are a common sufficient condition. For indicators these requirements hold automatically.

Deriving Covariance from the Intersection Probability

Use the covariance shortcut \(\operatorname{Cov}(X,Y)=E[XY]-E[X]E[Y]\), which applies when the relevant expectations are finite. For indicators, the product \(I_A I_B\) is itself the indicator of the intersection \(A\cap B\). Therefore its expected value is the probability of that intersection.

$$ E[I_A]=p,\qquad E[I_B]=q,\qquad E[I_A I_B]=P(A\cap B)=r. $$

Substituting these three expectations into the shortcut gives the result:

Theorem: For any two events \(A\) and \(B\), the covariance of their indicators is
$$ \operatorname{Cov}(I_A,I_B)=P(A\cap B)-P(A)P(B)=r-pq. $$

This identity explains the interpretation of the sign. If \(A\) and \(B\) were independent, the probability of both would be \(pq\). Thus covariance compares the actual intersection probability \(r\) with that independence benchmark. It does not say that one event causes the other.

1
Find the marginals.
Calculate \(p=P(A)\) and \(q=P(B)\).
2
Find the intersection.
Calculate \(r=P(A\cap B)\), using a joint probability or a conditional probability together with its conditioning probability.
3
Compare with the independence benchmark.
Calculate \(pq\), then subtract: \(\operatorname{Cov}(I_A,I_B)=r-pq\).
4
Interpret the sign.
A positive result means \(r>pq\); a negative result means \(r<pq\); and zero means \(r=pq\).

Sign, Independence, and Feasible Probabilities

For indicators, zero covariance has a particularly precise interpretation. Two events are independent exactly when \(P(A\cap B)=P(A)P(B)\). By the covariance formula, this is exactly the condition \(\operatorname{Cov}(I_A,I_B)=0\). This equivalence applies to the two indicators of these events; it should not be extended to arbitrary random variables, for which zero covariance does not in general imply independence.

$$ \begin{aligned} \operatorname{Cov}(I_A,I_B)>0 &\iff r>pq,\\ \operatorname{Cov}(I_A,I_B)=0 &\iff r=pq \iff A\text{ and }B\text{ are independent},\\ \operatorname{Cov}(I_A,I_B)<0 &\iff r<pq. \end{aligned} $$

The marginal probabilities also restrict which intersection probabilities are possible. Since the intersection is contained in each event, \(r\leq \min(p,q)\). And since \(P(A\cup B)=p+q-r\leq 1\), we have \(r\geq p+q-1\). Probabilities cannot be negative, so the complete bounds are:

$$ \max(0,p+q-1)\leq r\leq \min(p,q). $$

These bounds are useful checks before interpreting a covariance. For example, if \(p=0.30\) and \(q=0.40\), then the lower bound is \(\max(0,0.30+0.40-1)=\max(0,-0.30)=0\), and the upper bound is \(0.30\). An intersection probability of \(0.18\) is feasible because it lies between \(0\) and \(0.30\).

If \(p=0\) or \(p=1\), the indicator \(I_A\) is constant and its covariance with any indicator is zero. In the \(p=0\) case, any conditional probability given \(A\) is undefined, so do not use a conditional-probability formula that conditions on this event. The intersection formula \(r-pq\), however, remains valid.

Worked Example: Comparing Joint Occurrence with Independence

In a hypothetical group study, let \(A\) be the event that a participant completes a follow-up survey, and let \(B\) be the event that the participant attends a review session. Suppose \(P(A)=0.30\), \(P(B)=0.40\), and \(P(A\cap B)=0.18\). Find the covariance of the indicators, interpret its sign, and calculate the probability that exactly one event occurs.

Method and assumptions. Treat a participant selected at random from this study group as the outcome. The given values are the event probabilities for this selection. Use the indicator covariance formula; no independence assumption is made.

Step 1: Check the intersection probability. The feasible range is \( \max(0,0.30+0.40-1)=\max(0,-0.30)=0 \) to \( \min(0.30,0.40)=0.30 \). The stated value \(0.18\) is in this range.

Step 2: Find the independence benchmark. \(P(A)P(B)=0.30(0.40)=0.12\).

Step 3: Calculate covariance. \( \operatorname{Cov}(I_A,I_B)=0.18-0.12=0.06. \) The covariance is positive: both events occur together with probability \(0.18\), which is greater than the \(0.12\) that would apply if the events were independent.

Step 4: Calculate the probability of exactly one event. The events “\(A\) only” and “\(B\) only” are disjoint. Their probabilities are \(0.30-0.18=0.12\) and \(0.40-0.18=0.22\), respectively. Thus the probability of exactly one is \(0.12+0.22=0.34\). As a check, \(P(A\cup B)=0.30+0.40-0.18=0.52\), and exactly one has probability \(P(A\cup B)-P(A\cap B)=0.52-0.18=0.34\).

Common mistake avoided. The lower bound is not \(0.30+0.40-1=0\): that arithmetic equals \(-0.30\). The correct lower bound is the maximum of that value and zero, namely \(\max(0,-0.30)=0\).

Using Conditional Probabilities to Find the Intersection

Sometimes the intersection is not supplied directly. If \(P(A)>0\), the definition of conditional probability gives \(P(A\cap B)=P(A)P(B\mid A)\). The covariance can then be found by first calculating the intersection. If information is given for both \(A\) and its complement, the law of total probability can be used to find \(P(B)\) as well.

Worked Example: Finding Covariance from Conditional Rates

In a hypothetical screening program, \(A\) is the event that a participant has a specified risk factor and \(B\) is the event that a follow-up flag is recorded. Suppose \(P(A)=0.60\), \(P(B\mid A)=0.25\), and \(P(B\mid A^c)=0.55\). Calculate the covariance of the indicators and interpret it.

Method and assumptions. Take one participant selected at random from the program. Both conditioning events have positive probability: \(P(A)=0.60\) and \(P(A^c)=0.40\). Apply the conditional probability definition and the law of total probability.

Step 1: Calculate the intersection. \(P(A\cap B)=P(A)P(B\mid A)=0.60(0.25)=0.15\).

Step 2: Calculate the marginal probability of \(B\). \(P(B)=P(A)P(B\mid A)+P(A^c)P(B\mid A^c)\). Substitution gives \(P(B)=0.60(0.25)+0.40(0.55)=0.15+0.22=0.37\).

Step 3: Check feasibility. The lower bound is \(\max(0,0.60+0.37-1)=\max(0,-0.03)=0\); the upper bound is \(\min(0.60,0.37)=0.37\). The intersection probability \(0.15\) is feasible.

Step 4: Calculate and interpret covariance. The independence benchmark is \(P(A)P(B)=0.60(0.37)=0.222\). Therefore \(\operatorname{Cov}(I_A,I_B)=0.15-0.222=-0.072\). The negative sign says that the events occur together less often than their marginal probabilities would predict under independence. Here the conditional probability of the flag is lower among participants with \(A\) than among those without \(A\), consistent with that negative sign.

Common mistake avoided. The supplied value \(P(B\mid A)=0.25\) is not the intersection probability. Multiplying by \(P(A)=0.60\) is essential; using \(0.25\) directly in the covariance formula would give the wrong result.

Reading Covariance from a Joint Table

A joint table gives the probability of each combination of event outcomes. For indicators, only the cell where both events occur contributes to \(E[I_A I_B]\), but the marginal probabilities must still be calculated from all cells in which the corresponding event occurs.

Worked Example: Indicators from a Two-Way Count Table

A hypothetical research team classifies 200 participants according to whether they completed a second assessment (\(A\)) and whether they used a reminder tool (\(B\)). The counts are 54 for both, 36 for \(A\) only, 26 for \(B\) only, and 84 for neither. A participant is selected uniformly from these 200. Find the indicator covariance and correlation, and check the covariance using the centered-product definition.

Method and assumptions. The four counts are mutually exclusive and exhaustive, and uniform selection makes each count divided by 200 its corresponding probability.

Step 1: Convert counts to probabilities. \(P(A\cap B)=54/200=0.27\). The total in \(A\) is \(54+36=90\), so \(P(A)=90/200=0.45\). The total in \(B\) is \(54+26=80\), so \(P(B)=80/200=0.40\). The four probabilities sum to \(0.27+0.18+0.13+0.42=1\), as required.

Step 2: Calculate covariance. \(P(A)P(B)=0.45(0.40)=0.18\), so \(\operatorname{Cov}(I_A,I_B)=0.27-0.18=0.09\). Since \(0.27>0.18\), the two events occur together more often than the independence benchmark predicts.

Step 3: Check using centered products. The four cell probabilities are \(0.27,0.18,0.13,0.42\) for both, \(A\) only, \(B\) only, and neither. In those cells, the centered products \((I_A-0.45)(I_B-0.40)\) are \(0.33,-0.22,-0.27,0.18\), respectively. Their probability-weighted sum is \(0.27(0.33)+0.18(-0.22)+0.13(-0.27)+0.42(0.18)\) \(=0.0891-0.0396-0.0351+0.0756=0.0900\), matching the shortcut result.

Step 4: Calculate correlation. Both indicators have nonzero variance, so their correlation is covariance divided by the product of their standard deviations. Their variances are \(0.45(0.55)=0.2475\) and \(0.40(0.60)=0.24\). Thus \(\operatorname{Corr}(I_A,I_B)=0.09/\sqrt{0.2475(0.24)}=0.09/\sqrt{0.0594}\approx0.3693\), rounded to four decimal places. This positive value is consistent with the positive covariance.

Common mistake avoided. The joint probability \(0.27\) is not either marginal probability. For \(P(A)\), add the “both” and “\(A\) only” cells; for \(P(B)\), add the “both” and “\(B\) only” cells.

Common Exam Traps and Practical Interpretation

The formula is simple enough that most errors come from misreading the probabilities or making an invalid interpretation. In a question using conditional rates, identify the conditioning event carefully. In a table, calculate each marginal from the correct row or column totals. Before accepting a joint probability, verify that it satisfies the feasible bounds.

  • Confusing joint probability with a product. \(P(A\cap B)\) is the actual probability of both events; \(P(A)P(B)\) is the independence benchmark. They are equal only when the events are independent.
  • Using a conditional probability as the intersection. If \(P(A)>0\), convert \(P(B\mid A)\) to \(P(A\cap B)\) by multiplying by \(P(A)\).
  • Reversing the sign interpretation. A positive covariance means the actual intersection exceeds \(pq\), not that it falls below \(pq\).
  • Claiming too much from zero covariance. For two indicators, zero covariance does imply that the events are independent. For general random variables, that implication does not hold without additional assumptions.
  • Ignoring degeneracy when using correlation. If either event has probability zero or one, its indicator has zero variance, so the correlation is undefined even though the covariance is defined and equals zero.

For a two-event question, the most reliable summary is to state the covariance and then compare \(r\) with \(pq\) in context. This makes the numerical sign meaningful and keeps the interpretation tied to the actual event probabilities.

Key takeaway: The covariance of two event indicators is the actual probability of their intersection minus the product of their marginal probabilities. Its sign tells whether the events occur together more often, equally often, or less often than under independence; for indicators, zero covariance is equivalent to independence of the two events.

Check Your Understanding

For each problem, calculate or interpret the indicator covariance using the stated event probabilities. Answers are provided at the end of each question.

  1. For events \(A\) and \(B\), suppose \(P(A)=0.20\), \(P(B)=0.50\), and \(P(A\cap B)=0.14\). Check feasibility, calculate covariance, and state whether the events are independent. (Answer: Feasible range \([0,0.20]\); covariance \(0.0400\); not independent.)
  2. Suppose \(P(A)=0.70\), \(P(B\mid A)=0.30\), and \(P(B\mid A^c)=0.60\). Find \(P(B)\), \(P(A\cap B)\), and the covariance. (Answer: \(P(B)=0.3900\), \(P(A\cap B)=0.2100\), covariance \(=-0.0630\).)
  3. In a hypothetical sample of 100 people, the counts are 24 for both \(A\) and \(B\), 16 for \(A\) only, 26 for \(B\) only, and 34 for neither. Calculate the two marginals, the covariance, and the probability exactly one event occurs. (Answer: \(P(A)=0.4000\), \(P(B)=0.5000\), covariance \(=0.0400\), probability exactly one \(=0.4200\).)
  4. Suppose \(P(A)=0.35\), \(P(B)=0.60\), and \(P(A\cap B)=0.21\). Determine the covariance and whether the events are independent. (Answer: Covariance \(=0.0000\); the events are independent because \(0.21=0.35(0.60)\).)
  5. With fixed marginals \(P(A)=0.25\) and \(P(B)=0.80\), find the feasible range for \(P(A\cap B)\) and the corresponding minimum and maximum possible indicator covariances. (Answer: \(0.0500\leq P(A\cap B)\leq0.2500\); covariance ranges from \(-0.1500\) to \(0.0500\).)
Clinical Biostats