flexMItest {micd}R Documentation

Wrapper for gaussMItest, disMItest and mixMItest

Description

A plug-in conditional independence test for pcalg::skeleton, pcalg::pc or pcalg::fci when multiply imputed data sets are available. flexMItest detects whether variables are continuous, discrete or mixed, and automatically switches between gaussMItest (continuous only), link{disMItest} (discrete only) and mixMItest (mixed).

Usage

flexMItest(x, y, S = NULL, suffStat)

Arguments

x, y, S

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

suffStat

a list generated using getSuff with test="flexMItest". See below for details.

Details

suffStat needs to be a list with four elements named datlist, corlist, conpos and dispos. datlist is the list of imputed datasets. corlist is a list with M+1 elements, where M is the number of imputed datasets. For i=1,...,M, the the i-th element of corlist is the correlation matrix of the continuous variables in the i-th imputed dataset; the (M+1)-the element is the number of rows in each imputed dataset. conpos is a vector containing the integer positions of the continuous variables in the original dataset. dispos is a vector containing the integer positions of the discrete variables in the original dataset.

Value

A p-value.

See Also

gaussMItest, disMItest and mixMItest

Examples

## load data (numeric and factor variables)
library(ranger)
dat <- toenail2[1:400, ]

## delete some observations
set.seed(123)
dat[sample(400, 20), 2] <- NA
dat[sample(400, 30), 4] <- NA

## impute missing values using random forests
imp <- mice::mice(dat, method = "rf", m = 3, printFlag = FALSE)

## obtain correct input 'suffStat' for 'flexMItest'
suff <- getSuff(imp, test="flexMItest")

## analyse data
# continuous variables only
flexMItest(4,5,NULL, suffStat = suff)
implist <- complete(imp, action="all")
gaussSuff <- c(lapply(implist, function(i){cor(i[ ,c(4,5)])}), n = 400)
gaussMItest(1,2,NULL, suffStat = gaussSuff)
flexCItwd(4, 5, NULL, dat)

# discrete variables only
flexMItest(2,3,NULL, suffStat = suff)
disMItest(2,3,NULL, suffStat = complete(imp, action="all"))
flexCItwd(2,3,NULL, dat)

# mixed variables
flexMItest(2,3,4, suffStat = suff)
mixMItest(2,3,4, suffStat = complete(imp, action="all"))
flexCItwd(2,3,4, dat)


[Package micd version 1.1.1 Index]