Learn R Programming

Deducer (version 0.7-9)

add.cross.strata.test: Apply a Stratified test to a Contingency Table

Description

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

Usage

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

Arguments

tables
An object of class contingency.tables
name
The name of the hypothesis test
htests
A function or list of functions which take a three dimensional array 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

Value

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

See Also

add.mantel.haenszel add.test

Examples

Run this code
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)
add.cross.strata.test(tables,"Mantel-Haenszel",list(function(x) mantelhaen.test(x,correct=FALSE)),
 "asymptotic")
tables

Run the code above in your browser using DataLab