Solution (source code)

= Solution

Since the binary trait $Y$ has marginal <Bernoulli distribution> with probability $K=p\alpha^2$, its total <variance> is
$$
\boxed{\operatorname{Var}(Y)=p\alpha^2(1-p\alpha^2).}
$$
Within a specified <genotype> $G=g$, the <conditional variance> is $q_g(1-q_g)$. The within-genotype contribution to total variance is its average over the population:
$$
V_W=\mathbb E[q_G(1-q_G)]
=\mathbb E(q_G)-\mathbb E(q_G^2).
$$
Another <Hardy-Weinberg equilibrium> average gives
$$
\mathbb E(q_G^2)
=p^2[(1-\phi)+\phi\theta^2]^2=p^2\beta^2,
\qquad\beta=1+\phi(\theta^2-1).
$$
Hence
$$
\boxed{V_W=p\alpha^2-p^2\beta^2.}
$$
By the <law of total variance>, the remaining between-genotype component is the <genetic variance of penetrance>, namely
$$
\boxed{V_G=\operatorname{Var}(q_G)
=\operatorname{Var}(Y)-V_W=p^2(\beta^2-\alpha^4).}
$$
It is nonnegative, as a <variance> must be. It also follows from $\beta-\alpha^2=\phi(1-\phi)(\theta-1)^2\geq0$. The single-genotype variance and its population average are different quantities; both have been specified.