add.test {Deducer}R Documentation

Apply a test to a Contingency Tables object

Description

Applies and adds a test to a contingency.tables object.

Usage

add.test(tables,name,htests,types=c("asymptotic","monte.carlo","exact"))

add.chi.squared(tables, simulate.p.value = FALSE, B = 10000)

add.likelihood.ratio(tables, conservative = FALSE, simulate.p.value = FALSE, B = 10000)

add.fishers.exact(tables, simulate.p.value = FALSE, B = 10000)

add.correlation(tables,method=c("spearman","kendall"))

add.kruskal(tables,nominal=c("both","rows","cols"))

Arguments

tables

An object of class contingency.tables

name

Name of the test

htests

A function or list of functions which take a matrix as it's argument and returns an object of class htest

types

A character vector with the same number of items as htests, indicating what type of test was done

conservative

Should a conservative p-value be computed. i.e. One with a continuity correction for asymptotic tests and not using the mid p-value for exact and approximate tests

simulate.p.value

If TRUE p-values will be computed via monte carlo simulation

B

the number of samples for the monte carlo simulation

method

the type of correlation

nominal

Should the rows or columns be considered nominal.

Details

add.test applies a supplied list of tests to all of the tables in tables.

add.chi.squared is a wrapper function applying the chisq.test function to each table. add.likelihood.ratio is a wrapper function applying the likelihood.test function to each table. add.fishers.exact is a wrapper function applying the fisher.test function to each table. add.correlation is a wrapper function applying the cor.test function to each table. add.kruskal is a wrapper function applying the kruskal.test function to each table.

Value

A contingency.tables object identical to tables, but with the test applied to each table.

See Also

add.cross.strata.test likelihood.test cor.test kruskal.test

Examples

dat<-data.frame(a=rnorm(100)>.5,b=rnorm(100)>0,c=rnorm(100)>(-.5))
tables<-contingency.tables(
	row.vars=a,
	col.vars=b,
	stratum.var=c,data=dat)
tables<-add.chi.squared(tables,simulate.p.value=TRUE,B=10000)
tables<-add.likelihood.ratio(tables)
tables<-add.fishers.exact(tables)
tables<-add.correlation(tables,method='kendall')
tables<-add.kruskal(tables)
tables<-add.mantel.haenszel(tables)
print(tables)
remove(tables)

[Package Deducer version 0.7-9 Index]