Why a Two-by-Two Table Reveals Covariance
When two outcomes are recorded as indicators, their joint probability table contains all the information needed to calculate their covariance. The key is to compare the probability that both indicators equal one with the product of their separate probabilities. That product is what the joint probability would be if the indicators were independent.
This comparison is useful in actuarial settings where outcomes may be recorded as yes-or-no events—for example, whether a hypothetical policy has a claim and whether that claim exceeds a threshold. A positive covariance means the two indicators occur together more often than their marginal probabilities alone would suggest. A negative covariance means they occur together less often. Covariance describes association, not a causal effect.
Because binary variables are bounded, their expectations, second moments, and covariance are finite. Thus the product-moment identity applies: \(\operatorname{Cov}(X,Y)=E[XY]-E[X]E[Y]\). More generally, this identity requires that \(E[XY]\) exists; finite expectations of \(X\) and \(Y\) alone do not guarantee that condition. The boundedness of binary variables ensures it here.
The Table Formula and Its Sign
Use rows for \(X\) and columns for \(Y\), with the value one listed before zero. Denote the cells by \(a=p_{11}\), \(b=p_{10}\), \(c=p_{01}\), and \(d=p_{00}\).
| \(Y=1\) | \(Y=0\) | Row total | |
|---|---|---|---|
| \(X=1\) | \(a=p_{11}\) | \(b=p_{10}\) | \(a+b\) |
| \(X=0\) | \(c=p_{01}\) | \(d=p_{00}\) | \(c+d\) |
| Column total | \(a+c\) | \(b+d\) | 1 |
The probability that \(X=1\) is the first row total, \(a+b\), and the probability that \(Y=1\) is the first column total, \(a+c\). Since \(XY=1\) only when both variables equal one, \(E[XY]=a\).
The second equality uses \(a+b+c+d=1\). It shows that the sign can be determined by comparing the two diagonal products: \(ad\) and \(bc\). If \(ad>bc\), covariance is positive; if \(ad<bc\), it is negative; and if \(ad=bc\), it is zero. This is a direct sign test, but the marginal calculation is also valuable because it clarifies the interpretation.
Why the Formula Holds
The derivation follows from the product-moment identity and the table’s marginal totals. First, \(E[XY]=a\), since the product is one in the \(X=1,Y=1\) cell and zero in every other cell. Also, \(E[X]=a+b\) and \(E[Y]=a+c\). Therefore covariance is \(a-(a+b)(a+c)\). To obtain the cell-product form, use \(d=1-a-b-c\):
This derivation explains why the table’s diagonals matter: their product difference is exactly the covariance for zero-one coding, not merely a heuristic for its sign.
Zero Covariance and Independence
For general random variables, zero covariance does not necessarily imply independence. For two binary variables, however, it does. If covariance is zero, then \(a=(a+b)(a+c)\). Let \(r=P(X=1)=a+b\) and \(s=P(Y=1)=a+c\). The equation \(a=rs\) gives the probability of the cell where both equal one. The other cells then follow from the same marginals:
These are precisely the four products of the marginal probabilities. Thus every joint cell factors into its corresponding marginal probabilities, which is independence. Conversely, independence gives \(a=rs\), so the covariance is zero. This equivalence applies to binary variables, including cases where a marginal probability is zero or one.
A further consequence is that the sign depends on the coding. If \(Y\) is replaced by \(1-Y\), the event coded as one is reversed and \(\operatorname{Cov}(X,1-Y)=-\operatorname{Cov}(X,Y)\). The association has not changed in substance; its numerical sign has changed because the direction of the coding changed.
Worked Examples
Worked Example: Positive Covariance From a Joint Table
A hypothetical insurer records two binary indicators for a portfolio of policies: \(X=1\) if a policy has a claim during the year, and \(Y=1\) if the claim, when present, exceeds a specified threshold. The joint probabilities are shown below. Find the covariance and interpret its sign.
| \(Y=1\) | \(Y=0\) | |
|---|---|---|
| \(X=1\) | 0.24 | 0.16 |
| \(X=0\) | 0.12 | 0.48 |
Method. First verify the table and calculate both marginals. The four probabilities sum to \(0.24+0.16+0.12+0.48=1.00\). The row total for \(X=1\) is \(0.24+0.16=0.40\), and the column total for \(Y=1\) is \(0.24+0.12=0.36\).
The joint probability that both indicators equal one is \(0.24\). Therefore \[ \operatorname{Cov}(X,Y)=0.24-(0.40)(0.36)=0.24-0.144=0.096. \] As a table-product check, \(p_{11}p_{00}-p_{10}p_{01}=(0.24)(0.48)-(0.16)(0.12)=0.1152-0.0192=0.096\).
The covariance is positive. For an additional interpretation check, \(P(Y=1\mid X=1)=0.24/0.40=0.60\), which is greater than the marginal probability \(P(Y=1)=0.36\). The two calculations agree that the indicators occur together more often than independence would predict.
Check. Both formulas give \(0.096\), and the probabilities sum to one. A common mistake would be to use \(0.24\) itself as the covariance; that is the joint probability, not the joint probability minus the product of the marginals.
Worked Example: Negative Covariance Despite a Large Joint Cell
In a hypothetical two-category classification, \(X=1\) marks one type of event and \(Y=1\) marks a second type. The joint probabilities are \(p_{11}=0.10\), \(p_{10}=0.40\), \(p_{01}=0.30\), and \(p_{00}=0.20\). Determine the covariance and explain why looking only at \(p_{11}\) could mislead.
Method. Verify the total: \(0.10+0.40+0.30+0.20=1.00\). The marginals are \(P(X=1)=0.10+0.40=0.50\) and \(P(Y=1)=0.10+0.30=0.40\).
Calculate covariance by comparing the joint cell with the product of the marginals: \[ \operatorname{Cov}(X,Y)=0.10-(0.50)(0.40)=0.10-0.20=-0.10. \] The cell-product check gives \((0.10)(0.20)-(0.40)(0.30)=0.02-0.12=-0.10\).
The covariance is negative: the joint probability \(0.10\) is below the \(0.20\) that the two marginal probabilities would imply under independence. Although \(p_{11}\) is positive, that fact alone says nothing about the sign of covariance. The relevant comparison is with the product of the marginals.
Check. The negative sign agrees with \(p_{11}p_{00}<p_{10}p_{01}\). A common mistake is to treat any nonzero probability in the \(X=1,Y=1\) cell as evidence of positive covariance.
Worked Example: Zero Covariance and Independence
A hypothetical risk study records whether a location experiences a specified event (\(X=1\)) and whether it receives a particular response (\(Y=1\)). The table has probabilities \(p_{11}=0.18\), \(p_{10}=0.42\), \(p_{01}=0.12\), and \(p_{00}=0.28\). Determine the covariance and decide whether \(X\) and \(Y\) are independent.
Method. The cells sum to \(0.18+0.42+0.12+0.28=1.00\). The marginal probabilities are \(P(X=1)=0.18+0.42=0.60\) and \(P(Y=1)=0.18+0.12=0.30\).
The covariance is \[ \operatorname{Cov}(X,Y)=0.18-(0.60)(0.30)=0.18-0.18=0. \] For a direct independence check, the four products of the marginal probabilities are \(0.60(0.30)=0.18\), \(0.60(0.70)=0.42\), \(0.40(0.30)=0.12\), and \(0.40(0.70)=0.28\). Each matches its corresponding table cell.
Thus \(X\) and \(Y\) are independent. This conclusion follows from the special binary-variable result; it would not be valid to infer independence from zero covariance for arbitrary random variables.
Check. The table factors into its marginal probabilities, and the covariance is zero. A common mistake is to apply the general warning that zero covariance need not mean independence without noticing that both variables here are binary.
Common Exam Traps
- Using the wrong comparison. Positive covariance requires \(p_{11}>P(X=1)P(Y=1)\), not merely \(p_{11}>0\). Almost every valid table has a positive or zero \(p_{11}\).
- Reversing a cell or marginal. With the displayed layout, \(p_{10}\) means \(X=1,Y=0\), while \(p_{01}\) means \(X=0,Y=1\). Write the row and column labels before calculating.
- Assuming zero covariance never implies independence. That warning is correct for general random variables, but binary variables are a special case: zero covariance is equivalent to independence.
- Changing the meaning of one. Reversing a binary variable’s coding reverses the covariance sign. State what each variable’s zero and one represent.
- Using a table that is not a probability distribution. Check that every cell is nonnegative and the four cells sum to one before interpreting the result.
Check Your Understanding
For each table, use zero-one coding and check that the listed probabilities sum to one before calculating.
- A hypothetical table has \(p_{11}=0.27\), \(p_{10}=0.13\), \(p_{01}=0.18\), and \(p_{00}=0.42\). Find both marginals and the covariance. (Answer: \(P(X=1)=0.40\), \(P(Y=1)=0.45\), \(\operatorname{Cov}(X,Y)=0.0900\), positive.)
- A table has \(p_{11}=0.12\), \(p_{10}=0.28\), \(p_{01}=0.38\), and \(p_{00}=0.22\). Find the covariance using the marginal formula and state its sign. (Answer: \(P(X=1)=0.40\), \(P(Y=1)=0.50\), \(\operatorname{Cov}(X,Y)=-0.0800\), negative.)
- A table has \(p_{11}=0.21\), \(p_{10}=0.49\), \(p_{01}=0.09\), and \(p_{00}=0.21\). Calculate covariance, then determine whether the variables are independent. (Answer: \(P(X=1)=0.70\), \(P(Y=1)=0.30\), covariance \(0\); the variables are independent.)
- A table has \(p_{11}=0.15\), \(p_{10}=0.35\), \(p_{01}=0.25\), and \(p_{00}=0.25\). Use \(p_{11}p_{00}-p_{10}p_{01}\) to find the covariance and interpret it relative to independence. (Answer: \(0.15(0.25)-0.35(0.25)=0.0375-0.0875=-0.0500\); the joint occurrence is below its independent benchmark.)
- In a table, \(p_{11}=0.32\), \(p_{10}=0.08\), \(p_{01}=0.18\), and \(p_{00}=0.42\). Find \(\operatorname{Cov}(X,Y)\), then recode the second variable as \(Y'=1-Y\) and find \(\operatorname{Cov}(X,Y')\). (Answer: \(\operatorname{Cov}(X,Y)=0.32-(0.40)(0.50)=0.1200\); \(\operatorname{Cov}(X,Y')=-0.1200\).)