G.test: G-test

View source: R/G.test.R

G.testR Documentation

G-test

Description

Perfoms 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).

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 with two columns, equality of proportion of successes between populations is tested.

- if x is a matrix with more than two columns, independence of rows and columns is tested.

Since a G-test is an approximate test, an exact test is preferable when the number of individuals is small (200 is a reasonable minimum). See multinomial.test in that case with a vector, fisher.test with a matrix.

Value

method

name of the test.

statistic

test statistics.

parameter

test degrees of freedom.

p.value

p-value.

data.name

a character string giving the name(s) of the data.

observed

the observed counts.

expected

the expected counts under the null hypothesis.

Author(s)

Maxime HERVE <maxime.herve@univ-rennes1.fr>

See Also

chisq.test, multinomial.test, fisher.test G.multcomp, G.theo.multcomp, pairwise.G.test

Examples

counts <- c(49,30,63,59)
G.test(counts)

RVAideMemoire documentation built on Nov. 6, 2023, 5:07 p.m.