Skip to content

Instantly share code, notes, and snippets.

@SachaEpskamp
Last active August 16, 2019 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SachaEpskamp/7e4b5bea30be2ac9eb724eedd86c9d39 to your computer and use it in GitHub Desktop.
Save SachaEpskamp/7e4b5bea30be2ac9eb724eedd86c9d39 to your computer and use it in GitHub Desktop.
# Install from github:
devtools::install_github("sachaepskamp/qgraph")
library("qgraph")
# Example network to play with:
# Load data:
library("psychTools")
data(bfi)
# Compute polychoric correlations:
corMat <- cor_auto(bfi[,1:25])
# Optimize network:
Results <- ggmModSelect(corMat, nrow(bfi), gamma = 0.5, nCores = 8)
# Plot results:
object <- qgraph(Results$graph, layout = "spring", cut = 0, theme = "colorblind", title = "Using qgraph")
# Now as ggraph:
library("ggplot2")
as.ggraph(object) + ggtitle("Using ggraph")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment