p_anc_est_beta_mle: Calculate maximum likelihood estimates of allele frequencies...

View source: R/p_anc_hat_beta_mle.R

p_anc_est_beta_mleR Documentation

Calculate maximum likelihood estimates of allele frequencies from Beta model

Description

For each sample allele frequency x in the input, this function calculates the maximum likelihood estimate of the true allele frequency p⁠assuming that the sample was drawn from a Beta distribution with mean⁠p⁠ and variance p*(1-p)*kinship⁠, where kinship is the mean kinship of the sample and is known. Note that, oddly, this function estimates the unknown p from a single data point x. Nevertheless, this procedure results in favorable shrinkage of estimate towards 0.5.

Usage

p_anc_est_beta_mle(p_anc_est, kinship)

Arguments

p_anc_est

A vector of sample allele frequencies (each refered to as x above)

kinship

The mean kinship coefficient of the data

Value

A vector of maximum likelihood estimates of allele frequencies. The length of the vector is the same as the input p_anc_est, and each element in the output was estimated from each corresponding element in the input only.

See Also

inv_var_est_bayesian() for another way to get unbiased estimates of a specific class of inverse variance terms of interest in this project.

Examples

# select a relatively high value for example
kinship <- 0.1

# try a grid of values, including edge cases (0,1)
m_loci <- 1000
p_anc_est <- 0 : (m_loci - 1) / (m_loci - 1)

# calculate the desired estimates!
p_anc_mle <- p_anc_est_beta_mle( p_anc_est, kinship )

# notice values tend to be shrunk towards 0.5,
# except values near the edges of the range are shrunk less
plot( p_anc_est, p_anc_mle )
abline(0,1)


OchoaLab/simtrait documentation built on July 4, 2025, 3:48 a.m.