hwx.test()
function is the main function of the HWxtest
package. This function produces a valid test for Hardy-Weinberg frequencies for virtually any set of genotype counts. It will use either a full-enumeration method in which all possible tables with the same allele numbers are examined, or a Monte Carlo test where a large number of random tables is examined. To decide which to use, it calls xcountCutoff
to determine whether the number of tables to examine is greater than cutoff
. If it is, then mtest
is used. Otherwise xtest
is used. The result is a robust test which will always provide a meaningful and accurate P value. Each table examined is compared with the observed counts according to each of four measures of fit: hwx.test(c, method = "auto", cutoff = 1e+07, B = 1e+05,
statName = "LLR", histobins = 0, histobounds = c(0, 0), showCurve = T,
safeSecs = 100, detail = 2)
x
is somewhat flexible: It can be a square matrix, but only the hwx.test
will first check to see whether the total number of tables exceeds a cutoff specified by the method
is set to cutoff
is used to decide whether to perform the test via the full enumeration or Monte Carlo method. If the number of tables is less than cutoff
, then a full enumeratioTRUE
a histogram with 500 bins is plotted. If histobins
is set to a number greater than 1, a histogram with histobins
bins is plotted.c(0,0)
, then hwx.test
will compute reasonable bounds to include most of the distribution.LLR
and Chisq
hwx.test
programmatically.)hwtest
which includes the following items:LLR
, Prob
, U
and Chisq
in that order.p.value
item# Data from Louis and Dempster 1987 Table 2 and Guo and Thompson 1992 Figure 2:
c <- c(0,3,1,5,18,1,3,7,5,2)
hwx.test(c)
# To see a histogram of the LLR statistic:
hwx.test(c, histobins=TRUE)
# For a histogram of the U statistic and other details of the result:
hwx.test(c, statName="U", histobins=TRUE, detail=3)
Run the code above in your browser using DataLab