g.test: G-test

View source: R/functions.R

g.testR Documentation

G-test

Description

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

Usage

g.test(x, y = NULL, correct="williams", p = rep(1/length(x), length(x)), simulate.p.value = FALSE, B = 2000)

Arguments

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

Details

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.

Examples

#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")


mzinkgraf/BiometricsWWU documentation built on Dec. 9, 2023, 1:07 a.m.