cond.fun.chisq.test {FunChisq} | R Documentation |
Conditional Functional Chi-Squared Test
Description
Asymptotic chi-squared test to determine the model-free functional dependency of effect variable Y
on a cause variable X
, conditioned on a third variable Z
.
Usage
cond.fun.chisq.test(x, y, z=NULL, data=NULL, log.p = FALSE,
method = c("fchisq", "nfchisq"))
Arguments
x |
vector or character; either a discrete random variable (cause) represented as vector or a character column name in |
y |
vector or character; either a discrete random variable (effect) represented as vector or a character column name in |
z |
vector or character; either a discrete random variable (condition) represented as vector or a character column name in |
data |
a data frame containing three or more columns whose names can be used as values for |
log.p |
logical; if |
method |
a character string to specify the method to compute the conditional functional chi-squared test statistic and its p-value. The options are |
Details
The conditional functional chi-squared test introduces the concept of conditional functional depedency, where the functional association between two variables (x
and y
) is tested conditioned on a third variable (z
) (Zhang 2014). Two methods are provided to compute the chi-squared statistic and its p-value. When method = "fchisq"
, the p-value is computed using the chi-squared distribution; when method = "nfchisq"
, a normalized statistic is obtained by shifting and scaling the original chi-squared statistic and a p-value is computed using the standard normal distribution (Box et al. 2005). The normalized test is more conservative on the degrees of freedom.
Value
A list with class "htest
" containing the following components:
statistic |
the conditional functional chi-squared statistic if |
parameter |
degrees of freedom for the conditional functional chi-squared statistic. |
p.value |
p-value of the conditional functional test. If |
estimate |
an estimate of the conditional function index between 0 and 1. The value of 1 indicates strong functional dependency between |
Author(s)
Sajal Kumar and Mingzhou Song
References
Box GE, Hunter JS, Hunter WG (2005).
Statistics for Experimenters: Design, Innovation and Discovery, 2nd edition.
Wiley-Interscience, New York.
Zhang Y (2014).
Nonparametric Statistical Methods for Biological Network Inference.
Ph.D. thesis, Department of Computer Science, New Mexico State University, Las Cruces, NM, USA.
See Also
See (unconditional) functional chi-squared test fun.chisq.test
.
Examples
# Generate a relationship between variables X and Z
xz = matrix(c(30,2,2, 2,2,40, 2,30,2),ncol=3,nrow=3,
byrow = TRUE)
# Re-construct X
x = rep(c(1:nrow(xz)),rowSums(xz))
# Re-construct Z
z = c()
for(i in 1:nrow(xz))
z = c(z,rep(c(1:ncol(xz)),xz[i,]))
# Generate a relationship between variables Z and Y
# Make sure Z retains its distribution
zy = matrix(c(4,30, 30,4, 4,40),ncol=2,nrow=3,
byrow = TRUE)
# Re-construct Y
y = rep(0,length(z))
for(i in unique(z))
y[z==i] = rep(c(1:ncol(zy)),zy[i,])
# Tables
table(x,z)
table(z,y)
table(x,y)
# Conditional functional dependency
# Y = f(X) | Z should be false
cond.fun.chisq.test(x=x,y=y,z=z)
# Z = f(X) | Y should be true
cond.fun.chisq.test(x=x,y=z,z=y)
# Y = f(Z) | X should be true
cond.fun.chisq.test(x=z,y=y,z=x)