$$A_{jk} = N^{-1} \sum_i (x_{ij}-2p_i)(x_{ik}-2p_i)/(2p_i(1-p_i))$$ Each locus is standardized by its own Hardy-Weinberg variance. The original paper gives the diagonal as \(1 + N^{-1}\sum_i [x_{ij}^2 - (1+2p_i)x_{ij} + 2p_i^2]/(2p_i(1-p_i))\); GCTA later made the diagonal match the off-diagonal, which is the default here.
Examples
Yangr(matrix(c(1, 0, 0, 1, 2, 1), nrow = 2))
#> $estimate
#> [1] 0.6666667
#>
#> $A
#> [,1] [,2]
#> [1,] 0.6666667 -0.6666667
#> [2,] -0.6666667 0.6666667
#>
#> $freq
#> [1] 0.25 0.25 0.75
#>
#> $n_lines
#> [1] 2
#>
#> $n_markers
#> [1] 3
#>
#> $yang_diagonal
#> [1] FALSE
#>
#> $method
#> [1] "Yang et al. (2010) realized relationship matrix"
#>
