Learn R Programming

FunChisq (version 2.3.1)

fun.chisq.test: Chi-Square and Exact Tests for Non-Parametric Functional Dependencies

Description

Asymptotic chi-square, normalized chi-square or exact tests on contingency tables to determine non-parametric functional dependencies of the column variable on the row variable.

Usage

fun.chisq.test(x, method = "fchisq", alternative = "non-constant", log.p = FALSE, index.kind = "unconditional")

Arguments

x
a matrix representing a contingency table. The row variable represents the independent variable or all unique combinations of multiple independent variables. The column variable is the dependent variable.
method
a character string to specify the method to compute the functional chi-square test statistic and its p-value. The options are "fchisq" (equivalent to "default", the default), "nfchisq" (equivalent to "normalized"), or "exact". See Details.
alternative
a character string to specify the alternative hypothesis. The options are "non-constant" (default, non-constant functions) and "all" (all types of functions including constant ones).
log.p
logical; if TRUE, the p-value is given as log(p). Taking the log improves the accuracy when p-value is close to zero. The default is FALSE.
index.kind
a character string to specify the kind of function index xi.f to be estimated. The options are "unconditional" (default) and "conditional". See Details.

Value

A list with class "htest" containing the following components:
statistic
the functional chi-square statistic if method = "fchisq", "default", or "exact"; or the normalized functional chi-square statistic if method = "nfchisq" or "normalized".
parameter
degrees of freedom for the functional chi-square statistic.
p.value
p-value of the functional test. If method = "fchisq" (or "default"), it is computed by an asymptotic chi-square distribution; if method = "nfchisq" (or "normalized"), it is computed by the standard normal distribution; if method = "exact", it is computed by an exact hypergeometric distribution.
estimate
an estimate of function index between 0 and 1. The value of 1 indicates a strictly mathematical function. It is asymmetrical with respect to transpose of the input contingency table, different from the symmetrical Cramer's V for Pearson's chi-square.

Details

The functional chi-square test determines whether the column variable is a function of the row variable in contingency table x (Zhang and Song, 2013; Zhang, 2014). This function supports three hypothesis testing methods:

index.kind specifies the kind of estimated function index to be computed. If the experimental design controls neither the row nor column marginal sample size, index.kind = "unconditional" (default) is recommended; otherwise, index.kind = "conditional" is recommended. The choice of index.kind affects only the estimated function index xi.f value, but not the test statistic or p-value.

When method="fchisq" (equivalent to "default", the default), the test statistic is computed as described in (Zhang and Song, 2013; Zhang, 2014) and the p-value is computed using the chi-square distribution.

When method="nfchisq" (equivalent to "normalized"), the test statistic is a normalized functional chi-square obtained by shifting and scaling the original chi-square (Zhang and Song, 2013; Zhang, 2014); and the p-value is computed using the standard normal distribution (Box et al., 2005). The normalized chi-square, more conservative on the degrees of freedom, was used by the Best Performer NMSUSongLab in HPN-DREAM (DREAM8) Breast Cancer Network Inference Challenges.

When method="exact", an exact functional test (Zhong, 2014) is performed. It computes an exact p-value and is fast when both the sample and table sizes are small. If the sample size is greater than 200 or the table size is larger than 5 by 5, the exact test may not complete within a reasonable amount of time and the asymptotic functional chi-square test (method="fchisq") is used instead.

For 2-by-2 contingency tables, the asymptotic test options (method="fchisq" or "nfchisq") are recommended to test functional dependency.

References

Box, G. E., Hunter, J. S., and Hunter, W. G. (2005). Statistics for Experimenters: Design, Innovation and Discovery, 2nd Edition. Wiley-Interscience, New York.

Fisher, R. A. (1922). On the interpretation of chi-square from contingency tables, and the calculation of P. Journal of the Royal Statistical Society, 85(1), 87-94.

Pearson, K. (1990). On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine Series 5, 50(302), 157-175.

Zhang, Y. and Song, M. (2013) Deciphering interactions in causal networks without parametric assumptions. arXiv Molecular Networks, arXiv:1311.2707, http://arxiv.org/abs/1311.2707

Zhang, Y. (2014) Nonparametric Statistical Methods for Biological Network Inference. Unpublished doctoral dissertation, Department of Computer Science, New Mexico State University, Las Cruces, USA.

Zhong, H. (2014) An Exact and Fast Statistical Test for Nonparametric Functional Dependencies. Unpublished M.S. thesis, Department of Computer Science, New Mexico State University, Las Cruces, USA.

Examples

Run this code
# Example 1. Asymptotic functional chi-square test
x <- matrix(c(20,0,20,0,20,0,5,0,5), 3)
fun.chisq.test(x) # strong functional dependency
fun.chisq.test(t(x)) # weak functional dependency

# Example 2. Normalized functional chi-square test
x <- matrix(c(8,0,8,0,8,0,2,0,2), 3)
fun.chisq.test(x, method="nfchisq") # strong functional dependency
fun.chisq.test(t(x), method="nfchisq") # weak functional dependency

# Example 3. Exact functional chi-square test
x <- matrix(c(4,0,4,0,4,0,1,0,1), 3)
fun.chisq.test(x, method="exact") # strong functional dependency
fun.chisq.test(t(x), method="exact") # weak functional dependency

# Example 4. Exact functional chi-square test on a real data set
#            (Shen et al., 2002)
# x is a contingency table with row variable for p53 mutation and
#   column variable for CIMP
x <- matrix(c(12,26,18,0,8,12), nrow=2, ncol=3, byrow=TRUE)

# Test the functional dependency: p53 mutation -> CIMP
fun.chisq.test(x, method="exact")

# Test the functional dependency CIMP -> p53 mutation
fun.chisq.test(t(x), method="exact")

Run the code above in your browser using DataLab