if (FALSE) {
library(agridat)
data(becker.chicken)
dat <- becker.chicken
libs(lattice)
dotplot(weight ~ female, data=dat, group=male,
main="becker.chicken - progeny weight by M*F",
xlab="female parent",ylab="progeny weight",
auto.key=list(columns=5))
# Sums match Becker
# sum(dat$weight)
# aggregate(weight ~ male + female, dat, FUN=sum)
# Variance components
libs(lme4,lucid)
m1 <- lmer(weight ~ (1|male) + (1|female), data=dat)
# vc(m1)
## grp var1 var2 vcov sdcor
## 1 female (Intercept) 1096 33.1
## 2 male (Intercept) 776.8 27.87
## 3 Residual 5524 74.32
# Calculate heritabilities
# s2m <- 776 # variability for males
# s2f <- 1095 # variability for females
# s2w <- 5524 # variability within crosses
# vp <- s2m + s2f + s2w # 7395
# 4*s2m/vp # .42 male heritability
#4*s2f/vp # .59 female heritability
}
Run the code above in your browser using DataLab