disCItwd {micd} | R Documentation |
G square Test for (Conditional) Independence between Discrete Variables with Missings
Description
A wrapper for pcalg::disCItest
, to be used within
pcalg::skeleton
, pcalg::pc
or
pcalg::fci
when the data contain missing values.
Observations where at least one of the variables involved in the test is
missing are deleted prior to performing the test (test-wise deletion).
Usage
disCItwd(x, y, S = NULL, suffStat)
Arguments
x , y , S |
(Integer) position of variable X, Y and set of variables S,
respectively, in |
suffStat |
A list with three elements, |
Details
See disCItest
for details on the G square test. Test-wise deletion
is valid if missingness does not jointly depend on X and Y.
Value
A p-value.
See Also
pcalg::disCItest
for complete data, disMItest
for multiply imputed data
Examples
## load data (200 observations)
data(gmD)
dat <- gmD$x[1:1000,]
## delete some observations of X2 and X3
set.seed(123)
dat[sample(1:1000, 50), 2] <- NA
dat[sample(1:1000, 50), 3] <- NA
## analyse incomplete data
# test-wise deletion ==========
sufftwd <- getSuff(dat, test = "disCItwd")
disCItwd(1, 3, NULL, suffStat = sufftwd)
# list-wise deletion ==========
dat2 <- dat[complete.cases(dat), ]
suffStat2 <- getSuff(dat2, test = "disCItest", adaptDF = FALSE)
disCItest(1, 3, NULL, suffStat = suffStat2)
## use disCItwd within pcalg::pc ==========
pc.fit <- pc(suffStat = sufftwd, indepTest = disCItwd, alpha = 0.1, p = 5)
pc.fit
if (requireNamespace("Rgraphviz", quietly = TRUE))
plot(pc.fit)