# Calculating and Inferring Relatedness Coefficients with BGmisc

Source:`vignettes/analyticrelatedness.Rmd`

`analyticrelatedness.Rmd`

## Introduction

This vignette demonstrates analytic methods for determining
relatedness in a pedigree. The relatedness coefficient is a measure of
the genetic overlap between two individuals. In the simplest terms, it
quantifies the genetic overlap between two individuals. The relatedness
coefficient ranges from 0 to 1, with 1 indicating a perfect genetic
match (which occurs when comparing an individual to themselves, their
identical twin, or their clone), whereas 0 indicates no genetic overlap.
We introduce two functions: `calculateRelatedness`

and
`inferRelatedness`

, which allow users to compute and infer
the relatedness coefficient, respectively.

### Calculating Relatedness Coefficient

The `calculateRelatedness`

function offers a method to
compute the relatedness coefficient based on shared ancestry, as
described by Wright (1922). This function utilizes the formula:

\[ r_{bc} = \sum \left(\frac{1}{2}\right)^{n+n'+1} (1+f_a) \]

Where \(n\) and \(n'\) represent the number of generations back of common ancestors the pair share.

```
# Example usage:
# For full siblings, the relatedness coefficient is expected to be 0.5:
calculateRelatedness(generations = 1, full = TRUE)
#> [1] 0.5
```

```
# For half siblings, the relatedness coefficient is expected to be 0.25:
calculateRelatedness(generations = 1, full = FALSE)
#> [1] 0.25
```

## Inferring Relatedness Coefficient

The `inferRelatedness`

function is designed to infer the
relatedness coefficient between two groups based on the observed
correlation between their additive genetic variance and shared
environmental variance. This function leverages the ACE framework.

```
# Example usage:
# Infer the relatedness coefficient:
inferRelatedness(obsR = 0.5, aceA = 0.9, aceC = 0, sharedC = 0)
#> [1] 0.5555556
```