rmlike {hwep} | R Documentation |
Likelihood inference for random mating
Description
Estimates gamete genotype frequencies using a maximum likelihood approach and runs a likelihood ratio test for random mating.
Usage
rmlike(nvec, thresh = 1, nstarts = 10)
Arguments
nvec |
A vector containing the observed genotype counts,
where |
thresh |
All groups with counts less than |
nstarts |
The number of random restarts to the EM algorithm. Set this to 0 for only one run. |
Details
Let q
be the genotype frequencies. Let p
be the gamete
frequencies. Then random mating occurs if
q == stats::convolve(p, rev(p), type = "open")
. We test for
this hypothesis using likelihood inference, while estimating p
.
Value
A list with the following elements:
p
The estimated gamete genotype frequencies.
p[[i]]
is the estimated frequency for gamete genotypei-1
.chisq_rm
The likelihood ratio test statistic for testing against the null of random mating.
df_rm
The degrees of freedom associated with
chisq_rm
.p_rm
The p-value against the null of random mating.
Author(s)
David Gerard
Examples
## Randomly generate gamete frequencies
set.seed(1)
ploidy <- 10
pvec <- stats::runif(ploidy / 2 + 1)
pvec <- pvec / sum(pvec)
## Genotype frequencies from gamete frequencies under random mating
qvec <- stats::convolve(pvec, rev(pvec), type = "open")
## Generate data
nvec <- c(stats::rmultinom(n = 1, size = 100, prob = qvec))
## Run rmlike()
rmlike(nvec = nvec)