Perfom a G-test on a contingency table or a vector of counts.
Usage
G.test(x, p = rep(1/length(x), length(x)))
Arguments
x
a numeric vector or matrix (see Details).
p
theoretical proportions (optional).
Value
methodname of the test.
statistictest statistics.
parametertest degrees of freedom
p.valuep-value.
data.namea character string giving the name(s) of the data.
observedthe observed counts.
expectedthe expected counts under the null hypothesis.
Details
If x is matrix, it must be constructed like this:
- 2 columns giving number of successes (left) and fails (right)
- 1 row per population.
The function works as chisq.test :
- if x is a vector and theoretical proportions are not given, equality of counts is tested
- if x is a vector and theoretical proportions are given, equality of counts to theoretical counts (given by theoretical proportions) is tested
- if x is a matrix, equality of proportion of successes between populations is tested.