Learn R Programming

micd (version 1.1.1)

mixCItest: Likelihood Ratio Test for (Conditional) Independence between Mixed Variables

Description

A likelihood ratio test for (conditional) independence between mixed (continuous and unordered categorical) variables, to be used within pcalg::skeleton, pcalg::pc or pcalg::fci. It assumes that the variables in the test follow a Conditional Gaussian distribution, i.e. conditional on each combination of values of the discrete variables, the continuous variables are multivariate Gaussian. Each multivariate Gaussian distribution is allowed to have its own mean vector and covariance matrix.

Usage

mixCItest(x, y, S = NULL, suffStat, moreOutput = FALSE)

Value

A p-value. If moreOutput=TRUE, the test statistic and the degrees of freedom are returned as well.

Arguments

x, y, S

(Integer) position of variable X, Y and set of variables S, respectively, in suffStat. It is tested whether X and Y are conditionally independent given the subset S of the remaining variables.

suffStat

A data.frame. Discrete variables must be coded as factors.

moreOutput

If TRUE, the test statistic and the degrees of freedom are returned in addition to the p-value (only for mixed variables). Defaults to FALSE.

Author

Janine Witte

Details

The implementation follows Andrews et al. (2018). The same test is also implemented in TETRAD and in the R-package rcausal, a wrapper for the TETRAD Java library. Small differences in the p-values returned by CGtest and the TETRAD/rcausal equivalent are due to differences in handling sparse or empty cells.

References

Andrews B., Ramsey J., Cooper G.F. (2018): Scoring Bayesian networks of mixed variables. International Journal of Data Science and Analytics 6:3-18.

Lauritzen S.L., Wermuth N. (1989): Graphical models for associations between variables, some of which are qualitative and some quantitative. The Annals of Statistics 17(1):31-57.

Scheines R., Spirtes P., Glymour C., Meek C., Richardson T. (1998): The TETRAD project: Constraint based aids to causal model specification. Multivariate Behavioral Research 33(1):65-117. http://www.phil.cmu.edu/tetrad/index.html

Examples

Run this code
# load data (numeric and factor variables)
dat <- toenail2[,-1]

# analyse data
mixCItest(4, 1, NULL, suffStat = dat)
mixCItest(1, 2, 3, suffStat = dat)

## use mixCItest within pcalg::fci
fci.fit <- fci(suffStat = dat, indepTest = mixCItest, alpha = 0.01, p = 4)
if (requireNamespace("Rgraphviz", quietly = TRUE))
 plot(fci.fit)

Run the code above in your browser using DataLab