Learn R Programming

DiffXTables (version 0.1.1)

sharma.song.test: Sharma-Song Test for Second-Order Difference Across Contingency Tables

Description

Across given contingency tables, the test admits only second-order difference in the joint distributions underlying the tables.

Usage

sharma.song.test(tables)

Arguments

tables

a list of at least two non-negative matrices or data frames representing contingency tables of the same dimensions.

Value

A list with class "htest" containing the following components:

statistic

the Sharma-Song chi-squared test statistic.

parameter

degrees of freedom of the chi-squared test statistic.

p.value

p-value of the Sharma-Song test, computed using the chi-squared distribution.

Details

The Sharma-Song test determines whether the patterns underlying multiple input contingency tables are second-order differential. Its null test statistic is proved to asymptotically follow the chi-squared distribution sharma2020COPTYPDiffXTables.

The test statistic is minimized to zero if and only if the deviation of observed from expected counts normalized by the square root of expected count is equal in the same entry across all tables.

References

See Also

cp.chisq.test, heterogeneity.test, strength.test, marginal.change.test, and type.analysis.

Examples

Run this code
# NOT RUN {
  # Two second-order differential tables:
  tables <- list(
    matrix(c(4,0,0,
             0,4,0,
             0,0,4), nrow=3),
    matrix(c(0,4,4,
             4,0,4,
             4,4,0), nrow=3)
  )
  sharma.song.test(tables)
  
  # Three tables differ in the first-order but not second-order:
  tables <- list(
    matrix(c(2, 4,  6,  8, 
             3, 6,  9, 12, 
             4, 8, 12, 16), nrow=4),
    matrix(c( 2, 1,  3,  7,
              2, 1,  3,  7,
             10, 5, 15, 35), nrow=4),
    matrix(c(40, 16, 72, 16, 
             45, 18, 81, 18,
             25, 10, 45, 10), nrow=4)
  )
  sharma.song.test(tables)
# }

Run the code above in your browser using DataLab