g.test | R Documentation |
Log-likelihood test for independence & goodness of fit. g.test() performs Williams' and Yates' correction; Monte Carlo simulation of p-values, via gtestsim.c. MC requires recompilation of R. Written by Peter Hurd (V3.3 Pete Hurd Sept 29 2001, phurd AT ualberta.ca). Yuliya Karpievitch added comments for ease of understanding and incorporated into ProteoMM. G & q calculation from Sokal & Rohlf (1995) Biometry 3rd ed., TOI Yates correction taken from Mike Camanns 2x2 G-test function, GOF Yates correction as described in Zar (2000), more stuff taken from ctest's chisq.test().
g.test(x, y = NULL, correct = "none", p = rep(1/length(x), length(x)))
x |
vector of boolean values corresponding to presence & absence eg: c(TRUE, TRUE, FALSE, FALSE) for present present absent absent values. Order of TRUE/FALSE does not matter, can be used interchangeably. Same length as parameter y |
y |
vector treatments (factor) corresponding to values in x, same length as x eg: as.factor(c('grp1;, 'grp1', 'grp2', 'grp2')) |
correct |
correction to apply, options: "yates", "williams", "none" default: "none" NOTE: in ProteoMM we only tested & used correction = "none" |
p |
default: rep(1/length(x), length(x)), used in Yates correction NOTE: in ProteoMM we only tested & used the default parameter value |
htest object the following variables
value of the G statistic produced by g test
degrees of freedom of the test
p-value
method used to produce statistic and p-value
data passed in to the function
matrix of observed counts
matrix of expected counts
g.test(c(TRUE, TRUE, FALSE, FALSE), as.factor(c('grp1', 'grp1', 'grp2', 'grp2')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.