There's documentation here (https://www.rdocumentation.org/packages/pcalg/versions/2.7-3/topics/pc) on how to run the pc algorithm for binary data.
library(pcalg)
##################################################
## Using discrete data
##################################################
## Load data
data(gmD)
V <- colnames(gmD$x)
## define sufficient statistics
suffStat <- list(dm = gmD$x, nlev = c(3,2,3,4,2), adaptDF = FALSE)
## estimate CPDAG
pc.D <- pc(suffStat,
## independence test: G^2 statistic
indepTest = disCItest, alpha = 0.01, labels = V, verbose = TRUE)
if (require(Rgraphviz)) {
## show estimated CPDAG
par(mfrow = c(1,2))
plot(pc.D, main = "Estimated CPDAG")
plot(gmD$g, main = "True DAG")
}
I'm wondering if there's anyway I can use the pc.D
object to visualize this in ggdag
(https://cran.r-project.org/web/packages/ggdag/vignettes/intro-to-ggdag.html).
Is there a way?