g.test | R Documentation |
Log-likelihood tests of independence & goodness of fit. The g.test function impliments Williams' and Yates' correction, and does Monte Carlo simulation of p-values, via gtestsim.c
g.test(x, y = NULL, correct="williams", p = rep(1/length(x), length(x)), simulate.p.value = FALSE, B = 2000)
x |
Vector of occurances for each category |
y |
Vector of occurances for each category |
correct |
How should the test statitics be corrected. Options= "none", "yates", "williams" |
p |
Vector of probabilities |
simulate.p.value |
Logical |
B |
Number of permutations to use. Default = 2000 |
G & q calculation from Sokal & Rohlf (1995) Biometry 3rd ed.
TOI Yates' correction taken from Mike Camann's 2x2 G-test fn.
GOF Yates' correction as described in Zar (2000)
more stuff taken from ctest's chisq.test()
V3.3 Pete Hurd Sept 29 2001.
#Generate data
#Hat Island data
HI <- c(purple = 141, orange = 1)
#Strawberry Hill data
SH <- c(purple = 154, orange = 54)
(observed <- matrix(c(HI, SH), 2, dimnames = list(color = c("Purple", "Orange"), site = c("Hat Island", "Strawberry Hill"))))
#calcualte test statistic
g.test(observed, correct = "none")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.