# Calculating heritability

**bold**or

*italic*and can be split over multiple paragraphs.

# Calculating heritability

## Using 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)
```

## Using ASReml

In ASReml standalone: 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!

From R:

`summary(model)$varcomp[1,3]/sum(summary(model)$varcomp[,3])`

#1: SIZE is the response variable and the only fixed effect is the mean(denoted as1) #2: fit random effect of ANIMAL Va with an arbitrary starting value of 1 #3: use data file phenotypic data #4: connect the individual in the data file to the pedigree #5: omit any rows where the response or predictor variables are missing

to see the estimates of the fixed effects:

`summary(model)$coef.fixed`

and the estimates of the random effects:

`summary(model)$varcomp`

## Feedback

Was this page helpful?

Glad to hear it! Please tell us how we can improve.

Sorry to hear that. Please tell us how we can improve.