g.test: G Test for presence - absence analysis

Description Usage Arguments Value Examples

View source: R/gtest.R

Description

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

Usage

1
2
g.test(x, y = NULL, correct = "none", p = rep(1/length(x),
  length(x)))

Arguments

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

Value

htest object the following variables

statistic

value of the G statistic produced by g test

parameter

degrees of freedom of the test

p.value

p-value

method

method used to produce statistic and p-value

data.name

data passed in to the function

observed

matrix of observed counts

expected

matrix of expected counts

Examples

1
2
g.test(c(TRUE, TRUE, FALSE, FALSE),
       as.factor(c('grp1', 'grp1', 'grp2', 'grp2')))

ProteoMM documentation built on Nov. 8, 2020, 5:57 p.m.