mean_kinship {popkin} | R Documentation |
Calculate the weighted mean kinship
Description
This function computes a particular weighted mean kinship that arises in the context of kinship and FST estimators and in the definition of the effective sample size. This function allows for weights to be zero or even negative, but they are internally normalized to sum to one.
Usage
mean_kinship(kinship, weights = NULL)
Arguments
kinship |
The kinship matrix |
weights |
Weights for individuals (optional).
If |
Value
The weighted mean kinship matrix, equivalent to drop( weights %*% kinship %*% weights )
after normalizing weights to sum to one.
Examples
# construct a dummy kinship matrix
kinship <- matrix(c(0.5, 0, 0, 0.6), nrow=2)
# this is the ordinary mean
mean_kinship(kinship)
# weighted mean with twice as much weight on the second individual
# (weights are internally normalized to sum to one)
weights <- c(1, 2)
mean_kinship(kinship, weights)
[Package popkin version 1.3.23 Index]