# partial correlation networks (undirected)
cor_net(airquality, "pcor")
# directed acyclic graphs (grey edge = insignificant DPI)
dpi.dag = DPI_dag(airquality, k.covs=c(1,3,5), seed=1)
print(dpi.dag, k=1) # DAG with DPI(k=1)
print(dpi.dag, k=3) # DAG with DPI(k=3)
print(dpi.dag, k=5) # DAG with DPI(k=5)
# set edge labels and edge transparency
# (grey edge = insignificant DPI)
print(dpi.dag, k=5, show.label=FALSE, faded.dpi=TRUE)
# modify ggplot attributes
gg = plot(dpi.dag, k=5, show.label=FALSE, faded.dpi=TRUE)
gg + labs(title="DAG with DPI (k=5)")
# visualize DPIs of multiple paths
ggplot(dpi.dag$DPI, aes(x=k.cov, y=DPI)) +
geom_ribbon(
aes(ymin=Sim.LLCI, ymax=Sim.ULCI, fill=path),
alpha=0.1) +
geom_line(aes(color=path), linewidth=0.7) +
geom_point(aes(color=path)) +
geom_hline(yintercept=0, color="red",
linetype="dashed") +
scale_y_continuous(limits=c(NA, 0.5)) +
labs(color="Directed Prediction",
fill="Directed Prediction") +
theme_classic()
Run the code above in your browser using DataLab