Estimates gamete genotype frequencies using a maximum likelihood approach and runs a likelihood ratio test for random mating.
rmlike(nvec, thresh = 1, nstarts = 10)
A vector containing the observed genotype counts,
where nvec[[i]]
is the number of individuals with genotype
i-1
. This should be of length ploidy+1
.
All groups with counts less than nvec
will
be aggregated together.
The number of random restarts to the EM algorithm. Set this to 0 for only one run.
A list with the following elements:
p
The estimated gamete genotype frequencies. p[[i]]
is the estimated frequency for gamete genotype i-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.
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
.
## 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)
#> $p
#> 0 1 2 3 4 5
#> 0.09091247 0.13330033 0.13045867 0.23919892 0.07263341 0.33349620
#>
#> $chisq_rm
#> [1] 5.611122
#>
#> $df_rm
#> [1] 5
#>
#> $p_rm
#> [1] 0.3459148
#>