# Calculating heritability

This page explains what heritability is and how to calculate it using different software packages.

## What is heritability?

Heritability (or h2) measures the proportion of phenotypic variance accounted for by additive genetic effects and is a central property of quantitative genetics. As variance components are calulated after fixed effects have been accounted for, the addition of fixed effects into the model can cause the estimate of h2 to change. For further details see Wilson et al 2008 (pdf): Why h2 does not always equal VA / VP?

## How to calculate heritability

### By hand

Add up all variance components to find the total phenotypic variance (once fixed effects have been corrected for). Divide additive genetic variance by the total phenotypic variance. So in the simplest case in which we just have an additive genetic (VA) and a residual variance component (VR), h2 = VA / VA+VR.

### ASReml

In ASReml a second command file (with extension .pin) is used to caculate functions of estimated variance components ad their associated standard errors. So for a model in the .as file such as
`SIZE ~ mu ! ANIMAL`

the primary output file (.asr) will contain two variance components. The first will be the ANIMAL (i.e. additive genetic component), the second will be the residual variance. A .pin file to calculate heritability from these components migt be
```F VP 1+2  #adds components 1 and 2 to make a 3rd variance denoted VP
H h2 1 3  #divides 1 (VA) by 3 (VP) to calculate h2```

NOTE - if you change the random effects stucture of your model in .as you need to modify the .pin file accordingly or you will get the wrong answer!

### ASReml-R

There are two ways to calculate heritability in ASReml-R.
• 1. By hand - this is easiest if you are moving output into another program which can do calculations, Excel for example.
• 2. By extracting variance components from summary(model)\$varcomp. If additive genetic variance is the 1st random effect, the following code will work - otherwise change the number 1 for the appropriate row.
`summary(model)\$varcomp[1,3]/sum(summary(model)\$varcomp[,3])`

### MCMCglmm

```posterior.heritability1.1<-model1.1\$VCV[,"animal"]/
(model1.1\$VCV[,"animal"]+model1.1\$VCV[,"units"])

HPDinterval(posterior.heritability1.1,0.95)

posterior.mode(posterior.heritability1.1)

plot(posterior.heritability1.1)```

### WOMBAT

We can calculate the heritability by hand from the variance component estimates provided in `SumEstimates.out`. Conveniently however, WOMBAT estimates not only the absolute variance components, but also the proportion of the phenotypic variation accounted for by the different random effects, along with their sampling error. For the animal effect this proportion is (usually) equal to the heritability.