Created
November 18, 2019 06:32
-
-
Save SachaEpskamp/c0761ba43dfd0997ed0092055e80bd68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("bootnet") | |
library("mvtnorm") | |
library("qgraph") | |
# Sample size: | |
n <- 40000 | |
# Generate 10-node chain graph with positive edges: | |
net <- genGGM(10, propPositive = 1, constant = 1.1) | |
# Form data: | |
data <- ggmGenerator()(n,net) | |
# Form error: | |
error <- rmvnorm(n,sigma=diag(10)) | |
# Add data with error: | |
data2 <- data + error | |
# Make ordered (binary): | |
data3 <- 1 * (data2 < 0) | |
# Estimate three networks: | |
net1 <- estimateNetwork(data, default = "ggmModSelect") | |
net2 <- estimateNetwork(data2, default = "ggmModSelect") | |
net3 <- estimateNetwork(data3, default = "ggmModSelect") | |
# Plot everything: | |
layout(matrix(1:4,2,2,byrow=TRUE)) | |
qgraph(net,layout="circle",theme = "colorblind", title = "True network") | |
plot(net1,layout="circle", title = "ggmModSelect estimate") | |
plot(net2,layout="circle", title = "ggmModSelect estimate (with error)") | |
plot(net3,layout="circle", title = "ggmModSelect estimate (with error and polychorics)") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment