Title: | Methods and Measures for Brain, Cognitive, and Psychometric Network Analysis |
---|---|
Description: | Implements network analysis and graph theory measures used in neuroscience, cognitive science, and psychology. Methods include various filtering methods and approaches such as threshold, dependency (Kenett, Tumminello, Madi, Gur-Gershgoren, Mantegna, & Ben-Jacob, 2010 <doi:10.1371/journal.pone.0015032>), Information Filtering Networks (Barfuss, Massara, Di Matteo, & Aste, 2016 <doi:10.1103/PhysRevE.94.062306>), and Efficiency-Cost Optimization (Fallani, Latora, & Chavez, 2017 <doi:10.1371/journal.pcbi.1005305>). Brain methods include the recently developed Connectome Predictive Modeling (see references in package). Also implements several network measures including local network characteristics (e.g., centrality), community-level network characteristics (e.g., community centrality), global network characteristics (e.g., clustering coefficient), and various other measures associated with the reliability and reproducibility of network analysis. |
Authors: | Alexander Christensen [aut, cre] , Guido Previde Massara [ctb] |
Maintainer: | Alexander Christensen <[email protected]> |
License: | GPL (>= 3.0) |
Version: | 1.4.3 |
Built: | 2024-10-27 05:05:22 UTC |
Source: | https://github.com/alexchristensen/networktoolbox |
Implements network analysis and graph theory measures used in neuroscience, cognitive science, and psychology. Methods include various filtering methods and approaches such as threshold, dependency, Information Filtering Networks, and Efficiency-Cost Optimization. Brain methods include the recently developed Connectome Predictive Modeling. Also implements several network measures including local network characteristics (e.g., centrality), global network characteristics (e.g., clustering coefficient), and various other measures associated with the reliability and reproducibility of network analysis.
Alexander Christensen <[email protected]>
Christensen, A. P. (in press). NetworkToolbox: Methods and measures for brain, cognitive, and psychometric network analysis in R. The R Journal, 10, 422-439.
Compute an alpha value adjusted for sample size. The adjusted value is based on Perez and Pericchi's (2014) formula (equation 11, see below) using a reference sample, which can be defined a priori or estimated using the sample size calculation from power.
adapt.a( test = c("anova", "chisq", "cor", "one.sample", "two.sample", "paired"), ref.n = NULL, n = NULL, alpha = 0.05, power = 0.8, efxize = c("small", "medium", "large"), groups = NULL, df = NULL )
adapt.a( test = c("anova", "chisq", "cor", "one.sample", "two.sample", "paired"), ref.n = NULL, n = NULL, alpha = 0.05, power = 0.8, efxize = c("small", "medium", "large"), groups = NULL, df = NULL )
test |
Type of statistical test being used. Can be any of the tests listed |
ref.n |
n0 in the above equation. Reference sample size. If sample size was determined a priori, then the reference number of participants can be set. This removes the calculation of sample size based on power |
n |
n* in the above equation. Number of participants in the experiment sample (or per group) |
alpha |
|
power |
Power ( |
efxize |
Effect size to be used to estimate the reference sample size.
Effect sizes are based on Cohen (1992).
Numeric values can be used.
Defaults to |
groups |
Number of groups (only for |
df |
Number of degrees of freedom (only for |
A list containing the following objects:
adapt.a |
The adapted alpha value |
crit.value |
The critical value associated with the adapted alpha value |
orig.a |
The original alpha value |
ref.n |
The reference sample size based on alpha, power, effect size, and test |
exp.n |
The sample size of the experimental sample |
power |
The power used to determine the reference sample size |
test |
The type of statistical test used |
Alexander Christensen <[email protected]>
Cohen, J. (1992). A power primer. Psychological Bulletin, 112, 155-159.
Perez, M. E., & Pericchi, L. R. (2014). Changing statistical significance with the amount of information: The adaptive a significance level. Statistics & Probability Letters, 85, 20-24.
#ANOVA adapt.anova <- adapt.a(test = "anova", n = 200, alpha = .05, power = .80, groups = 3) #Chi-square adapt.chisq <- adapt.a(test = "chisq", n = 200, alpha = .05, power = .80, df = 3) #Correlation adapt.cor <- adapt.a(test = "cor", n = 200, alpha = .05, power = .80) #One-sample t-test adapt.one <- adapt.a(test = "one.sample", n = 200, alpha = .05, power = .80) #Two-sample t-test adapt.two <- adapt.a(test = "two.sample", n = 200, alpha = .05, power = .80) #Paired sample t-test adapt.paired <- adapt.a(test = "paired", n = 200, alpha = .05, power = .80, efxize = "medium")
#ANOVA adapt.anova <- adapt.a(test = "anova", n = 200, alpha = .05, power = .80, groups = 3) #Chi-square adapt.chisq <- adapt.a(test = "chisq", n = 200, alpha = .05, power = .80, df = 3) #Correlation adapt.cor <- adapt.a(test = "cor", n = 200, alpha = .05, power = .80) #One-sample t-test adapt.one <- adapt.a(test = "one.sample", n = 200, alpha = .05, power = .80) #Two-sample t-test adapt.two <- adapt.a(test = "two.sample", n = 200, alpha = .05, power = .80) #Paired sample t-test adapt.paired <- adapt.a(test = "paired", n = 200, alpha = .05, power = .80, efxize = "medium")
NEO-PI-3 Openness to Experience associated with resting-state data (n = 144).
data(behavOpen)
data(behavOpen)
behavOpen (vector, length = 144)
Behavioral data of NEO-PI-3 associated with each connectivity matrix (open).
To access the resting-state brain data, please go to https://drive.google.com/file/d/1ugwi7nRrlHQYuGPzEB4wYzsizFrIMvKR/view
Beaty, R. E., Chen, Q., Christensen, A. P., Qiu, J., Silvia, P. J., & Schacter, D. L. (2018). Brain networks of the imaginative mind: Dynamic functional connectivity of default and cognitive control networks relates to Openness to Experience. Human Brain Mapping, 39, 811-821.
Beaty, R. E., Kenett, Y. N., Christensen, A. P., Rosenberg, M. D., Benedek, M., Chen, Q., ... & Silvia, P. J. (2018). Robust prediction of individual creative ability from brain functional connectivity. Proceedings of the National Academy of Sciences, 201713532.
data("behavOpen")
data("behavOpen")
Computes betweenness centrality of each node in a network
betweenness(A, weighted = TRUE)
betweenness(A, weighted = TRUE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
A vector of betweenness centrality values for each node in the network
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted BC BCw <- betweenness(A) #Unweighted BC BC <- betweenness(A, weighted = FALSE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted BC BCw <- betweenness(A) #Unweighted BC BC <- betweenness(A, weighted = FALSE)
Converts weighted adjacency matrix to a binarized adjacency matrix
binarize(A)
binarize(A)
A |
An adjacency matrix of network data (or an array of matrices) |
Returns an adjacency matrix of 1's and 0's
Alexander Christensen <[email protected]>
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A neoB <- binarize(A)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A neoB <- binarize(A)
Computes closeness centrality of each node in a network
closeness(A, weighted = TRUE)
closeness(A, weighted = TRUE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
A vector of closeness centrality values for each node in the network
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted LC LC <- closeness(A) #Unweighted LC LC <- closeness(A, weighted = FALSE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted LC LC <- closeness(A) #Unweighted LC LC <- closeness(A, weighted = FALSE)
Computes global clustering coefficient (CC) and local clustering coefficient (CCi)
clustcoeff(A, weighted = FALSE)
clustcoeff(A, weighted = FALSE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
Returns a list containing:
CC |
Global clustering coefficient. The average clustering coefficient for each node in the network |
CCi |
Local clustering coefficient. The clustering coefficient for each node in the network |
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Unweighted CC CCu <- clustcoeff(A) #Weighted CC CCw <- clustcoeff(A, weighted=TRUE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Unweighted CC CCu <- clustcoeff(A) #Weighted CC CCw <- clustcoeff(A, weighted=TRUE)
Computes the between-community strength for each node in the network
comcat( A, comm = c("walktrap", "louvain"), cent = c("strength", "degree"), absolute = TRUE, metric = c("across", "each"), diagonal = 0, ... )
comcat( A, comm = c("walktrap", "louvain"), cent = c("strength", "degree"), absolute = TRUE, metric = c("across", "each"), diagonal = 0, ... )
A |
An adjacency matrix of network data |
comm |
Can be a vector of community assignments or community detection algorithms
( |
cent |
Centrality measure to be used.
Defaults to |
absolute |
Should network use absolute weights?
Defaults to |
metric |
Whether the metric should be compute for across all of the communities
(a single value) or for each community (a value for each community).
Defaults to |
diagonal |
Sets the diagonal values of the |
... |
Additional arguments for |
A vector containing the between-community strength value for each node
Alexander Christensen <[email protected]>
Blanken, T. F., Deserno, M. K., Dalege, J., Borsboom, D., Blanken, P., Kerkhof, G. A., & Cramer, A. O. (2018). The role of stabilizing and communicating symptoms given overlapping communities in psychopathology networks. Scientific Reports, 8, 5854.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A communicating <- comcat(A, comm = "walktrap", cent = "strength", metric = "across")
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A communicating <- comcat(A, comm = "walktrap", cent = "strength", metric = "across")
Computes the community closeness centrality measure of each community in a network
comm.close(A, comm, weighted = FALSE)
comm.close(A, comm, weighted = FALSE)
A |
An adjacency matrix of network data |
comm |
A vector or matrix corresponding to the community each node belongs to |
weighted |
Is the network weighted?
Defaults to |
A vector of community closeness centrality values for each specified community in the network (larger values suggest more central positioning)
Alexander Christensen <[email protected]>
Christensen, A. P. (in press). NetworkToolbox: Methods and measures for brain, cognitive, and psychometric network analysis in R. The R Journal, 10, 422-439.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A comm <- igraph::walktrap.community(convert2igraph(abs(A)))$membership #Weighted result <- comm.close(A, comm) #Unweighted result <- comm.close(A, comm, weighted = FALSE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A comm <- igraph::walktrap.community(convert2igraph(abs(A)))$membership #Weighted result <- comm.close(A, comm) #Unweighted result <- comm.close(A, comm, weighted = FALSE)
Computes the flow.frac for each community in the network. The values are equivalent to the community's eigenvector centrality
comm.eigen(A, comm, weighted = TRUE)
comm.eigen(A, comm, weighted = TRUE)
A |
An adjacency matrix |
comm |
A vector or matrix corresponding to the community each node belongs to |
weighted |
Is the network weighted?
Defaults to |
A vector of community eigenvector centrality values for each specified community in the network (larger values suggest more central positioning)
Alexander Christensen <[email protected]>
Giscard, P. L., & Wilson, R. C. (2018). A centrality measure for cycles and subgraphs II. Applied Network Science, 3, 9.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A comm <- igraph::walktrap.community(convert2igraph(abs(A)))$membership result <- comm.eigen(A, comm)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A comm <- igraph::walktrap.community(convert2igraph(abs(A)))$membership result <- comm.eigen(A, comm)
Computes the community
strength
/degree
centrality measure of each community in a network or computes the
strength
/degree
centrality measure of each community's connections to the other communities
comm.str(A, comm, weighted = TRUE, measure = c("within", "between"))
comm.str(A, comm, weighted = TRUE, measure = c("within", "between"))
A |
An adjacency matrix of network data |
comm |
A vector corresponding to the community each node belongs to |
weighted |
Is the network weighted?
Defaults to |
measure |
Type of measure to compute:
|
A vector of community strength/degree centrality values for each specified community in the network (larger values suggest more central positioning)
Alexander Christensen <[email protected]>
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A comm <- igraph::walktrap.community(convert2igraph(abs(A)))$membership #Strength within.ns <- comm.str(A, comm, measure = "within") between.ns <- comm.str(A, comm, measure = "between") #Degree within.deg <- comm.str(A, comm, weighted = FALSE, measure = "within") between.deg <- comm.str(A, comm, weighted = FALSE, measure = "between")
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A comm <- igraph::walktrap.community(convert2igraph(abs(A)))$membership #Strength within.ns <- comm.str(A, comm, measure = "within") between.ns <- comm.str(A, comm, measure = "between") #Degree within.deg <- comm.str(A, comm, weighted = FALSE, measure = "within") between.deg <- comm.str(A, comm, weighted = FALSE, measure = "between")
Computes the average and standard deviation of the weights in the network
conn(A)
conn(A)
A |
An adjacency matrix of a network |
Returns a list containing:
weights |
Each edge weight in the network |
mean |
The mean of the edge weights in the network |
sd |
The standard deviation of the edge weights in the network |
total |
The sum total of the edge weights in the network |
Alexander Christensen <[email protected]>
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A connectivity <- conn(A)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A connectivity <- conn(A)
Converts single or multiple networks into igraph
's format for network analysis
convert2igraph(A, neural = FALSE)
convert2igraph(A, neural = FALSE)
A |
Adjacency matrix (network matrix) or brain connectivity array
(from |
neural |
Is input a brain connectivity array (i.e., m x m x n)?
Defaults to |
Returns a network matrix in igraph
's format or
returns a list of brain connectivity matrices each of which have been
convert to igraph
's format
Alexander Christensen <[email protected]>
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A igraphNetwork <- convert2igraph(A) ## Not run: neuralarray <- convertConnBrainMat() igraphNeuralList <- convert2igraph(neuralarray, neural = TRUE) ## End(Not run)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A igraphNetwork <- convert2igraph(A) ## Not run: neuralarray <- convertConnBrainMat() igraphNeuralList <- convert2igraph(neuralarray, neural = TRUE) ## End(Not run)
Converts a Matlab brain z-score connectivity array (n x n x m) where n is the n x n connectivity matrices and m is the participant. If you would like to simply import a connectivity array from Matlab, then see the examples
convertConnBrainMat(MatlabData, progBar = TRUE)
convertConnBrainMat(MatlabData, progBar = TRUE)
MatlabData |
Input for Matlab data file. Defaults to interactive file choice |
progBar |
Should progress bar be displayed?
Defaults to |
Returns a list containing:
rmat |
Correlation matrices for each participant (m) in an array (n x n x m) |
zmat |
Z-score matrices for each participant (m) in an array (n x n x m) |
Alexander Christensen <[email protected]>
## Not run: neuralarray <- convertConnBrainMat() #Import correlation connectivity array from Matlab library(R.matlab) neuralarray<-readMat(file.choose()) ## End(Not run)
## Not run: neuralarray <- convertConnBrainMat() #Import correlation connectivity array from Matlab library(R.matlab) neuralarray<-readMat(file.choose()) ## End(Not run)
Converts a correlation matrix to a covariance matrix
cor2cov(cormat, data)
cor2cov(cormat, data)
cormat |
A correlation matrix |
data |
The dataset the correlation matrix is from |
Returns a covariance matrix
Alexander Christensen <[email protected]>
cormat <- cor(neoOpen) covmat <- cor2cov(cormat,neoOpen)
cormat <- cor(neoOpen) covmat <- cor2cov(cormat,neoOpen)
Automatically determines core, intermediary, and peripheral items in the network.
The entire network or within-community gradations can be determined. Based on the
hybrid
centrality
core.items(A, comm, by = c("network", "communities"))
core.items(A, comm, by = c("network", "communities"))
A |
An adjacency matrix of network data |
comm |
A vector or matrix corresponding to the community each node belongs to |
by |
Should the core items be defined by network or communities?
Defaults to |
Returns a list containing:
core |
Core items for each community |
inter |
Intermediate items for each community |
peri |
Peripheral items for each community |
Alexander Christensen <[email protected]>
#network # Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #core items by network coreBYnetwork <- core.items(A, by = "network") #theoretical factors comm <- c(rep(1,8),rep(2,8),rep(3,8),rep(4,8),rep(5,8),rep(6,8)) #core items by communities coreBYcomm <- core.items(A, comm, by = "communities")
#network # Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #core items by network coreBYnetwork <- core.items(A, by = "network") #theoretical factors comm <- c(rep(1,8),rep(2,8),rep(3,8),rep(4,8),rep(5,8),rep(6,8)) #core items by communities coreBYcomm <- core.items(A, comm, by = "communities")
Suite of functions for Connectome-based Predictive Modeling (CPM). See and cite Finn et al., 2015; Rosenberg et al., 2016; Shen et al., 2017
cpmIV
Internal Validation method (Rosenberg et al., 2016; Shen et al., 2017). Using a leave-one-out approach,
this method correlates a behavioral statistic bstat
with each edge of a whole-brain network across
participants. Using the significant edges in the network thresh
, a connectome model
is built (without the participant's network). A linear regression model is fit, with the behavioral
statistic being regressed on the connectome model. The left out participants connectome model is then
used with the linear regression weights to compute their predicted behavioral score. This is repeated
for every participant. The predicted scores are correlated with their observed score. Significant values
suggest that the connectome is related to the behavioral statistic
cpmIVperm
Performs a permutation test of the results obtained by cpmIV
. The permutation test quantifies
whether the results obtained by the original cpmIV
are significantly different than a random model
(see Shen et al., 2017)
cpmEV
UNDER DEVELOPMENT. External Validation method (Beaty et al., 2018). Performs similar function as cpmIV
but uses data
to train train_na
the connectome model using a behavioral statistic train_b
.
This training connectome model is then used to predict another dataset valid_na
,
using the same behavioral statistic valid_b
. The full training dataset FALSE
or
the leave-one-out overlap = TRUE
approach can be used
cpmFP
Fingerprinting method (Finn et al., 2015). Uses CPM approach to identify participants across two sessions
cpmFPperm
Fingerprinting method (Finn et al., 2015). Uses permutation method to estimate the significance of
of the cpmFP
results
cpmPlot
Plots the CPM results
cpmIV(neuralarray, bstat, kfolds, covar, thresh = .01, connections = c("separate", "overall"), groups = NULL, method = c("mean", "sum"), model = c("linear","quadratic","cubic"), corr = c("pearson","spearman"), nEdges, standardize = FALSE, cores, progBar = TRUE, plots = TRUE) cpmIVperm(iter = 1000, ...) cpmEV(train_na, train_b, valid_na, valid_b, thresh = .01, overlap = FALSE, progBar = TRUE) cpmFP(session1, session2, progBar = TRUE) cpmFPperm(session1, session2, iter = 1000, progBar = TRUE) cpmPlot(cpm.obj, visual.nets = FALSE)
cpmIV(neuralarray, bstat, kfolds, covar, thresh = .01, connections = c("separate", "overall"), groups = NULL, method = c("mean", "sum"), model = c("linear","quadratic","cubic"), corr = c("pearson","spearman"), nEdges, standardize = FALSE, cores, progBar = TRUE, plots = TRUE) cpmIVperm(iter = 1000, ...) cpmEV(train_na, train_b, valid_na, valid_b, thresh = .01, overlap = FALSE, progBar = TRUE) cpmFP(session1, session2, progBar = TRUE) cpmFPperm(session1, session2, iter = 1000, progBar = TRUE) cpmPlot(cpm.obj, visual.nets = FALSE)
neuralarray |
Array from |
bstat |
Behavioral statistic for each participant with neural data (a vector) |
kfolds |
Numeric.
Number of k-fold validation samples.
Defaults to the number of participants in the sample (i.e., n),
which is also known as leave-one-out validation.
Recommended folds are |
covar |
Covariates to be included in predicting relevant edges (time consuming).
Must be input as a |
thresh |
Sets an |
connections |
Character.
Should positive and negative correlations be separated or used together?
Defaults to |
groups |
Allows grouping variables to be used for plotting points.
Must be a vector.
Defaults to |
method |
Use |
model |
Regression model to use for fitting the data.
Defaults to |
corr |
Correlation method for assessing the relationship between the behavioral measure and edges between ROIs.
Defaults to |
nEdges |
Number of participants that are required to have an edge to appear in the plots. Defaults to 10 percent of edges in participants |
standardize |
Should the behavioral statistic ( |
cores |
Number of computer processing cores to use when performing covariate analyses. Defaults to n - 1 total number of cores. Set to any number between 1 and maximum amount of cores on your computer |
progBar |
Should progress bar be displayed?
Defaults to |
plots |
Should plots be plotted?
Defaults to |
train_na |
Training dataset
(an array from |
train_b |
Behavioral statistic for each participant for the training neural data (a vector) |
valid_na |
Validation dataset
(an array from |
valid_b |
Behavioral statistic for each participant for the validation neural data (a vector) |
overlap |
Should leave-one-out cross-validation be used?
Defaults to |
session1 |
Array from |
session2 |
Array from |
iter |
Number of iterations to perform.
Defaults to |
cpm.obj |
|
visual.nets |
Boolean.
Uses |
... |
Additional arguments to be passed from a |
cpmIV
and cpmEV
:
Returns a list containing:
results |
A matrix containing: r coefficient ( |
posMask |
Positive connectivity for input in BioImage Suite Connectivity Viewer |
negMask |
Negative connectivity for input in BioImage Suite Connectivity Viewer |
cpmIVperm
:
Returns a matrix containing p-values for positive and negative prediction models
cpmFP
:
Returns a matrix containing the percentage and number of correctly identified subjects for sessions 1 and 2
cpmPlot
:
Returns plot of connectivity differences between the positive and negative masks
Alexander Christensen <[email protected]>
Beaty, R. E., Kenett, Y. N., Christensen, A. P., Rosenberg, M. D., Benedek, M., Chen, Q., Fink, A., Qiu, J., Kwapil, T. R., Kane, M. J., & Silvia, P. J. (2018). Robust prediction of individual creative ability from brain functional connectivity. Proceedings of the National Academy of Sciences, 115, 1087-1092.
Finn, E. S., Shen, X., Scheinost, D., Rosenberg, M. D., Huang, J., Chun, M. M., Papademetris, X., Constable, R. T. (2015). Functional connectome fingerprinting: Identifying individuals using patterns of brain connectivity. Nature Neuroscience, 18, 1664-1671.
Rosenberg, M. D., Finn, E. S., Scheinost, D., Papademetris, X., Shen, X., Constable, R. T., Chun, M. M. (2016). A neuromarker of sustained attention from whole-brain functional connectivity. Nature Neuroscience, 19, 165-171.
Shen, X. Finn, E. S., Scheinost, D., Rosenberg, M. D., Chun, M. M., Papademetris, X., Constable, R. T. (2017). Using connectome-based predictive modeling to predict individual behavior from brain connectivity. Nature Protocols, 12, 506-518.
Wei, T. & Simko, V.(2017). R package "corrplot": Visualization of a correlation matrix (Version 0.84).
# Load data behav <- behavOpen ## Not run: # Create path to temporary file temp <- tempfile() # Download to temporary file googledrive::drive_download( paste("https://drive.google.com/file/d/", "1T7_mComB6HPxJxZZwwsLLSYHXsOuvOBt", "/view?usp=sharing", sep = ""), path = temp ) # Load resting state brain data load(temp) # Run cpmIV res <- cpmIV(neuralarray = restOpen, bstat = behav, cores = 4) # Plot cpmIV results cpmPlot(res) ## End(Not run)
# Load data behav <- behavOpen ## Not run: # Create path to temporary file temp <- tempfile() # Download to temporary file googledrive::drive_download( paste("https://drive.google.com/file/d/", "1T7_mComB6HPxJxZZwwsLLSYHXsOuvOBt", "/view?usp=sharing", sep = ""), path = temp ) # Load resting state brain data load(temp) # Run cpmIV res <- cpmIV(neuralarray = restOpen, bstat = behav, cores = 4) # Plot cpmIV results cpmPlot(res) ## End(Not run)
Computes the distance correlation (Yoo et al., 2019) for
ROI time series data. This function is mainly a subroutine for the
dCor.parallel
function
dCor(neurallist, centering = c("U", "double"))
dCor(neurallist, centering = c("U", "double"))
neurallist |
List.
A time series list from |
centering |
Character. Options for centering the Euclidean distances.
|
Returns a m x m matrix corresponding to distance correlations between ROIs
Alexander Christensen <[email protected]>
Yoo, K., Rosenberg, M. D., Noble, S., Scheinost, D., Constable, R. T., & Chun, M. M. (2019). Multivariate approaches improve the reliability and validity of functional connectivity and prediction of individual behaviors. NeuroImage, 197, 212-223.
## Not run: # Import time series data neurallist <- convertConnBrainMat() # Run distance correlation dCor(neurallist) ## End(Not run)
## Not run: # Import time series data neurallist <- convertConnBrainMat() # Run distance correlation dCor(neurallist) ## End(Not run)
Parallelizes the dCor
function
for faster computation times
dCor.parallel(neurallist, cores)
dCor.parallel(neurallist, cores)
neurallist |
List of lists.
A list containing the time series list from all participants imported from the
|
cores |
Number of computer processing cores to use when performing covariate analyses. Defaults to n - 1 total number of cores. Set to any number between 1 and maximum amount of cores on your computer |
Returns a m x m x n array corresponding to distance correlations between ROIs (m x m matrix) for n participants
Alexander Christensen <[email protected]>
Yoo, K., Rosenberg, M. D., Noble, S., Scheinost, D., Constable, R. T., & Chun, M. M. (2019). Multivariate approaches improve the reliability and validity of functional connectivity and prediction of individual behaviors. NeuroImage, 197, 212-223.
## Not run: # Import time series data for(i in 1:5) # Run distance correlation dCor.parallel(mat.list, cores = 2) ## End(Not run)
## Not run: # Import time series data for(i in 1:5) # Run distance correlation dCor.parallel(mat.list, cores = 2) ## End(Not run)
Computes degree of each node in a network
degree(A)
degree(A)
A |
An adjacency matrix of network data |
A vector of degree values for each node in the network.
If directed network, returns a list containing:
inDegree |
Degree of incoming edges (pointing to the node) |
outDegree |
Degree of outgoing edges (pointing away from the node) |
relInf |
Relative degree of incoming and outgoing edges. Positive values indicate more outgoing degree relative to incoming degree. Negative values indicate more incoming degree relative to outgoing degree |
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
#Undirected network ## Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A deg <- degree(A) #Directed network ## Not run: dep <- depend(neoOpen) Adep <- TMFG(dep, depend = TRUE)$A deg <- degree(Adep) ## End(Not run)
#Undirected network ## Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A deg <- degree(A) #Directed network ## Not run: dep <- depend(neoOpen) Adep <- TMFG(dep, depend = TRUE)$A deg <- degree(Adep) ## End(Not run)
Generates a dependency matrix of the data (index argument is still in testing phase)
depend( data, normal = FALSE, na.data = c("pairwise", "listwise", "fiml", "none"), index = FALSE, fisher = FALSE, progBar = TRUE )
depend( data, normal = FALSE, na.data = c("pairwise", "listwise", "fiml", "none"), index = FALSE, fisher = FALSE, progBar = TRUE )
data |
A set of data |
normal |
Should data be transformed to a normal distribution?
Defaults to |
na.data |
How should missing data be handled?
For |
index |
Should correlation with the latent variable
(i.e., weighted average of all variables) be removed?
Defaults to |
fisher |
Should Fisher's Z-test be used to keep significantly higher influences (index only)?
Defaults to |
progBar |
Should progress bar be displayed?
Defaults to |
Returns an adjacency matrix of dependencies
Alexander Christensen <[email protected]>
Kenett, D. Y., Tumminello, M., Madi, A., Gur-Gershgoren, G., Mantegna, R. N., & Ben-Jacob, E. (2010). Dominating clasp of the financial sector revealed by partial correlation analysis of the stock market. PLoS one, 5, e15032.
Kenett, D. Y., Huang, X., Vodenska, I., Havlin, S., & Stanley, H. E. (2015). Partial correlation analysis: Applications for financial markets. Quantitative Finance, 15, 569-578.
## Not run: D <- depend(neoOpen) Dindex <- depend(neoOpen, index = TRUE) ## End(Not run)
## Not run: D <- depend(neoOpen) Dindex <- depend(neoOpen, index = TRUE) ## End(Not run)
Applies the dependency network approach to neural network array
depna(neuralarray, cores, ...)
depna(neuralarray, cores, ...)
neuralarray |
Array from |
cores |
Numeric.
Number of cores to use in computing results.
Set to |
... |
Additional arguments from |
Returns an array of n x n x m dependency matrices
Alexander Christensen <[email protected]>
Jacob, Y., Winetraub, Y., Raz, G., Ben-Simon, E., Okon-Singer, H., Rosenberg-Katz, K., ... & Ben-Jacob, E. (2016). Dependency Network Analysis (DEPNA) reveals context related influence of brain network nodes. Scientific Reports, 6, 27444.
Kenett, D. Y., Tumminello, M., Madi, A., Gur-Gershgoren, G., Mantegna, R. N., & Ben-Jacob, E. (2010). Dominating clasp of the financial sector revealed by partial correlation analysis of the stock market. PLoS one, 5, e15032.
## Not run: neuralarray <- convertConnBrainMat() dependencyneuralarray <- depna(neuralarray) ## End(Not run)
## Not run: neuralarray <- convertConnBrainMat() dependencyneuralarray <- depna(neuralarray) ## End(Not run)
Computes mean
, standard deviation (sd
), minimum value (min
),
maximum value (max
),
and univariate normal statistics (normal?
) for a variable
desc(data, column, histplot = TRUE)
desc(data, column, histplot = TRUE)
data |
A matrix or data frame |
column |
Column name or number in |
histplot |
A histogram plot of the variable |
A data frame containing values for n
(number of cases),
missing
(number of missing cases), mean
, sd
, min
, and max
. normal?
will contain yes/no for whether the variable is normally distributed based
on the shapiro.test
for a variable
Alexander Christensen <[email protected]>
desc(neoOpen,1)
desc(neoOpen,1)
Computes mean
, standard deviation (sd
), minimum value (min
),
maximum value (max
),
and univariate normal statistics (normal?
) for the entire dataset
desc.all(data)
desc.all(data)
data |
A matrix or data frame |
A data frame containing values for n
(number of cases),
missing
(number of missing cases), mean
, sd
, min
, and max
. normal?
will contain yes/no for whether the variable is normally distributed based
on the shapiro.test
for the entire dataset
Alexander Christensen <[email protected]>
desc.all(neoOpen)
desc.all(neoOpen)
Computes distance matrix of the network
distance(A, weighted = FALSE)
distance(A, weighted = FALSE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
A distance matrix of the network
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Unweighted Du <- distance(A) #Weighted Dw <- distance(A, weighted = TRUE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Unweighted Du <- distance(A) #Weighted Dw <- distance(A, weighted = TRUE)
Computes the diversity coefficient for each node. The diversity coefficient measures a node's connections to communitites outside of its own community. Nodes that have many connections to other communities will have higher diversity coefficient values. Positive and negative signed weights for diversity coefficients are computed separately.
diversity(A, comm = c("walktrap", "louvain"))
diversity(A, comm = c("walktrap", "louvain"))
A |
Network adjacency matrix |
comm |
A vector of corresponding to each item's community.
Defaults to |
Values closer to 1 suggest greater between-community connectivity and values closer to 0 suggest greater within-community connectivity
Returns a list containing:
overall |
Diversity coefficient without signs considered |
positive |
Diversity coefficient with only positive sign |
negative |
Diversity coefficient with only negative sign |
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #theoretical communities comm <- rep(1:8, each = 6) gdiv <- diversity(A, comm = comm) #walktrap communities wdiv <- diversity(A, comm = "walktrap")
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #theoretical communities comm <- rep(1:8, each = 6) gdiv <- diversity(A, comm = comm) #walktrap communities wdiv <- diversity(A, comm = "walktrap")
Applies the ECO neural network filtering method
ECO(data, directed = FALSE)
ECO(data, directed = FALSE)
data |
Can be a dataset or a correlation matrix |
directed |
Is the network directed?
Defaults to |
A sparse association matrix
Alexander Christensen <[email protected]>
Fallani, F. D. V., Latora, V., & Chavez, M. (2017). A topological criterion for filtering information in complex brain networks. PLoS Computational Biology, 13, e1005305.
eco.net <- ECO(neoOpen)
eco.net <- ECO(neoOpen)
Applies the ECO
neural network filtering method
combined with the MaST
filtering method
ECOplusMaST(data)
ECOplusMaST(data)
data |
Can be a dataset or a correlation matrix |
A sparse association matrix
Alexander Christensen <[email protected]>
Fallani, F. D. V., Latora, V., & Chavez, M. (2017). A topological criterion for filtering information in complex brain networks. PLoS Computational Biology, 13, e1005305.
# half the variables for CRAN checks ECOplusMaST.net <- ECOplusMaST(neoOpen[,c(1:24)])
# half the variables for CRAN checks ECOplusMaST.net <- ECOplusMaST(neoOpen[,c(1:24)])
Computes the number of edges that replicate between two cross-sectional networks
edgerep(A, B, corr = c("pearson", "spearman", "kendall"))
edgerep(A, B, corr = c("pearson", "spearman", "kendall"))
A |
An adjacency matrix of network A |
B |
An adjacency matrix of network B |
corr |
Correlation method for assessing the relationship between the replicated edge weights.
Defaults to |
Returns a list containing:
replicatedEdges |
The edges that replicated and their weights |
replicated |
Number of edges that replicated |
meanDiff |
The average edge weight difference between the edges that replicated |
sdDiff |
The standard deviation edge weight difference between the edges that replicated |
cor |
The correlation between the edges that replicated |
Lists for each network contain:
totalEdges |
Total possible number of edges to be replicated |
percentage |
Percentage of edges that replicated relative to total possible |
density |
The density of the network |
Alexander Christensen <[email protected]>
# normal set to FALSE for CRAN tests tmfg <- TMFG(neoOpen, normal = FALSE)$A # normal set to FALSE for CRAN tests mast <- MaST(neoOpen, normal = FALSE) edges <- edgerep(tmfg, mast)
# normal set to FALSE for CRAN tests tmfg <- TMFG(neoOpen, normal = FALSE)$A # normal set to FALSE for CRAN tests mast <- MaST(neoOpen, normal = FALSE) edges <- edgerep(tmfg, mast)
Computes eigenvector centrality of each node in a network
eigenvector(A, weighted = TRUE)
eigenvector(A, weighted = TRUE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
A vector of eigenvector centrality values for each node in the network
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted EC <- eigenvector(A) #Unweighted EC <- eigenvector(A, weighted = FALSE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted EC <- eigenvector(A) #Unweighted EC <- eigenvector(A, weighted = FALSE)
Computes eigenvector
centrality over nodes in a subset of nodes
in the network. This measure generalizes across any subset of nodes and
is not specific to communities
flow.frac(A, nodes)
flow.frac(A, nodes)
A |
An adjacency matrix |
nodes |
A subset of nodes in the network |
Returns a flow fraction value
Alexander Christensen <[email protected]>
Giscard, P. L., & Wilson, R. C. (2018). A centrality measure for cycles and subgraphs II. Applied Network Science, 3, 9.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A nodes <- seq(1,48,2) result <- flow.frac(A, nodes)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A nodes <- seq(1,48,2) result <- flow.frac(A, nodes)
These functions maximize a gain criterion
for adding a node to a clique (and the larger network).
The flexibility of MFCF
allows for any multivariate function to be used as a
scoring function.
"logLik"
The log determinant of the matrix restricted to the separator minus the log determinant of the matrix restricted to the clique.
"logLik.val"
"logLik"
with a further validation based on
the likelihood ratio. If the increase in gain is not significant
the routine stops adding nodes to the separator.
"rSquared.val"
The R squared from the regression of the node against the clique. Only
the clique nodes with a regression coefficient significantly different
from zero are added to the separator / new clique. The gain is different from
zero only if the F-values is significant, It assumed that the data
matrix is a dataset of realizations (i.e., p
variables and n
observations).
"logLik" gfcnv_logdet(data, clique_id, cl, excl_nodes, ctreeControl) "logLik.val" gfcnv_logdet_val(data, clique_id, cl, excl_nodes, ctreeControl) "rSquared.val" gdcnv_lmfit(data, clique_id, cl, excl_nodes, ctreeControl)
"logLik" gfcnv_logdet(data, clique_id, cl, excl_nodes, ctreeControl) "logLik.val" gfcnv_logdet_val(data, clique_id, cl, excl_nodes, ctreeControl) "rSquared.val" gdcnv_lmfit(data, clique_id, cl, excl_nodes, ctreeControl)
data |
Matrix or data frame. Can be a dataset or a correlation matrix |
clique_id |
Numeric. Number corresponding to clique to add another node to |
cl |
List. List of cliques already assembled in the network |
excl_nodes |
Numeric vector. A vector of numbers corresponding to nodes not already included in the network |
ctreeControl |
List (length = 5). A list containing several parameters for controlling the clique tree sizes:
|
Returns the value with the maximum gain
Guido Previde Massara <[email protected]> and Alexander Christensen <[email protected]>
Massara, G. P. & Aste, T. (2019). Learning clique forests. ArXiv.
Computes the gateway coefficient for each node. The gateway coefficient measures a node's connections between its community and other communities. Nodes that are solely responsible for inter-community connectivity will have higher gateway coefficient values. Positive and negative signed weights for gateway coefficients are computed separately.
gateway( A, comm = c("walktrap", "louvain"), cent = c("strength", "betweenness") )
gateway( A, comm = c("walktrap", "louvain"), cent = c("strength", "betweenness") )
A |
Network adjacency matrix |
comm |
A vector of corresponding to each item's community.
Defaults to |
cent |
Centrality to community gateway coefficient.
Defaults to |
Returns a list containing:
overall |
Gateway coefficient without signs considered |
positive |
Gateway coefficient with only positive sign |
negative |
Gateway coefficient with only negative sign |
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
Vargas, E. R., & Wahl, L. M. (2014). The gateway coefficient: A novel metric for identifying critical connections in modular networks. The European Physical Journal B, 87, 1-10.
#theoretical communities comm <- rep(1:8, each = 6) # Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A gw <- gateway(A, comm = comm) #walktrap communities wgw <- gateway(A, comm = "walktrap")
#theoretical communities comm <- rep(1:8, each = 6) # Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A gw <- gateway(A, comm = comm) #walktrap communities wgw <- gateway(A, comm = "walktrap")
Computes hybrid centrality of each node in a network
hybrid(A, BC = c("standard", "random"), beta)
hybrid(A, BC = c("standard", "random"), beta)
A |
An adjacency matrix of network data |
BC |
How should the betweenness centrality be computed?
Defaults to |
beta |
Beta parameter to be passed to the |
A vector of hybrid centrality values for each node in the network (higher values are more central, lower values are more peripheral)
Alexander Christensen <[email protected]>
Christensen, A. P., Kenett, Y. N., Aste, T., Silvia, P. J., & Kwapil, T. R. (2018). Network structure of the Wisconsin Schizotypy Scales-Short Forms: Examining psychometric network filtering approaches. Behavior Research Methods, 50, 2531-2550.
Pozzi, F., Di Matteo, T., & Aste, T. (2013). Spread of risk across financial markets: Better to invest in the peripheries. Scientific Reports, 3, 1655.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A HC <- hybrid(A)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A HC <- hybrid(A)
Computes impact measure or how much the average distance in the network changes with that node removed of each node in a network (Please see and cite Kenett et al., 2011)
impact(A)
impact(A)
A |
An adjacency matrix of network data |
A vector of node impact values for each node in the network (impact > 0, greater ASPL when node is removed; impact < 0, lower ASPL when node is removed)
Alexander Christensen <[email protected]>
Cotter, K. N., Christensen, A. P., & Silvia, P. J. (in press). Understanding inner music: A dimensional approach to musical imagery. Psychology of Aesthetics, Creativity, and the Arts.
Kenett, Y. N., Kenett, D. Y., Ben-Jacob, E., & Faust, M. (2011). Global and local features of semantic networks: Evidence from the Hebrew mental lexicon. PLoS one, 6, e23912.
# normal set to FALSE for CRAN tests A <- TMFG(neoOpen, normal = FALSE)$A nodeimpact <- impact(A)
# normal set to FALSE for CRAN tests A <- TMFG(neoOpen, normal = FALSE)$A nodeimpact <- impact(A)
Tests for whether the network is graphical. Input must be a partial correlation network. Function assumes that partial correlations were computed from a multivariate normal distribution
is.graphical(A)
is.graphical(A)
A |
A partial correlation network (adjacency matrix) |
Returns a TRUE/FALSE for whether network is graphical
Alexander Christensen <[email protected]>
## Not run: A <- LoGo(neoOpen, normal = TRUE, partial = TRUE) is.graphical(A) ## End(Not run)
## Not run: A <- LoGo(neoOpen, normal = TRUE, partial = TRUE) is.graphical(A) ## End(Not run)
Estimates the Kullback-Leibler Divergence which measures how one probability distribution diverges from the original distribution (equivalent means are assumed) Matrices must be positive definite inverse covariance matrix for accurate measurement. This is a relative metric
kld(base, test)
kld(base, test)
base |
Full or base model |
test |
Reduced or testing model |
A value greater than 0. Smaller values suggest the probability distribution of the reduced model is near the full model
Alexander Christensen <[email protected]>
Kullback, S., & Leibler, R. A. (1951). On information and sufficiency. The Annals of Mathematical Statistics, 22, 79-86.
A1 <- solve(cov(neoOpen)) ## Not run: A2 <- LoGo(neoOpen) kld_value <- kld(A1, A2) ## End(Not run)
A1 <- solve(cov(neoOpen)) ## Not run: A2 <- LoGo(neoOpen) kld_value <- kld(A1, A2) ## End(Not run)
Generates a lattice network
lattnet(nodes, edges)
lattnet(nodes, edges)
nodes |
Number of nodes in lattice network |
edges |
Number of edges in lattice network |
Returns an adjacency matrix of a lattice network
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
latt <- lattnet(10, 27)
latt <- lattnet(10, 27)
Computes leverage centrality of each node in a network (the degree of connected neighbors; Please see and cite Joyce et al., 2010)
leverage(A, weighted = TRUE)
leverage(A, weighted = TRUE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
A vector of leverage centrality values for each node in the network
Alexander Christensen <[email protected]>
Joyce, K. E., Laurienti, P. J., Burdette, J. H., & Hayasaka, S. (2010). A new measure of centrality for brain networks. PLoS One, 5 e12200.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted levW <- leverage(A) #Unweighted levU <- leverage(A, weighted = FALSE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Weighted levW <- leverage(A) #Unweighted levU <- leverage(A, weighted = FALSE)
Applies the Local/Global method to estimate
a Gaussian Graphical Model (GGM) using a TMFG
-filtered network
(see and cite Barfuss et al., 2016). Also used to
convert clique and separator structure from
MFCF
into partial correlation
and precision matrices
LoGo( data, cliques, separators, normal = TRUE, na.data = c("pairwise", "listwise", "fiml", "none"), partial = TRUE, ... )
LoGo( data, cliques, separators, normal = TRUE, na.data = c("pairwise", "listwise", "fiml", "none"), partial = TRUE, ... )
data |
Must be a dataset |
cliques |
Cliques defined in the network. Input can be a list or matrix |
separators |
Separators defined in the network. Input can be a list or matrix |
normal |
Should data be transformed to a normal distribution?
Defaults to |
na.data |
How should missing data be handled?
For |
partial |
Should the output network's connections be the partial correlation between two nodes given all other nodes?
Defaults to |
... |
Additional arguments (deprecated arguments) |
Returns the sparse LoGo-filtered inverse covariance matrix (partial = FALSE
)
or LoGo-filtered partial correlation matrix (partial = TRUE
)
Alexander Christensen <[email protected]>
Barfuss, W., Massara, G. P., Di Matteo, T., & Aste, T. (2016). Parsimonious modeling with information filtering networks. Physical Review E, 94, 062306.
# normal set to FALSE for CRAN tests LoGonet <- LoGo(neoOpen, normal = FALSE, partial = TRUE)
# normal set to FALSE for CRAN tests LoGonet <- LoGo(neoOpen, normal = FALSE, partial = TRUE)
Computes a vector of communities (community) and a global modularity measure (Q)
louvain(A, gamma, M0)
louvain(A, gamma, M0)
A |
An adjacency matrix of network data |
gamma |
Defaults to |
M0 |
Input can be an initial community vector.
Defaults to |
Returns a list containing:
community |
A community vector corresponding to each node's community |
Q |
Modularity statistic. A measure of how well the communities are compartmentalized |
Alexander Christensen <[email protected]>
Blondel, V. D., Guillaume, J. L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics: Theory and Experiment, 2008, P10008.
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A modularity <- louvain(A)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A modularity <- louvain(A)
Applies the Maximum Spanning Tree (MaST) filtering method
MaST( data, normal = TRUE, na.data = c("pairwise", "listwise", "fiml", "none"), depend = FALSE )
MaST( data, normal = TRUE, na.data = c("pairwise", "listwise", "fiml", "none"), depend = FALSE )
data |
Can be a dataset or a correlation matrix |
normal |
Should data be transformed to a normal distribution?
Input must be a dataset.
Defaults to |
na.data |
How should missing data be handled?
For |
depend |
Is network a dependency (or directed) network?
Defaults to |
A sparse association matrix
Alexander Christensen <[email protected]>
# Pearson's correlation only for CRAN checks MaST.net <- MaST(neoOpen, normal = FALSE)
# Pearson's correlation only for CRAN checks MaST.net <- MaST(neoOpen, normal = FALSE)
Applies the Maximally Filtered Clique Forest (MFCF) filtering method (Please see and cite Massara & Aste).
MFCF( data, cases = NULL, na.data = c("pairwise", "listwise", "fiml", "none"), time.series = FALSE, gain.fxn = c("logLik", "logLik.val", "rSquared.val"), min_size = 0, max_size = 8, pval = 0.05, pen = 0, drop_sep = FALSE, use_returns = FALSE )
MFCF( data, cases = NULL, na.data = c("pairwise", "listwise", "fiml", "none"), time.series = FALSE, gain.fxn = c("logLik", "logLik.val", "rSquared.val"), min_size = 0, max_size = 8, pval = 0.05, pen = 0, drop_sep = FALSE, use_returns = FALSE )
data |
Matrix (n |
cases |
Numeric. If |
na.data |
Character. How should missing data be handled?
|
time.series |
Boolean.
Is |
gain.fxn |
Character.
Gain function to be used for inclusion of nodes in cliques.
There are several options available
(see |
min_size |
Numeric. Minimum number of nodes allowed per
clique. Defaults to |
max_size |
Numeric. Maximum number of nodes allowed per
clique. Defaults to |
pval |
Numeric. p-value used to determine cut-offs for nodes to include in a clique |
pen |
Numeric. Multiplies the number of edges added to penalise complex models. Similar to the penalty term in AIC |
drop_sep |
Boolean. This parameter influences the MFCF only.
Defaults to |
use_returns |
Boolean. Only used in |
Returns a list containing:
A |
MFCF filtered partial correlation network (adjacency matrix) |
J |
MFCF filtered inverse covariance matrix (precision matrix) |
cliques |
Cliques in the network
(output for |
separators |
Separators in the network
(output for |
Guido Previde Massara <[email protected]> and Alexander Christensen <[email protected]>
Massara, G. P. & Aste, T. (2019). Learning clique forests. ArXiv.
# Load data data <- neoOpen ## Not run: # Use polychoric correlations and R-squared method MFCF.net <- MFCF(qgraph::cor_auto(data), cases = nrow(neoOpen))$A ## End(Not run)
# Load data data <- neoOpen ## Not run: # Use polychoric correlations and R-squared method MFCF.net <- MFCF(qgraph::cor_auto(data), cases = nrow(neoOpen))$A ## End(Not run)
A response matrix (n = 802) of NEO-PI-3's Openness to Experience from Christensen, Cotter, & Silvia (2019).
data(neoOpen)
data(neoOpen)
A 802x48 response matrix
Christensen, A. P., Cotter, K. N., & Silvia, P. J. (2019). Reopening openness to experience: A network analysis of four openness to experience inventories. Journal of Personality Assessment, 101, 574-588.
data("neoOpen")
data("neoOpen")
Computes the mean distance across a subset of nodes in a network. This measure can be used to identify the effectiveness of a subset of nodes' coverage of the network space
net.coverage(A, nodes, weighted = FALSE)
net.coverage(A, nodes, weighted = FALSE)
A |
An adjacency matrix |
nodes |
Subset of nodes to examine the coverage of the network |
weighted |
Is the network weighted?
Defaults to |
Returns a list containing:
mean |
The average distance from the subset of nodes to all other nodes in the network |
sd |
The standard deviation of distance from the subset of nodes to all other nodes in the network |
range |
The range of distance from the subset of nodes to all other nodes in the network |
Alexander Christensen <[email protected]> and Mathias Benedek <[email protected]>
Christensen, A. P., Cotter, K. N., Silvia, P. J., & Benedek, M. (2018) Scale development via network analysis: A comprehensive and concise measure of Openness to Experience PsyArXiv, 1-40.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A nodes <- seq(1,48,2) result <- net.coverage(A, nodes)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A nodes <- seq(1,48,2) result <- net.coverage(A, nodes)
Computes the mean distance across a subset of nodes in a network. This measure can be used to identify the effectiveness of a subset of nodes' coverage of the network space
network.coverage(A, nodes, weighted = FALSE)
network.coverage(A, nodes, weighted = FALSE)
A |
An adjacency matrix |
nodes |
Subset of nodes to examine the coverage of the network |
weighted |
Is the network weighted?
Defaults to |
Returns a list containing:
mean |
The average distance from the subset of nodes to all other nodes in the network |
sd |
The standard deviation of distance from the subset of nodes to all other nodes in the network |
range |
The range of distance from the subset of nodes to all other nodes in the network |
Alexander Christensen <[email protected]> and Mathias Benedek <[email protected]>
Christensen, A. P., Cotter, K. N., Silvia, P. J., & Benedek, M. (2018) Scale development via network analysis: A comprehensive and concise measure of Openness to Experience PsyArXiv, 1-40.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A nodes <- seq(1,48,2) result <- network.coverage(A, nodes)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A nodes <- seq(1,48,2) result <- network.coverage(A, nodes)
Computes a permutation test to determine whether there are difference in centrality and global network measures
network.permutation( sample1 = NULL, sample2 = NULL, iter, network = c("glasso", "ising", "TMFG", "LoGo"), measure = c("betweenness", "closeness", "strength", "eigenvector", "rspbc", "hybrid", "ASPL", "CC", "S", "Q"), alternative = c("less", "greater", "two.tailed"), ncores, prev.perm = NULL, ... )
network.permutation( sample1 = NULL, sample2 = NULL, iter, network = c("glasso", "ising", "TMFG", "LoGo"), measure = c("betweenness", "closeness", "strength", "eigenvector", "rspbc", "hybrid", "ASPL", "CC", "S", "Q"), alternative = c("less", "greater", "two.tailed"), ncores, prev.perm = NULL, ... )
sample1 |
Matrix or data frame.
Sample to be compared with |
sample2 |
Matrix or data frame.
Sample to be compared with |
iter |
Numeric.
Number of iterations to perform.
Defaults to |
network |
Character.
Network estimation method to apply to the datasets.
Defaults to |
measure |
Character. Network measure to be compared in the permutation test |
alternative |
Character.
Alternative hypothesis test to perform.
Defaults to |
ncores |
Numeric.
Number of computer processing cores to use for bootstrapping samples.
Defaults to n - 1 total number of cores.
Set to any number between 1 and maximum amount of cores on your computer
(see |
prev.perm |
|
... |
Additional arguments for |
Returns a list containing two objects:
result |
The results of the permutation test. For centrality measures,
this is a matrix where the rows represent each node and the columns are
the observed values of the centrality measure for |
networks |
A list containing two lists: |
Alexander Christensen <[email protected]>
# Split data (only for example) split1 <- neoOpen[c(1:401),] split2 <- neoOpen[c(402:802),] # Perform permutation test perm.str <- network.permutation(split1, split2, iter = 1000, network = "glasso", measure = "strength", alternative = "two.tailed", ncores = 2) # Check results perm.str$result # Permutation to check other measures (using networks from previous result) perm.aspl <- network.permutation(prev.perm = perm.str, measure = "ASPL", ncores = 2) # Check results perm.aspl$result
# Split data (only for example) split1 <- neoOpen[c(1:401),] split2 <- neoOpen[c(402:802),] # Perform permutation test perm.str <- network.permutation(split1, split2, iter = 1000, network = "glasso", measure = "strength", alternative = "two.tailed", ncores = 2) # Check results perm.str$result # Permutation to check other measures (using networks from previous result) perm.aspl <- network.permutation(prev.perm = perm.str, measure = "ASPL", ncores = 2) # Check results perm.aspl$result
Applies a network filtering methodology to neural network array.
Removes edges from the neural network output from convertConnBrainMat
using a network filtering approach
neuralnetfilter( neuralarray, method = c("TMFG", "MaST", "ECOplusMaST", "ECO", "threshold"), progBar = TRUE, ... )
neuralnetfilter( neuralarray, method = c("TMFG", "MaST", "ECOplusMaST", "ECO", "threshold"), progBar = TRUE, ... )
neuralarray |
Array from |
method |
Filtering method to be applied |
progBar |
Should progress bar be displayed?
Defaults to |
... |
Additional arguments from network filtering methods |
Returns an array of n x n x m filtered matrices
Alexander Christensen <[email protected]>
## Not run: neuralarray <- convertConnBrainMat() filteredneuralarray <- neuralnetfilter(neuralarray, method = "threshold", thresh = .50) dependencyarray <- depna(neuralarray) filtereddependencyarray <- neuralnetfilter(dependencyarray, method = "TMFG", depend = TRUE) ## End(Not run)
## Not run: neuralarray <- convertConnBrainMat() filteredneuralarray <- neuralnetfilter(neuralarray, method = "threshold", thresh = .50) dependencyarray <- depna(neuralarray) filtereddependencyarray <- neuralnetfilter(dependencyarray, method = "TMFG", depend = TRUE) ## End(Not run)
A response matrix (n = 794) of all four Openness to Experience inventories from Christensen, Cotter, & Silvia (2019). The key provides inventory, facet, and item description information for the item labels. Note that because of NEO's copyrights the items have been shortened and paraphrased
data(openness) data(openness.key)
data(openness) data(openness.key)
A 794 x 138 response matrix (openness) and 138 x 7 matrix (openness.key). Here are detailed descriptions of the key:
Inventory
The personality inventory the item belongs to
Facet
The personality inventory defined facet
JPA.Domains
The broad domains identified by Christensen, Cotter, and Silvia (2019)
JPA.Facets
The facets identified by Christensen, Cotter, and Silvia (2019)
Item.Label
The labels used in Christensen, Cotter, and Silvia (2019)
Item.Description
Descriptions of each item. Note that the NEO-PI-3 items are protected by
copyright and therefore have been paraphrased. These item descriptions
do not represent the item as given to the participant
Reversed
Whether an item should be reversed or not (openness
is already reversed)
Christensen, A. P., Cotter, K. N., & Silvia, P. J. (2019). Reopening openness to experience: A network analysis of four openness to experience inventories. Journal of Personality Assessment, 101, 574-588.
# Loading data data("openness") data("openness.key") # Change item labels colnames(openness) <- openness.key$Item.Description
# Loading data data("openness") data("openness.key") # Change item labels colnames(openness) <- openness.key$Item.Description
Computes the participation coefficient for each node. The participation coefficient measures the strength of a node's connections within its community. Positive and negative signed weights for participation coefficients are computed separately.
participation(A, comm = c("walktrap", "louvain"))
participation(A, comm = c("walktrap", "louvain"))
A |
Network adjacency matrix |
comm |
A vector of corresponding to each item's community.
Defaults to |
Values closer to 0 suggest greater within-community connectivity and values closer to 1 suggest greater between-community connectivity
Returns a list containing:
overall |
Participation coefficient without signs considered |
positive |
Participation coefficient with only positive sign |
negative |
Participation coefficient with only negative sign |
Alexander Christensen <[email protected]>
Guimera, R., & Amaral, L. A. N. (2005). Functional cartography of complex metabolic networks. Nature, 433, 895-900.
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
#theoretical factors comm <- rep(1:8, each = 6) # Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A pc <- participation(A, comm = comm) # Walktrap factors wpc <- participation(A, comm = "walktrap")
#theoretical factors comm <- rep(1:8, each = 6) # Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A pc <- participation(A, comm = comm) # Walktrap factors wpc <- participation(A, comm = "walktrap")
Computes global average shortest path length, local average shortest path length, eccentricity, and diameter of a network
pathlengths(A, weighted = FALSE)
pathlengths(A, weighted = FALSE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
Returns a list containing:
ASPL |
Global average shortest path length |
ASPLi |
Local average shortest path length |
ecc |
Eccentricity (i.e., maximal shortest path length between a node and any other node) |
D |
Diameter of the network (i.e., the maximum of eccentricity) |
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Unweighted PL <- pathlengths(A) #Weighted PL <- pathlengths(A, weighted = TRUE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A #Unweighted PL <- pathlengths(A) #Weighted PL <- pathlengths(A, weighted = TRUE)
Plots CPM results
## S3 method for class 'cpm' plot(x, ...)
## S3 method for class 'cpm' plot(x, ...)
x |
A |
... |
Additional arguments for plot |
Alexander Christensen <[email protected]>
Generates a random binary network
randnet(nodes = NULL, edges = NULL, A = NULL)
randnet(nodes = NULL, edges = NULL, A = NULL)
nodes |
Numeric. Number of nodes in random network |
edges |
Numeric. Number of edges in random network |
A |
Matrix or data frame. An adjacency matrix (i.e., network) to be used to estimated a random network with fixed edges (allows for asymmetric network estimation) |
Returns an adjacency matrix of a random network
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
Csardi, G., & Nepusz, T. (2006). The igraph software package for complex network research. InterJournal, Complex Systems, 1695.
rand <- randnet(10, 27)
rand <- randnet(10, 27)
Computes regression such that one variable is regressed over all other variables
reg( data, family = c("binomial", "gaussian", "Gamma", "poisson"), symmetric = TRUE )
reg( data, family = c("binomial", "gaussian", "Gamma", "poisson"), symmetric = TRUE )
data |
A dataset |
family |
Error distribution to be used in the regression model.
Defaults to |
symmetric |
Should matrix be symmetric?
Defaults to |
A matrix of fully regressed coefficients where one variable is regressed over all others
Alexander Christensen <[email protected]>
#binarize responses psyb <- ifelse(neoOpen>=4, 1, 0) #perform logistic regression mat <- reg(psyb)
#binarize responses psyb <- ifelse(neoOpen>=4, 1, 0) #perform logistic regression mat <- reg(psyb)
Screens data to identify potential cases of repeated responding.
The function is based on two criteria: no variance (i.e., a standard
deviation of zero for given responses)and frequency proportion of the
response values (which is set by freq.prop
). Note that these
criteria are highly related. Additional criteria will be added in
the future.
resp.rep(data, scale.lens = NULL, max.val, reverse = NULL, freq.prop = 0.8)
resp.rep(data, scale.lens = NULL, max.val, reverse = NULL, freq.prop = 0.8)
data |
A dataset |
scale.lens |
The number of items for each scale in the data. A vector indicating the length for each scale to be checked in the data |
max.val |
Maximum value for data (or scales). If scales have different maximum values, then a vector must be input with each scale's maximum value (see examples) |
reverse |
Reverse scored responses. If responses have not yet reversed, then do not reverse them. If responses have been reversed, then a vector indicating which responses have been reverse-scored should be input (see examples). Can be TRUE/FALSE or 1/0 (reversed/not reversed) |
freq.prop |
Frequency proportion of the response values.
Allows the researcher to determine the maximum frequency proportion
of a certain response value is suspicious.
The default is set to |
If a case is returned, then it does not mean that it is a bad case. Researchers should thoroughly inspect each case that is returned. A general guideline is that if a participant responded with all middle values (e.g., all 3's on a 5-point Likert scale), then they should be dropped. Note that a participant who responds with all maximum or minimum values may be a real case or a bad case. It is up to the researcher to decide and justify why or why not a case is kept.
Returns a matrix when scale.lens = NULL
and a
list with elements corresponding to the order of scales. In general,
the output contains potential bad cases that should be further
inspected by the researcher.
Alexander Christensen <[email protected]>
#Re-reverse responses rev.vec <- c(TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,FALSE, TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE) #Maximum value (5-point Likert scale) mv.vec <- 5 #Repeated responses check resp.rep(neoOpen, reverse = rev.vec, max.val = mv.vec) #Example with multiple scales #Facet scale lengths of NEO-PI-3 Openness to Experience s.len <- c(8, 8, 8, 8, 8, 8) #Maximum values mv.vec <- c(5, 5, 5, 5, 5, 5) #Re-reverse responses rev.vec <- c(TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,FALSE, TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE) #Repeated responses check resp.rep(neoOpen, scale.lens = s.len, max.val = mv.vec, reverse = rev.vec)
#Re-reverse responses rev.vec <- c(TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,FALSE, TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE) #Maximum value (5-point Likert scale) mv.vec <- 5 #Repeated responses check resp.rep(neoOpen, reverse = rev.vec, max.val = mv.vec) #Example with multiple scales #Facet scale lengths of NEO-PI-3 Openness to Experience s.len <- c(8, 8, 8, 8, 8, 8) #Maximum values mv.vec <- c(5, 5, 5, 5, 5, 5) #Re-reverse responses rev.vec <- c(TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,FALSE, TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE, FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE) #Repeated responses check resp.rep(neoOpen, scale.lens = s.len, max.val = mv.vec, reverse = rev.vec)
Computes the root mean square error (RMSE) of a sparse model to a full model
rmse(base, test)
rmse(base, test)
base |
Base (or full) model to be evaluated against |
test |
Reduced (or testing) model (e.g., a sparse correlation or covariance matrix) |
RMSE value (lower values suggest more similarity between the full and sparse model)
Alexander Christensen <[email protected]>
A1 <- solve(cov(neoOpen)) ## Not run: A2 <- LoGo(neoOpen) root <- rmse(A1, A2) ## End(Not run)
A1 <- solve(cov(neoOpen)) ## Not run: A2 <- LoGo(neoOpen) root <- rmse(A1, A2) ## End(Not run)
Computes betweenness centrality based on randomized shortest paths of each node in a network (Please see and cite Kivimaki et al., 2016)
rspbc(A, beta = 0.01, comm = NULL)
rspbc(A, beta = 0.01, comm = NULL)
A |
An adjacency matrix of network data |
beta |
Sets the beta parameter.
Defaults to |
comm |
Vector. Community vector containing a value for each node. Computes "bridge" RSPBC, where the number of times a node is used on a random path between to another community |
A vector of randomized shortest paths betweenness centrality values for each node in the network
Alexander Christensen <[email protected]>
Kivimaki, I., Lebichot, B., Saramaki, J., & Saerens, M. (2016). Two betweenness centrality measures based on Randomized Shortest Paths. Scientific Reports, 6, 19668.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A rspbc <- rspbc(A, beta=0.01)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A rspbc <- rspbc(A, beta=0.01)
Simulates a chordal network based on number of nodes. Data will also be simulated based on the true network structure
sim.chordal( nodes, inverse = c("cases", "matrix"), n = NULL, ordinal = FALSE, ordLevels = NULL, idio = NULL, eps = NULL )
sim.chordal( nodes, inverse = c("cases", "matrix"), n = NULL, ordinal = FALSE, ordLevels = NULL, idio = NULL, eps = NULL )
nodes |
Numeric. Number of nodes in the simulated network |
inverse |
Character. Method to produce inverse covariance matrix.
|
n |
Numeric. Number of cases in the simulated dataset |
ordinal |
Boolean.
Should simulated continuous data be converted to ordinal?
Defaults to |
ordLevels |
Numeric.
If |
idio |
Numeric.
DESCRIPTION.
Defaults to |
eps |
Numeric.
DESCRIPTION.
Defaults to |
Returns a list containing:
cliques |
The cliques in the network |
separators |
The separators in the network |
inverse |
Simulated inverse covariance matrix of the network |
data |
Simulated data from sim.correlation in the |
Guido Previde Massara <[email protected]>
Massara, G. P. & Aste, T. (2019). Learning clique forests. ArXiv.
#Continuous data sim.Norm <- sim.chordal(nodes = 20, inverse = "cases", n = 1000) #Ordinal data sim.Likert <- sim.chordal(nodes = 20, inverse = "cases", n = 1000, ordinal = TRUE) #Dichotomous data sim.Binary <- sim.chordal(nodes = 20, inverse = "cases", n = 1000, ordinal = TRUE, ordLevels = 5)
#Continuous data sim.Norm <- sim.chordal(nodes = 20, inverse = "cases", n = 1000) #Ordinal data sim.Likert <- sim.chordal(nodes = 20, inverse = "cases", n = 1000, ordinal = TRUE) #Dichotomous data sim.Binary <- sim.chordal(nodes = 20, inverse = "cases", n = 1000, ordinal = TRUE, ordLevels = 5)
Simulates a small-world network based on specified topological properties. Data will also be simulated based on the true network structure
sim.swn( nodes, n, pos = 0.8, ran = c(0.3, 0.7), nei = 1, p = 0.5, corr = FALSE, replace = NULL, ordinal = FALSE, ordLevels = NULL )
sim.swn( nodes, n, pos = 0.8, ran = c(0.3, 0.7), nei = 1, p = 0.5, corr = FALSE, replace = NULL, ordinal = FALSE, ordLevels = NULL )
nodes |
Number of nodes in the simulated network |
n |
Number of cases in the simulated dataset |
pos |
Proportion of positive correlations in the simulated network |
ran |
Range of correlations in the simulated network |
nei |
Adjusts the number of connections each node has to
neighboring nodes (see |
p |
Adjusts the rewiring probability (default is .5). p > .5 rewires the simulated network closer to a random network. p < .5 rewires the simulated network closer to a lattice network |
corr |
Should the simulated network be a correlation network? Defaults to FALSE. Set to TRUE for a simulated correlation network |
replace |
If noise > 0, then should participants be sampled with replacement? Defaults to TRUE. Set to FALSE to not allow the potential for participants to be consecutively entered into the simulated dataset. |
ordinal |
Should simulated continuous data be converted to ordinal? Defaults to FALSE. Set to TRUE for simulated ordinal data |
ordLevels |
If ordinal = TRUE, then how many levels should be used? Defaults to NULL. Set to desired number of intervals (defaults to 5) |
Returns a list containing:
simNetwork |
Adjacency matrix of the simulated network |
simData |
Simulated data from sim.correlation in the |
simRho |
Simulated correlation from sim.correlation in the |
Alexander Christensen <[email protected]>
Csardi, G., & Nepusz, T. (2006). The igraph software package for complex network research. InterJournal, Complex Systems, 1695, 1-9.
#Continuous data sim.Norm <- sim.swn(25, 500, nei = 3) #Ordinal data sim.Likert <- sim.swn(25, 500, nei = 3, replace = TRUE, ordinal = TRUE, ordLevels = 5) #Dichotomous data sim.Binary <- sim.swn(25, 500, nei = 3, replace = TRUE, ordinal = TRUE, ordLevels = 2)
#Continuous data sim.Norm <- sim.swn(25, 500, nei = 3) #Ordinal data sim.Likert <- sim.swn(25, 500, nei = 3, replace = TRUE, ordinal = TRUE, ordLevels = 5) #Dichotomous data sim.Binary <- sim.swn(25, 500, nei = 3, replace = TRUE, ordinal = TRUE, ordLevels = 2)
Computes the small-worldness measure of a network
smallworldness( A, iter = 100, progBar = FALSE, method = c("HG", "rand", "TJHBL") )
smallworldness( A, iter = 100, progBar = FALSE, method = c("HG", "rand", "TJHBL") )
A |
An adjacency matrix of network data |
iter |
Number of random (or lattice) networks to generate, which are used to calculate the mean random ASPL and CC (or lattice) |
progBar |
Defaults to |
method |
Defaults to |
For "rand"
, values > 1 indicate a small-world network.
For "HG"
, values > 3 indicate a small-world network.
For "TJHBL"
, values near 0 indicate a small-world network,
while < 0 indicates a more regular network and > 0 indicates a more random network
Returns a list containing:
swm |
Small-worldness value |
rASPL |
Global average shortest path length from random network |
lrCCt |
When |
Alexander Christensen <[email protected]>
Humphries, M. D., & Gurney, K. (2008). Network 'small-world-ness': A quantitative method for determining canonical network equivalence. PLoS one, 3, e0002051.
Telesford, Q. K., Joyce, K. E., Hayasaka, S., Burdette, J. H., & Laurienti, P. J. (2011). The ubiquity of small-world networks. Brain Connectivity, 1(5), 367-375.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A swmHG <- smallworldness(A, method="HG") swmRand <- smallworldness(A, method="rand") swmTJHBL <- smallworldness(A, method="TJHBL")
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A swmHG <- smallworldness(A, method="HG") swmRand <- smallworldness(A, method="rand") swmTJHBL <- smallworldness(A, method="TJHBL")
Computes the within-community centrality for each node in the network
stable( A, comm = c("walktrap", "louvain"), cent = c("betweenness", "rspbc", "closeness", "strength", "degree", "hybrid"), absolute = TRUE, diagonal = 0, ... )
stable( A, comm = c("walktrap", "louvain"), cent = c("betweenness", "rspbc", "closeness", "strength", "degree", "hybrid"), absolute = TRUE, diagonal = 0, ... )
A |
An adjacency matrix of network data |
comm |
Can be a vector of community assignments or community detection algorithms
( |
cent |
Centrality measure to be used.
Defaults to |
absolute |
Should network use absolute weights?
Defaults to |
diagonal |
Sets the diagonal values of the |
... |
Additional arguments for |
A matrix containing the within-community centrality value for each node
Alexander Christensen <[email protected]>
Blanken, T. F., Deserno, M. K., Dalege, J., Borsboom, D., Blanken, P., Kerkhof, G. A., & Cramer, A. O. (2018). The role of stabilizing and communicating symptoms given overlapping communities in psychopathology networks. Scientific Reports, 8, 5854.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A stabilizing <- stable(A, comm = "walktrap")
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A stabilizing <- stable(A, comm = "walktrap")
Computes strength of each node in a network
strength(A, absolute = TRUE)
strength(A, absolute = TRUE)
A |
An adjacency matrix of network data |
absolute |
Should network use absolute weights?
Defaults to |
A vector of strength values for each node in the network.
If directed network, returns a list containing:
inStrength |
Strength of incoming edges (pointing to the node) |
outStrength |
Strength of outgoing edges (pointing away from the node) |
relInf |
Relative degree of incoming and outgoing edges. Positive values indicate more outgoing strength relative to incoming strength. Negative values indicate more incoming strength relative to outgoing strength |
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A str <- strength(A) #Directed network ## Not run: dep <- depend(neoOpen) Adep <- TMFG(dep, depend = TRUE)$A str <- strength(Adep) ## End(Not run)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A str <- strength(A) #Directed network ## Not run: dep <- depend(neoOpen) Adep <- TMFG(dep, depend = TRUE)$A str <- strength(Adep) ## End(Not run)
Filters the network based on an r-value, alpha, adaptive alpha, bonferroni, false-discovery rate (FDR), or proportional density (fixed number of edges) value
threshold( data, a, thresh = c("alpha", "adaptive", "bonferroni", "FDR", "proportional"), normal = FALSE, na.data = c("pairwise", "listwise", "fiml", "none"), ... )
threshold( data, a, thresh = c("alpha", "adaptive", "bonferroni", "FDR", "proportional"), normal = FALSE, na.data = c("pairwise", "listwise", "fiml", "none"), ... )
data |
Can be a dataset or a correlation matrix |
a |
When |
thresh |
Sets threshold. Defaults to |
normal |
Should data be transformed to a normal distribution? Defaults to FALSE. Data is not transformed to be normal. Set to TRUE if data should be transformed to be normal (computes correlations using the cor_auto function) |
na.data |
How should missing data be handled?
For |
... |
Returns a list containing:
A |
The filtered adjacency matrix |
r.cv |
The critical correlation value used to filter the network |
Alexander Christensen <[email protected]>
Strimmer, K. (2008). fdrtool: A versatile R package for estimating local and tail area-based false discovery rates. Bioinformatics, 24, 1461-1462.
threshnet<-threshold(neoOpen) alphanet<-threshold(neoOpen, thresh = "alpha", a = .05) bonnet<-threshold(neoOpen, thresh = "bonferroni", a = .05) FDRnet<-threshold(neoOpen, thresh = "FDR", a = .10) propnet<-threshold(neoOpen, thresh = "proportional", a = .15)
threshnet<-threshold(neoOpen) alphanet<-threshold(neoOpen, thresh = "alpha", a = .05) bonnet<-threshold(neoOpen, thresh = "bonferroni", a = .05) FDRnet<-threshold(neoOpen, thresh = "FDR", a = .10) propnet<-threshold(neoOpen, thresh = "proportional", a = .15)
Applies the Triangulated Maximally Filtered Graph (TMFG) filtering method
(Please see and cite Massara et al., 2016). The TMFG method uses a structural
constraint that limits the number of zero-order correlations included in the network
(3n - 6; where n is the number of variables). The TMFG algorithm begins by
identifying four variables which have the largest sum of correlations to all other
variables. Then, it iteratively adds each variable with the largest sum of three
correlations to nodes already in the network until all variables have been added to
the network. This structure can be associated with the inverse correlation matrix
(i.e., precision matrix) to be turned into a GGM (i.e., partial correlation network)
by using LoGo
. See Details for more information on this
network estimation method.
TMFG( data, normal = TRUE, na.data = c("pairwise", "listwise", "fiml", "none"), depend = FALSE )
TMFG( data, normal = TRUE, na.data = c("pairwise", "listwise", "fiml", "none"), depend = FALSE )
data |
Can be a dataset or a correlation matrix |
normal |
Should data be transformed to a normal distribution?
Input must be a dataset.
Defaults to |
na.data |
How should missing data be handled?
For |
depend |
Is network a dependency (or directed) network?
Defaults to |
The TMFG method applies a structural constraint on the network, which restrains the network to retain a certain number of edges (3n-6, where n is the number of nodes; Massara et al., 2016). The network is also composed of 3- and 4-node cliques (i.e., sets of connected nodes; a triangle and tetrahedron, respectively). The TMFG method constructs a network using zero-order correlations and the resulting network can be associated with the inverse covariance matrix (yielding a GGM; Barfuss, Massara, Di Matteo, & Aste, 2016). Notably, the TMFG can use any association measure and thus does not assume the data is multivariate normal.
Construction begins by forming a tetrahedron of the four nodes that have the highest sum of correlations that are greater than the average correlation in the correlation matrix. Next, the algorithm iteratively identifies the node that maximizes its sum of correlations to a connected set of three nodes (triangles) already included in the network and then adds that node to the network. The process is completed once every node is connected in the network. In this process, the network automatically generates what’s called a planar network. A planar network is a network that could be drawn on a sphere with no edges crossing (often, however, the networks are depicted with edges crossing; Tumminello, Aste, Di Matteo, & Mantegna, 2005).
Returns a list containing:
A |
The filtered adjacency matrix |
separators |
The separators (3-cliques) in the network
(wrapper output for |
cliques |
The cliques (4-cliques) in the network
(wrapper output for |
Alexander Christensen <[email protected]>
Christensen, A. P., Kenett, Y. N., Aste, T., Silvia, P. J., & Kwapil, T. R. (2018). Network structure of the Wisconsin Schizotypy Scales-Short Forms: Examining psychometric network filtering approaches. Behavior Research Methods, 50, 2531-2550.
Massara, G. P., Di Matteo, T., & Aste, T. (2016). Network filtering for big data: Triangulated maximally filtered graph. Journal of Complex Networks, 5, 161-178.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A
Computes transitivity of a network
transitivity(A, weighted = FALSE)
transitivity(A, weighted = FALSE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
Returns a value of transitivity
Alexander Christensen <[email protected]>
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A trans <- transitivity(A, weighted=TRUE)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A trans <- transitivity(A, weighted=TRUE)
Converts a directed network to an undirected network
un.direct(A, diagonal = 0)
un.direct(A, diagonal = 0)
A |
Matrix or data frame. Adjacency matrix (network matrix) |
diagonal |
Numeric.
Number to be placed on the diagonal.
Defaults to |
Returns a symmetric adjacency matrix
Alexander Christensen <[email protected]>
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A # create a directed network dir <- A * sample(c(0,1), size = length(A), replace = TRUE) # undirect the directed network undir <- un.direct(dir)
# Pearson's correlation only for CRAN checks A <- TMFG(neoOpen, normal = FALSE)$A # create a directed network dir <- A * sample(c(0,1), size = length(A), replace = TRUE) # undirect the directed network undir <- un.direct(dir)