Two questions to start with.
72% of people whose parents have a particular genetic disease also have that disease. If you find out a person's parents have that disease, do you predict that they do too?
72% of people whose parents like a certain song also like that song. If you find out a person's parents like that song, do you predict that they do too?
Neither question can be answered yet, and it is not because one is about genes and the other is about a song. It is because 72% on its own is not information about anybody. Find the number that is missing.
p1 <- 0.72 # parents have itp2 <- 0.72 # parents do notparent <- rep(c(1, 0), each = 100)child <- rbinom(200, 1, ifelse(parent == 1, p1, p2))# what knowing the parent buys youp1 - p2# and the same thing as a correlationcor(parent, child)
Galton wrote to 205 families in 1885 and asked for the heights of everybody in them. 934 grown children came back, with both their parents.
Every height here is measured as a departure from the average of its own kind, in spreads rather than inches, so that a father, a mother and a daughter can all go on one axis. Each point is one parent against one of their children.
Fit the line. Its tilt is the correlation between a parent and their child, and that number is the whole of what this lesson is about.
g <- read.csv("data/clean/galton_families.csv")g$kid <- g$childHeight * ifelse(g$gender == "female", 1.08, 1)# every child against each parent in turnpar <- c(g$father, g$mother * 1.08)kid <- c(g$kid, g$kid)# both in spreads, so the tilt is the correlationpz <- scale(par); kz <- scale(kid)tilt <- 0.00cor(pz, kz - tilt * pz) # the tilt left overcor(par, kid)coef(lm(kz ~ pz))
Sixty broods of nestlings, four to a nest. Each father sings, and each nestling learns the song from the bird in whose nest it wakes up. Nothing about the song is carried in any egg.
Turn up how carefully the nestlings copy, and watch two things at once: the nestmates in a brood start to sound like each other, and each nestling starts to sound like the bird that raised it.
Then swap the eggs between nests before any of them hatch, and ask both questions again.
fid <- 0.30 # how carefully a nestling copiesfather <- rnorm(40)tutor <- if (swap) sample(father) else fatherbrood <- rep(1:40, each = 4)song <- fid*tutor[brood] + sqrt(1-fid^2)*rnorm(160)cor(tutor[brood], song) # the bird that raised itcor(father[brood], song) # the bird it came from
Now a trait that every gene in the population agrees about. Four limbs, in every individual, specified as thoroughly as anything in the body is specified.
The variation comes from somewhere else entirely. Some of them lose a limb — a fall, a predator, a machine. Turn the accident rate up and there is plenty of variation to look at.
Then ask whether the accidents happen to fall in the same families, and watch what that does to the parent–offspring correlation.
# every individual is built with fourrate <- 0.25clus <- 0.00danger <- rnorm(400)p <- pnorm(qnorm(rate) + clus*danger)par <- 4 - rbinom(400, 1, p)kid <- 4 - rbinom(400, 1, p)cor(par, kid)
So far every correlation has been a parent against a child. There are other pairs of relatives, and each of them shares a different amount of what a parent hands down.
One knob here — the heritability — and four kinds of relative: a parent and a child, two full siblings, two half siblings, and two first cousins. Turn it and all four move together.
The two marks on the axis are Galton's, from the real families in Stage B: what one parent and a child actually measured, and what two siblings actually measured. Find the setting that puts your first two rungs on them.
h <- 0.20kid <- function(a, b) (a+b)/2 + sqrt(h/2)*rnorm(length(a))seen <- function(g) g + sqrt(1-h)*rnorm(length(g))# each rung is the same fit as Stage B, on a different paircor(seen(father), seen(kid(father, mother)))# theory, for a check: h/2, h/2, h/4, h/8
Three populations, one knob each. In the first, a child gets half of what its parents were built with. In the second, a child copies whoever raises it. In the third, a parent and a child simply live under the same roof and it does the same thing to both.
Set all three knobs until the three correlations are the same number. Then look at the three scatters and decide which is which.
Then swap the babies between families at birth, keep comparing each child to the parents it came from, and look again.
h1 <- 0.20 # built inh2 <- 0.20 # copied from the raiserh3 <- 0.20 # shared roof# swapping cannot reach into the first onegk <- gp/2 + sqrt(h1*0.75)*rnorm(n)k2 <- h2*if(swap) sample(p2) else p2k3 <- h3*if(swap) sample(roof) else roofc(cor(P1,K1), cor(P2,K2), cor(P3,K3))