Description Usage Arguments Value References Examples

The `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: “LLR”, “Prob”, “U”, or “Chisq” corresponding to the log-likelihood ratio, the null-hypothesis probability, the U-score or the Pearson X^2 value. It can also plot a histogram showing the distribution of any of these statistics.

1 2 3 |

`c` |
The genotype counts. You must provide the number of each genotype. So if there are |

`method` |
Can be “auto”, “exact” or “monte” to indicate the method to use. If “auto”, the |

`cutoff` |
If |

`B` |
The number of trials to perform if Monte Carlo method is used |

`statName` |
can be “LLR”, “Prob”, “U”, or “Chisq” depending on which one is to be ploted. Note that P values for all four are computed regardless of which one is specified with this parameter. |

`histobins` |
If 0, no histogram is plotted. If 1 or |

`histobounds` |
A vector containing the left and right boundaries for the histogram's x axis. If you leave this as the default, |

`showCurve` |
whether to show a blue curve indicating the asymptotic (chi squared) distribution. This only works for |

`safeSecs` |
After this many seconds the calculation will be aborted. This is a safety valve to prevent attempts to compute impossibly large sets of tables. |

`detail` |
Determines how much detail is printed. If it is set to 0, nothing is printed (useful if you use |

Returns a list of class `hwtest`

which includes the following items:

`$ Pvalues` |
The four computed P values corresponding to the test statistics: |

`$ observed` |
The four observed statistics in the same order as above |

`$ ntrials` |
The number of tables examined during the calculation if done by Monte Carlo |

`$ tableCount` |
The total number of tables if done by full enumeration |

`$ genotypes` |
The input matrix of genotype counts |

`$ alleles` |
The allele counts |

`$ statName` |
Which statistic to use for the histogram and in the |

`$ method` |
Which method was used, “exact” or “monte” |

`$ detail` |
An integer indicating how much detail to print. Use 0 for no printing |

`$ SE` |
vector with the standard error for each stat. Only applicable with Monte Carlo tests |

The methods are described by Engels, 2009. **Genetics** 183:1431.

1 2 3 4 5 6 7 | ```
# 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)
``` |

HWxtest documentation built on May 29, 2017, 3:33 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.