Learn R Programming

qgraph (version 1.10.1)

FDRnetwork: Model selection using local False Discovery Rate

Description

This function is a wrapper around fdrtool to easily compute a correlation or partial correlation network in which all nonsignificant edges are set to zero.

Usage

FDRnetwork(net, cutoff = 0.1, method = c('lfdr', 'pval', 'qval'))

Value

A matrix of the same dimensions as net in which the edges for which the selected measure exceeds the cutoff are set to zero.

Arguments

net

A correlation or partial correlation matrix

cutoff

The cutoff value to use. Edges for which the measure indicated by the first element of method is higher than the cutoff are removed. Thus, by default, edges with a local false discovery rate higher than 0.1 are removed from the graph.

method

The method to use with the cutoff. Can be 'lfdr' for the local false discovery rate, 'pval' for the p-value or 'qval' for the q-value.

Author

Sacha Epskamp <mail@sachaepskamp.com>

Details

method = 'lfdr' could result in a very sparse network, so also looking at other values is advisable.

References

Bernd Klaus and Korbinian Strimmer. (2014). fdrtool: Estimation of (Local) False Discovery Rates and Higher Criticism. R package version 1.2.12. http://CRAN.R-project.org/package=fdrtool

Examples

Run this code
if (FALSE) {
### Using bfi dataset from psych ###
library("psych")
data(bfi)

### CORRELATIONS ###
# Compute Spearman correlations:
CorMat <- cor(bfi[,1:25], method = "spearman", use = "pairwise.complete.obs")

# Run local FDR:
CorMat_FDR <- FDRnetwork(CorMat)

# Proportion 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:
PCorMat <- corpcor::cor2pcor(CorMat)

# Run local FDR:
PCorMat_FDR <- FDRnetwork(PCorMat, cutoff = 0.1, method = "pval")

# Proportion 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