#simulate a dataset with binary data
dataset <- matrix(nrow = 50 , ncol = 101)
dataset <- apply(dataset, 2, function(i) sample(c(0,1),50, replace=TRUE))
#initialize binary target
target <- dataset[,101]
#remove target from the dataset
dataset <- dataset[,-101]
require(pcalg)
if(require("pcalg", quietly = TRUE))
{
#run the gSquare conditional independence test for the binary class variable
results <- gSquare(target, dataset, xIndex = 44, csIndex = c(10,20))
results
#require(gRbase) #for faster computations in the internal functions
#run SES algorithm using the gSquare conditional independence test for the binary class variable
sesObject <- SES(target , dataset , max_k=3 , threshold=0.05 , test="gSquare");
#print summary of the SES output
summary(sesObject);
#plot the SES output
plot(sesObject, mode="all");
}
Run the code above in your browser using DataLab