# Define distribution list
dist <- list(a = "gaussian",
b = "gaussian",
c = "gaussian",
d = "gaussian",
e = "binomial",
f = "binomial")
# Define a matrix formulation
edge_strength <- matrix(c(0, 0.5, 0.5, 0.7, 0.1, 0,
0, 0, 0.3, 0.1, 0, 0.8,
0, 0, 0, 0.35, 0.66, 0,
0, 0, 0, 0, 0.9, 0,
0, 0, 0, 0, 0, 0.8,
0, 0, 0, 0, 0, 0),
nrow = 6L,
ncol = 6L,
byrow = TRUE)
## Naming of the matrix
colnames(edge_strength) <- rownames(edge_strength) <- names(dist)
## Random Data
df <- data.frame(a = rnorm(100),
b = rnorm(100),
c = rnorm(100),
d = rnorm(100),
e = rbinom(100, 1, 0.5),
f = rbinom(100, 1, 0.5))
## Plot form a matrix
plotAbn(dag = edge_strength,
data.dists = dist)
## Edge strength
plotAbn(dag = ~ a | b:c:d:e + b | c:d:f + c | d:e + d | e + e | f,
data.dists = dist,
edge.strength = edge_strength,
data.df = df)
## Plot from a formula for a different DAG!
plotAbn(dag = ~ a | b:c:e + b | c:d:f + e | f,
data.dists = dist,
data.df = df)
## Markov blanket
plotAbn(dag = ~ a | b:c:e + b | c:d:f + e | f,
data.dists = dist,
markov.blanket.node = "e",
data.df = df)
## Change col for all edges
tmp <- plotAbn(dag = ~ a | b:c:e + b | c:d:f + e | f,
data.dists = dist,
plot = FALSE,
data.df = df)
graph::edgeRenderInfo(tmp) <- list(col = "blue")
Rgraphviz::renderGraph(tmp)
## Change lty for individual ones. Named vector is necessary
tmp <- plotAbn(dag = ~ a | b:c:e + b | c:d:f + e | f,
data.dists = dist,
plot = FALSE,
data.df = df)
edgelty <- rep(c("solid", "dotted"), c(6, 1))
names(edgelty) <- names(graph::edgeRenderInfo(tmp, "col"))
graph::edgeRenderInfo(tmp) <- list(lty = edgelty)
Rgraphviz::renderGraph(tmp)
Run the code above in your browser using DataLab