Iteratively resample individuals/genotypes, calculating the U-statistic for each resample, and use these resamples to test against the null of no equilibrium.
hweboot(n, nboot = 2000, more = FALSE)
One of two forms
Element i is the number of individuals with genotype i.
Element (i, j) is the posterior probability that individual i has ploidy j-1.
The number of bootstrap samples to run.
A logical. Should we return the bootstrap replicates
(FALSE
) or just the p-value, with 95% confidence interval
of the p-value (TRUE
).
A list with some or all of the following elements
p_hwe
The bootstrap p-value against the null of equilibrium.
p_ci
The 95% confidence interval of p_hwe.
alpha_boot
The bootstrap samples of the double reduction parameter.
u_boot
The bootstrap samples of the U-statistic.
set.seed(1)
ploidy <- 6
size <- 100
r <- 0.5
alpha <- 0.1
qvec <- hwefreq(r = r, alpha = alpha, ploidy = ploidy)
nvec <- c(rmultinom(n = 1, size = size, prob = qvec))
bout <- hweboot(n = nvec, more = TRUE, nboot = 1000)
bout$p_hwe
#> [1] 0.746
bout$p_ci
#> [1] 0.7178207 0.7727228
#> attr(,"conf.level")
#> [1] 0.95
hist(bout$test_boot)
abline(v = bout$test_stat, lty = 2, col = 2)