# James Hensman’s Weblog

## February 4, 2009

### Back to school for me…

Filed under: Uncategorized — jameshensman @ 6:32 pm

I’ve been having a preliminary flick through Andrew Gelman’s book, (amazon) which so far seems excellent. I thought I’d have a shot at the questions in the introductory chapter.

First question. Easy, no problem.

Second question. Ooh, bit trickier. Got there in the end.

Third question. This has taken me 40 minutes, which seems like justification for posting a solution on this ‘ere weblog.

Suppose that in each individual in a population there is a pair of genes, each of which can be either X or x, that controls eye colour: those with xx have blue eyes, those with XX or Xx or xX have brown eyes. Those with Xx are known as heterozygotes.

The proportion of individuals with blue eyes (xx) is $a^2$, and the proportion of heterozygotes is $2a(1-a)$.

Each parent transmits one gene to the child: if the parent is a heterozygote, the probability that they transmit X is $0.5$. Assuming random mating, show that amongst brown eyed parents with brown eyed children, the proportion of heterozygotes is $2a/(1+2a)$.

Okay says I, it’s just Bayes’ rule, no? Let’s denote all heterozygotes as Xx (this should save significant keypresses…), children as ch and parents as pa.

Under Bayes rule we need a likelihood $p(\text{ch}=Xx | \text{pa})$, prior $p(\text{pa})$ and a ‘marginal likelihood’ term, which we get by summing the above. So we’re going to get something like:

$p(\text{ch}=Xx) = \frac{p(\text{ch}=Xx | \text{pa}) p(\text{pa})} {\sum_\text{ch} p(\text{ch}=Xx | \text{pa}) p(\text{pa})}$

We also need to make sure that we only consider brown eyed individuals (XX, Xx, and xX. not xx). let’s have a look at the priors:

$p(xx) = a^2$
$p(Xx) = 2a(1-a)$
and a little manipulation yeilds:
$p(XX) = (1-a)^2$

So looking at combinations of parents who have brown eyes:

$p(\text{pa}=XX,XX) = (1-a)^4$
$p(\text{pa}=XX,Xx) = 2*2a(1-a)*(1-a)^2$
$p(\text{pa}=Xx,xx) = 4a^2(1-a)^2$

Each of which can be considered a prior, with correspondings likelihoods (of the child being Xx):

$p(\text{ch}=Xx | \text{pa}=XX,XX) = 0$
$p(\text{ch}=Xx | \text{pa}=XX,Xx) = 0.5$
$p(\text{ch}=Xx | \text{pa}=Xx,xx) = 0.5$

Now, the top line of Thomas Bayes’ famous rule looks like:

$0.5*4a(1-a)^3 + 0.5*4a^2(1-a)^2$

remembering that the bottom line must consist of all brown eyed children of brown eyed parents (not just the heterozygotes), the bottom line looks like:

$(1-a)^4 + 4a(1-a)^3 + 0.75*4a^2(1-a)^2$

Phew. Cancelling a few terms does indeed leave

$p(\text{ch}=Xx | \text{pa}=(Xx,XX),(XX,XX),(Xx,Xx)) = \frac{2a}{1+2a}$

Not going to school for years switches your brain off: It took me as long to figure out how to do this as it did to blog it…

There’s actually a second part to the problem, (first set by Lindley, 1965, apparently), which turns out to have some rather messy terms in. I think I’ll save blogging that for another day.