if (FALSE) {
set.seed(10)
# - - Example 1
# Generating multivariate normal data from a 'random' graph
data.sim <- bdgraph.sim(n = 100, p = 10, size = 15, vis = TRUE)
bdgraph.obj <- bdgraph(data = data.sim, iter = 1000, save = TRUE)
summary(bdgraph.obj)
# Confusion Matrix
conf.mat(actual = data.sim, pred = bdgraph.obj)
conf.mat.plot(actual = data.sim, pred = bdgraph.obj)
# To compare our result with true graph
compare(bdgraph.obj, data.sim, main = c("Target", "BDgraph"), vis = T)
# Running algorithm with starting points from previous run
bdgraph.obj2 <- bdgraph(data = data.sim, g.start = bdgraph.obj)
compare(list(bdgraph.obj, bdgraph.obj2), data.sim,
main = c("Target", "Frist run", "Second run"))
# - - Example 2
# Generating mixed data from a 'scale-free' graph
data.sim <- bdgraph.sim(n = 200, p = 7, type = "mixed", graph = "scale-free", vis = TRUE)
bdgraph.obj <- bdgraph(data = data.sim, method = "gcgm")
summary(bdgraph.obj)
compare(bdgraph.obj, data.sim, vis = T)
conf.mat(actual = data.sim, pred = bdgraph.obj)
conf.mat.plot(actual = data.sim, pred = bdgraph.obj)
}
Run the code above in your browser using DataLab