Bayes test for random mating with known genotypes
rmbayes(
nvec,
lg = TRUE,
alpha = NULL,
beta = NULL,
nburn = 10000,
niter = 10000,
type = c("auto", "allo")
)
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
.
A logical. Should we return the log Bayes factor (TRUE
)
or the Bayes factor (FALSE
)?
The concentration hyperparameters of the gamete frequencies under the null of random mating. Should be length ploidy/2 + 1.
The concentration hyperparameters of the genotype frequencies under the alternative of no random mating. Should be length ploidy + 1.
The number of iterations in the Gibbs sampler to burn-in.
The number of sampling iterations in the Gibbs sampler.
If alpha
is NULL
, then the default priors depend
on if you have autopolyploids ("auto"
) or allopolyploids
("allo"
).
Gerard D (2023). "Bayesian tests for random mating in polyploids." Molecular Ecology Resources, In press. doi:10.1111/1755-0998.13856 .
set.seed(1)
ploidy <- 8
## Simulate under the null
p <- stats::runif(ploidy / 2 + 1)
p <- p / sum(p)
q <- stats::convolve(p, rev(p), type = "open")
## See BF increase
nvec <- c(stats::rmultinom(n = 1, size = 100, prob = q))
rmbayes(nvec = nvec)
#> [1] 2.122218
nvec <- c(stats::rmultinom(n = 1, size = 1000, prob = q))
rmbayes(nvec = nvec)
#> [1] 8.487987
nvec <- c(stats::rmultinom(n = 1, size = 10000, prob = q))
rmbayes(nvec = nvec)
#> [1] 11.77032
## Simulate under the alternative
q <- stats::runif(ploidy + 1)
q <- q / sum(q)
## See BF decrease
nvec <- c(stats::rmultinom(n = 1, size = 100, prob = q))
rmbayes(nvec = nvec)
#> [1] -11.87659
nvec <- c(stats::rmultinom(n = 1, size = 1000, prob = q))
rmbayes(nvec = nvec)
#> [1] -128.9095
nvec <- c(stats::rmultinom(n = 1, size = 10000, prob = q))
rmbayes(nvec = nvec)
#> [1] -1265.442