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

Description Usage Arguments Value See Also Examples

View source: R/contingency.tables.R

Description

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

Usage

1
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

1
2
3
4
5
6
7
8
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

Example output

Loading required package: ggplot2
Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
OpenJDK 64-Bit Server VM warning: Can't detect primordial thread stack location - find_vma failed

Please type JGR() to launch console. Platform specific launchers (.exe and .app) can also be obtained at http://www.rforge.net/JGR/files/.


Loading required package: car
Loading required package: carData
Loading required package: MASS
Registered S3 methods overwritten by 'lme4':
  method                          from
  cooks.distance.influence.merMod car 
  influence.merMod                car 
  dfbeta.influence.merMod         car 
  dfbetas.influence.merMod        car 


Note Non-JGR console detected:
	Deducer is best used from within JGR (http://jgr.markushelbig.org/).
	To Bring up GUI dialogs, type deducer().

================================================================================

               ==================================================               
                      ========== Table: a by b ==========                      

                       | -- Stratum = FALSE --
                       | b 
                     a |    FALSE  |     TRUE  | Row Total | 
-----------------------|-----------|-----------|-----------|
       FALSE  Count    |       11  |       12  |       23  | 
              Row %    |   47.826% |   52.174% |   76.667% | 
              Column % |   78.571% |   75.000% |           | 
              Total %  |   36.667% |   40.000% |           | 
-----------------------|-----------|-----------|-----------|
        TRUE  Count    |        3  |        4  |        7  | 
              Row %    |   42.857% |   57.143% |   23.333% | 
              Column % |   21.429% |   25.000% |           | 
              Total %  |   10.000% |   13.333% |           | 
-----------------------|-----------|-----------|-----------|
          Column Total |       14  |       16  |       30  | 
              Column % |   46.667% |   53.333% |           | 

                       | -- Stratum = TRUE --
                       | b 
                     a |    FALSE  |     TRUE  | Row Total | 
-----------------------|-----------|-----------|-----------|
       FALSE  Count    |       27  |       22  |       49  | 
              Row %    |   55.102% |   44.898% |   70.000% | 
              Column % |   72.973% |   66.667% |           | 
              Total %  |   38.571% |   31.429% |           | 
-----------------------|-----------|-----------|-----------|
        TRUE  Count    |       10  |       11  |       21  | 
              Row %    |   47.619% |   52.381% |   30.000% | 
              Column % |   27.027% |   33.333% |           | 
              Total %  |   14.286% |   15.714% |           | 
-----------------------|-----------|-----------|-----------|
          Column Total |       37  |       33  |       70  | 
              Column % |   52.857% |   47.143% |           | 



                Large Sample                                               
           Test Statistic    DF p-value | Effect Size       est.  Lower (%)
Mantel-Haenszel 0.366        1  0.545   | common odds ratio 1.315 0.546 () 
                         
           Test Upper (%)
Mantel-Haenszel 3.165 () 
---------------





================================================================================
================================================================================

               ==================================================               
                      ========== Table: a by b ==========                      

                       | -- Stratum = FALSE --
                       | b 
                     a |    FALSE  |     TRUE  | Row Total | 
-----------------------|-----------|-----------|-----------|
       FALSE  Count    |       11  |       12  |       23  | 
              Row %    |   47.826% |   52.174% |   76.667% | 
              Column % |   78.571% |   75.000% |           | 
              Total %  |   36.667% |   40.000% |           | 
-----------------------|-----------|-----------|-----------|
        TRUE  Count    |        3  |        4  |        7  | 
              Row %    |   42.857% |   57.143% |   23.333% | 
              Column % |   21.429% |   25.000% |           | 
              Total %  |   10.000% |   13.333% |           | 
-----------------------|-----------|-----------|-----------|
          Column Total |       14  |       16  |       30  | 
              Column % |   46.667% |   53.333% |           | 

                       | -- Stratum = TRUE --
                       | b 
                     a |    FALSE  |     TRUE  | Row Total | 
-----------------------|-----------|-----------|-----------|
       FALSE  Count    |       27  |       22  |       49  | 
              Row %    |   55.102% |   44.898% |   70.000% | 
              Column % |   72.973% |   66.667% |           | 
              Total %  |   38.571% |   31.429% |           | 
-----------------------|-----------|-----------|-----------|
        TRUE  Count    |       10  |       11  |       21  | 
              Row %    |   47.619% |   52.381% |   30.000% | 
              Column % |   27.027% |   33.333% |           | 
              Total %  |   14.286% |   15.714% |           | 
-----------------------|-----------|-----------|-----------|
          Column Total |       37  |       33  |       70  | 
              Column % |   52.857% |   47.143% |           | 


================================================================================

Deducer documentation built on May 2, 2019, 8:35 a.m.