# NOT RUN {
### Using bfi dataset from psych ###
library("psych")
data(bfi)
### CORRELATIONS ###
# Compute correlations:
CorMat <- cor_auto(bfi[,1:25])
# Run local FDR:
CorMat_FDR <- FDRnetwork(CorMat)
# Number of edges remaining:
mean(CorMat_FDR[upper.tri(CorMat_FDR,diag=FALSE)]!=0)
# None, so might use different criterion:
CorMat_FDR <- FDRnetwork(CorMat, method = "pval")
# Compare:
L <- averageLayout(CorMat, CorMat_FDR)
layout(t(1:2))
qgraph(CorMat, layout = L, title = "Correlation network",
maximum = 1, cut = 0.1, minimum = 0, esize = 20)
qgraph(CorMat_FDR, layout = L, title = "Local FDR correlation network",
maximum = 1, cut = 0.1, minimum = 0, esize = 20)
# Centrality:
centralityPlot(list(cor=CorMat, fdr = CorMat_FDR))
### PARTIAL CORRELATIONS ###
# Partial correlation matrix:
library("parcor")
PCorMat <- cor2pcor(CorMat)
# Run local FDR:
PCorMat_FDR <- FDRnetwork(PCorMat, cutoff = 0.1, method = "pval")
# Number of edges remaining:
mean(PCorMat_FDR[upper.tri(PCorMat_FDR,diag=FALSE)]!=0)
# Compare:
L <- averageLayout(PCorMat, PCorMat_FDR)
layout(t(1:2))
qgraph(PCorMat, layout = L, title = "Partial correlation network",
maximum = 1, cut = 0.1, minimum = 0, esize = 20)
qgraph(PCorMat_FDR, layout = L, title = "Local FDR partial correlation network",
maximum = 1, cut = 0.1, minimum = 0, esize = 20)
# Centrality:
centralityPlot(list(cor=PCorMat, fdr = PCorMat_FDR))
# }
Run the code above in your browser using DataLab