Title: | Methods and Measures for Semantic Network Analysis |
---|---|
Description: | Implements several functions for the analysis of semantic networks including different network estimation algorithms, partial node bootstrapping (Kenett, Anaki, & Faust, 2014 <doi:10.3389/fnhum.2014.00407>), random walk simulation (Kenett & Austerweil, 2016 <http://alab.psych.wisc.edu/papers/files/Kenett16CreativityRW.pdf>), and a function to compute global network measures. Significance tests and plotting features are also implemented. |
Authors: | Alexander P. Christensen [aut, cre] , Yoed N. Kenett [aut, ctb] |
Maintainer: | Alexander P. Christensen <[email protected]> |
License: | GPL (>= 3.0) |
Version: | 1.4.4 |
Built: | 2024-11-05 03:27:23 UTC |
Source: | https://github.com/alexchristensen/semnet |
Implements several functions for the analysis of semantic networks including partial node bootstraping (Kenett, Anaki, & Faust, 2014), random walk simulation (Kenett & Austerweil, 2016), and a function to compute global network measures. Significance tests and plotting features are also implemented.
Alexander P. Christensen <[email protected]> & Yoed N. Kenett <[email protected]>
Christensen, A. P., Kenett, Y. N., Cotter, K. N., Beaty, R. E., & Silvia, P. J. (2018). Remotely close associations: Openness to experience and semantic memory structure. European Journal of Personality, 32, 480-492.
Kenett, Y. N., Anaki, D., & Faust, M. (2014). Investigating the structure of semantic networks in low and high creative persons. Frontiers in Human Neuroscience, 8, 407.
Kenett, Y. N., & Austerweil, J. L. (2016). Examining search processes in low and high creative individuals with random walks. In Paper presented at the proceedings of the 38th annual meeting of the cognitive science society. Austin, TX.
Useful links:
Report bugs at https://github.com/AlexChristensen/SemNeT/issues
Frequency of animal responses from Christensen & Kenett (2019). These frequencies
are used to generate data in the sim.fluency
function.
data(animals.freq)
data(animals.freq)
animals.freq (vector, length = 367)
data("animals.freq")
data("animals.freq")
Computes the global average shortest path length of the network
ASPL(A, weighted = FALSE)
ASPL(A, weighted = FALSE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
Returns the ASPL 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(similarity(sim.fluency(100), method = "cor")) # Unweighted aspl <- ASPL(A)
# Pearson's correlation only for CRAN checks A <- TMFG(similarity(sim.fluency(100), method = "cor")) # Unweighted aspl <- ASPL(A)
Bootstrap techniques to generate semantic networks and compute global network characteristics
bootSemNeT( ..., method = c("CN", "NRW", "PF", "TMFG"), methodArgs = list(), type = c("case", "node"), prop = 0.5, sim, weighted = FALSE, iter = 1000, cores )
bootSemNeT( ..., method = c("CN", "NRW", "PF", "TMFG"), methodArgs = list(), type = c("case", "node"), prop = 0.5, sim, weighted = FALSE, iter = 1000, cores )
... |
Matrices or data frames.
Cleaned response matrices (e.g., |
method |
Character. Network estimation method to use. Current options include: |
methodArgs |
List.
A list of additional arguments for the network estimation function.
See links in argument |
type |
Character. Type of bootstrap to perform
|
prop |
Numeric.
Only for |
sim |
Character.
Similarity measure to use.
Defaults to |
weighted |
Boolean.
Should weighted ASPL and CC be used?
Defaults to |
iter |
Numeric.
Number of iterations in bootstrap.
Defaults to |
cores |
Numeric.
Number of computer processing cores to use for bootstrapping samples.
Defaults to n / 2 total number of cores.
Set to any number between 1 and maximum amount of cores on your computer
(see |
Returns a list containing:
dataMeas |
A matrix for the network input in the |
dataSumm |
Summary statistics across the bootrapped samples for the
network input in the |
prop |
Outputs the proportion used from the |
iter |
Outputs the number of bootstrapped samples
used from the |
If a paired
network is input, then also returns:
pairedMeas |
A matrix for the network input in the |
pairedSumm |
Summary statistics across the bootrapped samples for the
network input in the |
Alexander Christensen <[email protected]>
# Simulate Dataset one <- sim.fluency(20) # Run bootstrap node-drop (partial) networks one.result <- bootSemNeT(one, prop = .50, iter = 100, sim = "cosine", cores = 2, method = "TMFG", type = "node") # Run bootstrap case-drop networks ## Includes additional equating argument: minCase one.result <- bootSemNeT(one, iter = 100, sim = "cosine", cores = 2, method = "TMFG", type = "case", methodArgs = list(minCase = 2)) # Bootstrap case-wise networks ## Get openness data low <- open.clean[which(open.group == "Low"),] high <- open.clean[which(open.group == "High"),] ## Run ### Inlcudes additional NRW argument: threshold open <- bootSemNeT(low, high, iter = 100, cores = 2, method = "NRW", type = "case", methodArgs = list(type = "num", threshold = 3))
# Simulate Dataset one <- sim.fluency(20) # Run bootstrap node-drop (partial) networks one.result <- bootSemNeT(one, prop = .50, iter = 100, sim = "cosine", cores = 2, method = "TMFG", type = "node") # Run bootstrap case-drop networks ## Includes additional equating argument: minCase one.result <- bootSemNeT(one, iter = 100, sim = "cosine", cores = 2, method = "TMFG", type = "case", methodArgs = list(minCase = 2)) # Bootstrap case-wise networks ## Get openness data low <- open.clean[which(open.group == "Low"),] high <- open.clean[which(open.group == "High"),] ## Run ### Inlcudes additional NRW argument: threshold open <- bootSemNeT(low, high, iter = 100, cores = 2, method = "NRW", type = "case", methodArgs = list(type = "num", threshold = 3))
Computes global clustering coefficient CC
CC(A, weighted = FALSE)
CC(A, weighted = FALSE)
A |
An adjacency matrix of network data |
weighted |
Is the network weighted?
Defaults to |
Returns the network's CC
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(similarity(sim.fluency(100), method = "cor")) # Unweighted cc <- CC(A)
# Pearson's correlation only for CRAN checks A <- TMFG(similarity(sim.fluency(100), method = "cor")) # Unweighted cc <- CC(A)
Estimates a semantic network using the Community Network method described in Goni et al. (2011)
CN(data, window = 2, alpha = 0.05, enrich = FALSE)
CN(data, window = 2, alpha = 0.05, enrich = FALSE)
data |
Matrix or data frame. A preprocessed verbal fluency matrix where rows are participants and columns are verbal fluency responses |
window |
Numeric.
Size of window to look for co-occurences in.
Defaults to |
alpha |
Numeric.
Significance value.
Defaults to |
enrich |
Boolean.
Should the network be enriched by connecting
all nodes in their respective modules?
Defaults to |
Returns a undirected semantic network
Alexander Christensen <[email protected]>
Goni, J., Arrondo, G., Sepulcre, J., Martincorena, I., de Mendizabal, N. V., Corominas-Murtra, B., ... & Villoslada, P. (2011). The semantic organization of the animal category: Evidence from semantic verbal fluency and network theory. Cognitive Processing, 12, 183-196.
# Get data data <- open.clean # Organize group data ## Get group data group <- open.group ## Low and high openness to experience groups low <- data[which(group == "Low"),] high <- data[which(group == "High"),] ## Not run: # Compute networks low.net <- CN(low) high.net <- CN(high) ## End(Not run)
# Get data data <- open.clean # Organize group data ## Get group data group <- open.group ## Low and high openness to experience groups low <- data[which(group == "Low"),] high <- data[which(group == "High"),] ## Not run: # Compute networks low.net <- CN(low) high.net <- CN(high) ## End(Not run)
Uses qgraph
to plot networks.
Accepts any number of networks and will organize the plots
in the number of side-by-side columns using the heuristic of taking the square root of the number of
input and rounding down to the nearest integer (i.e., floor(sqrt(length(input)))
).
Examples
3 networks: 1 x 3
6 networks: 2 x 3
9 networks: 3 x 3
compare_nets( ..., title, config, placement = c("match", "default"), weighted = FALSE, qgraph.args = list() )
compare_nets( ..., title, config, placement = c("match", "default"), weighted = FALSE, qgraph.args = list() )
... |
Matrices or data frames of network adjacency matrices |
title |
List. Characters denoting titles of plots |
config |
Character.
Defaults to |
placement |
Character.
How should nodes be placed when comparing groups?
Defaults to
|
weighted |
Boolean.
Should networks be plotted with weights?
Defaults to |
qgraph.args |
List.
An argument list to be passed onto |
Plots networks using qgraph
Alexander Christensen <[email protected]>
Epskamp, S., Cramer, A. O. J., Waldorp, L. J., Schmittmann, V. D., & Borsboom, D. (2012). qgraph: Network visualizations of relationships in psychometric data. Journal of Statistical Software, 48, 1-18.
Jones, P. J. (2019). networktools: Tools for Identifying Important Nodes in Networks. R package version 1.2.1.
Jones, P. J., Mair, P., & McNally, R. (2018). Visualizing psychological networks: A tutorial in R. Frontiers in Psychology, 9, 1742.
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Compare networks compare_nets(net1, net2, title = list("One", "Two"), config = "spring") # Change edge colors compare_nets(net1, net2, title = list("One", "Two"), config = "spring", qgraph.args = list(edge.color = "blue"))
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Compare networks compare_nets(net1, net2, title = list("One", "Two"), config = "spring") # Change edge colors compare_nets(net1, net2, title = list("One", "Two"), config = "spring", qgraph.args = list(edge.color = "blue"))
Converts an adjacency matrix to Cytoscape's sparse matrix format
convert2cytoscape(A)
convert2cytoscape(A)
A |
Matrix or data frame. A cleaned, finalized response matrix ready to be visualized |
A sparse matrix formatted for Cytoscape
Alexander Christensen <[email protected]>
Shannon, P., Markiel, A., Ozier, O., Baliga, N. S., Wang, J. T., Ramage, D., ... & Ideker, T. (2003). Cytoscape: A software environment for integrated models of biomolecular interaction networks. Genome Research, 13, 2498-2504.
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Convert to Cytoscape format cyto1 <- convert2cytoscape(net1) cyto2 <- convert2cytoscape(net2) # Write to .csv write.csv(cyto1, file.path(tempdir(), "cyto1.csv"), row.names = FALSE) write.csv(cyto2, file.path(tempdir(), "cyto2.csv"), row.names = FALSE)
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Convert to Cytoscape format cyto1 <- convert2cytoscape(net1) cyto2 <- convert2cytoscape(net2) # Write to .csv write.csv(cyto1, file.path(tempdir(), "cyto1.csv"), row.names = FALSE) write.csv(cyto2, file.path(tempdir(), "cyto2.csv"), row.names = FALSE)
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 |
Defunct. |
Returns a network matrix in igraph
's format
Alexander Christensen <[email protected]>
# Pearson's correlation only for CRAN checks A <- TMFG(similarity(sim.fluency(50), method = "cor")) igraphNetwork <- convert2igraph(A)
# Pearson's correlation only for CRAN checks A <- TMFG(similarity(sim.fluency(50), method = "cor")) igraphNetwork <- convert2igraph(A)
A function to "equate" multiple response matrices to one another. N number of groups are matched based on their responses so that every group has the same responses in their data
equate(...)
equate(...)
... |
Matrices, data frames or a list of matrices and data frames. Binary response matrices to be equated |
This function returns a list containing the equated binary response matrices in the order they were input. The response matrices are labeled as the object name they were entered with
Alexander Christensen <[email protected]>
# Obtain binary data bin <- open.binary # Finalize mat1 mat1 <- finalize(bin[c(1:5),]) # Finalize mat2 mat2 <- finalize(bin[c(6:10),]) # Equate mat1 and mat1 eq <- equate(mat1, mat2) # Obtain respective equated response matrices eq.mat1 <- eq$mat1 # list objects are named with the names eq.mat2 <- eq$mat2 # they were entered with
# Obtain binary data bin <- open.binary # Finalize mat1 mat1 <- finalize(bin[c(1:5),]) # Finalize mat2 mat2 <- finalize(bin[c(6:10),]) # Equate mat1 and mat1 eq <- equate(mat1, mat2) # Obtain respective equated response matrices eq.mat1 <- eq$mat1 # list objects are named with the names eq.mat2 <- eq$mat2 # they were entered with
Finalizes the response matrix by keeping responses that are given by a certain number of people
finalize(rmat, minCase = 2)
finalize(rmat, minCase = 2)
rmat |
Binary matrix. A textcleaner filtered response matrix |
minCase |
Numeric. Minimum number of cases to produce a response |
A binary response matrix with responses
given by at least minCase
people
Alexander Christensen <[email protected]>
# Obtain binary data bin <- open.binary # Finalize mat1 mat1 <- finalize(bin)
# Obtain binary data bin <- open.binary # Finalize mat1 mat1 <- finalize(bin)
High openness to experience network from Christensen & Kenett (2019)
data(net.high)
data(net.high)
net.high (matrix, 160 x 160)
Christensen, A. P., & Kenett, Y. N. (2019) Semantic network analysis (SemNA): A tutorial on preprocessing, estimating, and analyzing semantic networks. PsyArXiv.
data("net.high")
data("net.high")
Low openness to experience network from Christensen & Kenett (2019)
data(net.low)
data(net.low)
net.low (matrix, 160 x 160)
Christensen, A. P., & Kenett, Y. N. (2019) Semantic network analysis (SemNA): A tutorial on preprocessing, estimating, and analyzing semantic networks. PsyArXiv.
data("net.low")
data("net.low")
Estimates a semantic network using the Naive Random Walk method described in Lerner, Ogrocki, and Thomas (2009)
NRW(data, type = c("num", "prop"), threshold = 0)
NRW(data, type = c("num", "prop"), threshold = 0)
data |
Matrix or data frame. A preprocessed verbal fluency matrix where rows are participants and columns are verbal fluency responses |
type |
Character.
Type of
Defaults to |
threshold |
Numeric.
Value of the minimum number or proportion of co-occurrences.
Defaults to |
Returns a undirected semantic network
Alexander Christensen <[email protected]>
Lerner, A. J., Ogrocki, P. K., & Thomas, P. J. (2009). Network graph analysis of category fluency testing. Cognitive and Behavioral Neurology, 22, 45-52.
# Get data data <- open.clean # Organize group data ## Get group data group <- open.group ## Low and high openness to experience groups low <- data[which(group == "Low"),] high <- data[which(group == "High"),] # Compute networks low.net <- NRW(low) high.net <- NRW(high)
# Get data data <- open.clean # Organize group data ## Get group data group <- open.group ## Low and high openness to experience groups low <- data[which(group == "Low"),] high <- data[which(group == "High"),] # Compute networks low.net <- NRW(low) high.net <- NRW(high)
A result of bootSemNeT
from a simulated dataset
data(one.result)
data(one.result)
one.result (list, length = 4)
data("one.result")
data("one.result")
Binary response matrices for the Animals verbal fluency data (n = 516) from Christensen et al. (2018).
data(open.binary)
data(open.binary)
open.binary (matrix, 516 x 367)
Christensen, A. P., Kenett, Y. N., Cotter, K. N., Beaty, R. E., & Silvia, P. J. (2018). Remotely close associations: Openness to experience and semantic memory structure. European Journal of Personality, 32, 480-492.
data("open.binary")
data("open.binary")
Cleaned response matrices for the Animals verbal fluency data (n = 516) from Christensen et al. (2018).
data(open.clean)
data(open.clean)
open.clean (matrix, 516 x 35)
Christensen, A. P., Kenett, Y. N., Cotter, K. N., Beaty, R. E., & Silvia, P. J. (2018). Remotely close associations: Openness to experience and semantic memory structure. European Journal of Personality, 32, 480-492.
data("open.clean")
data("open.clean")
Groups for the Animals verbal fluency data (n = 516)
from Christensen et al. (2018; see also open.clean
).
data(open.group)
data(open.group)
open.group (vector, length = 516)
Christensen, A. P., Kenett, Y. N., Cotter, K. N., Beaty, R. E., & Silvia, P. J. (2018). Remotely close associations: Openness to experience and semantic memory structure. European Journal of Personality, 32, 480-492.
data("open.group")
data("open.group")
Estimates a pathfinder network using the MST-Pathfinder Network method from Quirin et al. (2008; see also Schvaneveldt, 1990)
PF(data)
PF(data)
data |
Matrix or data frame. A binary response matrix |
An adjacency matrix
Alexander Christensen <[email protected]>
Quirin, A., Cordon, O., Guerrero-Bote, V. P., Vargas-Quesada, B., & Moya-Aneon, F. (2008) A quick MST-based algorithm to obtain Pathfinder networks (Inf, n-1). Journal of the American Society for Information Science and Technology, 59, 1912-1924.
Schvaneveldt, R. W. (1990). Pathfinder associative networks: Studies in knowledge organization. Norwood, NJ: Ablex Publishing.
# Obtain data data <- open.binary # Estimate network pf.net <- PF(data)
# Obtain data data <- open.binary # Estimate network pf.net <- PF(data)
Uses qgraph
and ani.record
to animate networks. Accepts only one network animation at a time
## S3 method for class 'animateShiny' plot(x, ...)
## S3 method for class 'animateShiny' plot(x, ...)
x |
Shiny result |
... |
Additional arguments for |
Plots animated networks using qgraph
and ani.record
Alexander Christensen <[email protected]>
Epskamp, S., Cramer, A. O. J., Waldorp, L. J., Schmittmann, V. D., & Borsboom, D. (2012). qgraph: Network visualizations of relationships in psychometric data. Journal of Statistical Software, 48, 1-18. Retrieved from: http://www.jstatsoft.org/v48/i04/
Siew, C. S. Q. (2019). spreadr: An R package to simulate spreading activation in a network. Behavior Research Methods, 51, 910-929. https://doi.org/10.3758/s13428-018-1186-5
if(interactive()) {SemNeTShiny()} ## Not run: plot(resultShiny$spreadingActivationPlot[[1]]) ## End(Not run)
if(interactive()) {SemNeTShiny()} ## Not run: plot(resultShiny$spreadingActivationPlot[[1]]) ## End(Not run)
Plots output from bootSemNeT
## S3 method for class 'bootSemNeT' plot(..., groups = NULL, measures = c("ASPL", "CC", "Q"))
## S3 method for class 'bootSemNeT' plot(..., groups = NULL, measures = c("ASPL", "CC", "Q"))
... |
Object(s) from |
groups |
Character.
Labels for groups in the order they were entered
in |
measures |
Character. Measures to be plotted |
Returns plots for the specified measures
Alexander Christensen <[email protected]>
# Simulate Dataset one <- sim.fluency(20) # Run partial bootstrap networks one.result <- bootSemNeT(one, prop = .50, iter = 1000, sim = "cosine", cores = 2, type = "node", method = "TMFG") # Plot plot(one.result, groups = c("One"))
# Simulate Dataset one <- sim.fluency(20) # Run partial bootstrap networks one.result <- bootSemNeT(one, prop = .50, iter = 1000, sim = "cosine", cores = 2, type = "node", method = "TMFG") # Plot plot(one.result, groups = c("One"))
Uses qgraph
to plot networks. Accepts any number of networks and will organize the plots
in the number of side-by-side columns using the heuristic of taking the square root of the number of
input and rounding down to the nearest integer (i.e., floor(sqrt(length(input)))
).
Performs the same operations as compare_nets
Examples
3 networks: 1 x 3
6 networks: 2 x 3
9 networks: 3 x 3
## S3 method for class 'compareShiny' plot(x, ...)
## S3 method for class 'compareShiny' plot(x, ...)
x |
Shiny result |
... |
Additional arguments |
Plots networks using qgraph
Alexander Christensen <[email protected]>
Epskamp, S., Cramer, A. O. J., Waldorp, L. J., Schmittmann, V. D., & Borsboom, D. (2012). qgraph: Network visualizations of relationships in psychometric data. Journal of Statistical Software, 48, 1-18.
Jones, P. J. (2019). networktools: Tools for Identifying Important Nodes in Networks. R package version 1.2.1.
Jones, P. J., Mair, P., & McNally, R. (2018). Visualizing psychological networks: A tutorial in R. Frontiers in Psychology, 9, 1742.
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Compare networks compare_nets(net1, net2, title = list("One", "Two"), config = "spring") # Change edge colors compare_nets(net1, net2, title = list("One", "Two"), config = "spring", qgraph.args = list(edge.color = "blue"))
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Compare networks compare_nets(net1, net2, title = list("One", "Two"), config = "spring") # Change edge colors compare_nets(net1, net2, title = list("One", "Two"), config = "spring", qgraph.args = list(edge.color = "blue"))
Computes a global modularity measure (Q) using the Louvain community detection algorithm
Q(A)
Q(A)
A |
An adjacency matrix of network data |
Returns Q or a measure of how well the communities in the network 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(similarity(sim.fluency(100), method = "cor")) modularity <- Q(A)
# Pearson's correlation only for CRAN checks A <- TMFG(similarity(sim.fluency(100), method = "cor")) modularity <- Q(A)
Performs significance tests for global measures of semantic networks against the global measures of equivalent size (and density) random networks
randnet.test(..., iter, cores)
randnet.test(..., iter, cores)
... |
Matrices or data frames. Semantic networks to be compared against random networks |
iter |
Numeric.
Number of iterations in bootstrap.
Defaults to |
cores |
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 |
Returns a matrix containing p-values
for the network measures of the input networks against
the distribution of equivalent random networks. The last
two columns contain the mean ("M.rand"
) and
standard deviation ("SD.rand"
) of the network measures
for the random network distribution
Alexander Christensen <[email protected]>
Viger, F., & Latapy, M. (2016). Efficient and simple generation of random simple connected graphs with prescribed degree sequence. Journal of Complex Networks, 4, 15-37.
# Get openness data one <- open.clean[which(open.group == "Low"),] two <- open.clean[which(open.group == "High"),] # Compute networks net.one <- CN(one) net.two <- CN(two) # Perform random networks test randnet.test(net.one, net.two, iter = 100, cores = 2)
# Get openness data one <- open.clean[which(open.group == "Low"),] two <- open.clean[which(open.group == "High"),] # Compute networks net.one <- CN(one) net.two <- CN(two) # Perform random networks test randnet.test(net.one, net.two, iter = 100, cores = 2)
Simulates random walks over two networks to examine the characteristics of spontaneous spreading activation (see Kenett & Austerweil, 2016)
randwalk(A, B, reps = 20, steps = 10, iter = 10000, cores)
randwalk(A, B, reps = 20, steps = 10, iter = 10000, cores)
A |
Matrix or data frame. Adjacency matrix of a semantic network |
B |
Matrix or data frame. A comparison adjacency matrix of a semantic network |
reps |
Numeric.
Number of repetitions of increments in 10 steps.
Defaults to |
steps |
Numeric.
Number of random steps to begin with.
Defaults to |
iter |
Numeric.
Number of iterations for each random walk.
Defaults to |
cores |
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 |
A result matrix containing the means and standard deviations for several measures as well as p-values for a Mann-Whitney U test
Alexander Christensen <[email protected]> and Yoed Kenett <[email protected]>
Kenett, Y. N., & Austerweil, J. L. (2016). Examining search processes in low and high creative individuals with random walks. In Paper presented at the proceedings of the 38th annual meeting of the cognitive science society. Austin, TX.
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Run random walk analysis rw.results <- randwalk(net1, net2, iter = 100, cores = 2)
# Simulate Datasets one <- sim.fluency(10) two <- sim.fluency(10) # Compute similarity matrix cos1 <- similarity(one, method = "cosine") cos2 <- similarity(two, method = "cosine") # Compute networks net1 <- TMFG(cos1) net2 <- TMFG(cos2) # Run random walk analysis rw.results <- randwalk(net1, net2, iter = 100, cores = 2)
Computes the difference in the total and unique number of responses between two groups (follows Christensen et al., 2018)
response.analysis(...)
response.analysis(...)
... |
Matrix or data frame. Responses matrices for two different groups |
A list containing objects:
total |
A vector with the total responses given by each participant. A t-test is used to compare, on average, whether one group provides more response than the other |
unique |
A vector with the number of unique responses provided by both groups
( |
Alexander Christensen <[email protected]>
Christensen, A. P., Kenett, Y. N., Cotter, K. N., Beaty, R. E., & Silvia, P. J. (2018). Remotely close associations: Openness to experience and semantic memory structure. European Journal of Personality, 32, 480-492.
# Obtain data low <- open.clean[which(open.group == "Low"),] high <- open.clean[which(open.group == "High"),] # Perform analysis response.analysis(low, high)
# Obtain data low <- open.clean[which(open.group == "Low"),] high <- open.clean[which(open.group == "High"),] # Perform analysis response.analysis(low, high)
Computes the average shortest path length (ASPL), clustering coefficient(CC), and modularity (Q) of the network
semnetmeas(A, meas = c("ASPL", "CC", "Q"), weighted = FALSE)
semnetmeas(A, meas = c("ASPL", "CC", "Q"), weighted = FALSE)
A |
Matrix or data frame. An adjacency matrix of a network |
meas |
Character. Global network measures to compute. By default, computes ASPL, CC, and Q. Individual measures can be selected |
weighted |
Boolean.
Should weighted measures be computed?
Defaults to |
Returns a values for ASPL, CC, and Q
Alexander Christensen <[email protected]>
# Simulate Datasets one <- sim.fluency(10) # Compute similarity matrix cos <- similarity(one, method = "cosine") # Compute networks net <- TMFG(cos) # Compute global network measures globmeas <- semnetmeas(net)
# Simulate Datasets one <- sim.fluency(10) # Compute similarity matrix cos <- similarity(one, method = "cosine") # Compute networks net <- TMFG(cos) # Compute global network measures globmeas <- semnetmeas(net)
SemNeT
An interactive Shiny application for running SemNeT
analysis.
SemNeTShiny()
SemNeTShiny()
A list called resultShiny
containing:
data |
The data imported into |
group |
The grouping variable imported into |
network |
The networks generated during |
measures |
Network measures ASPL (Average Shortest Path Lengths),
CC (Clustering Coefficient), and Q (Modularity) for the networks generated
during |
(see semnetmeas
)
comparePlot |
A visualization of the networks generated during |
(see compare_nets
)
randomTest |
Statistical results from the Random Network Test in |
bootstrap |
Results from the Bootstrap Network Analysis in |
bootstrapTest |
Statistical results from the Bootstrap Network Analysis
(see |
bootstrapPlot |
Plots of the statistical results from the Bootstrap Network Analysis
(see |
randomWalk |
Results from the Random Walk Analysis
(see |
bootstrapPlot |
Results from the Spreading Activation Analysis
(see |
if(interactive()) {SemNeTShiny()}
if(interactive()) {SemNeTShiny()}
Simulates verbal fluency data based on the number of
nodes in the desired network. The summed total of
each response is simulated from a poisson distribution
(see rpois
), using frequencies from the
animals.freq
data. Using these
sums, participants responses are simulated with a probability of giving
a response as the total of the summed response over the number of participants.
sim.fluency(nodes, cases, random = FALSE)
sim.fluency(nodes, cases, random = FALSE)
nodes |
Numeric.
Number of nodes to simulate in data.
Defaults to |
cases |
Numeric.
Number of participants to simulate in data.
Defaults to |
random |
Boolean.
Should the frequencies be randomly sampled from?
Defaults to |
A binary matrix with p
(participants) by n
(nodes)
Alexander Christensen <[email protected]>
# Simulate data for 50 nodes and 200 participants sim.fluency(nodes = 50, cases = 200)
# Simulate data for 50 nodes and 200 participants sim.fluency(nodes = 50, cases = 200)
Computes several measures of similarity (see Choi, Cha, & Tappert, 2010 for additional measures)
similarity( data, method = c("angular", "cor", "cosine", "euclid", "faith", "jaccard", "phi", "rr") )
similarity( data, method = c("angular", "cor", "cosine", "euclid", "faith", "jaccard", "phi", "rr") )
data |
Matrix or data frame. A binarized dataset of verbal fluency or linguistic data |
||||||||||||||||||||||||||
method |
Character. Type of similarity measure to compute. Below are the definitions for each bin:
Options include:
|
A symmetric similarity matrix
Alexander Christensen <[email protected]>
Choi, S. S., Cha, S. H., & Tappert, C. C. (2010). A survey of binary similarity and distance measures. Journal of Systemics, Cybernetics and Informatics, 8, 43-48.
# Simulate Datasets one <- sim.fluency(10) # Compute similarity matrix cos <- similarity(one, method = "cosine")
# Simulate Datasets one <- sim.fluency(10) # Compute similarity matrix cos <- similarity(one, method = "cosine")
bootSemNeT
Computes statistical tests for bootstrapped
networks from bootSemNeT
test.bootSemNeT( ..., test = c("ANCOVA", "ANOVA", "t-test"), measures = c("ASPL", "CC", "Q"), formula = NULL, groups = NULL )
test.bootSemNeT( ..., test = c("ANCOVA", "ANOVA", "t-test"), measures = c("ASPL", "CC", "Q"), formula = NULL, groups = NULL )
... |
Object(s) from |
test |
Character. Type of statistical test to be used. |
measures |
Character. Network measures to be tested. |
formula |
Character.
A formula for specifying an ANOVA structure. The formula should
have the predictor variable as "y" and include the names the variables
are grouped by (e.g., |
groups |
Data frame.
A data frame specifying the groups to be input into the formula.
The column names should be the variable names of interest. The
groups should be in the same order as the groups input into
|
Returns a list containing the objects:
ASPL |
Test statistics for each proportion of nodes remaining for ASPL |
CC |
Test statistics for each proportion of nodes remaining for CC |
Q |
Test statistics for each proportion of nodes remaining for Q |
If two groups:
A matrix in each object has the following columns:
t-statistic |
Statistic from the |
df |
Degrees of freedom |
p-value |
p-value with values equal to |
d |
Cohen's d |
CI95.lower |
Lower bound of the 95 percent confidence interval |
CI95.upper |
Upper bound of the 95 percent confidence interval |
Direction |
Direction of the effect. The argument |
Row names refer to the proportion of nodes remaining in bootstrapped networks
If three or more groups:
A list containing two objects:
ANOVA |
A matrix containing the F-statistic, group degrees of freedom,
residual degrees of freedom, p-value, and partial eta squared |
HSD |
A matrix containing the differences between each group ( |
Alexander Christensen <[email protected]>
# Simulate Dataset one <- sim.fluency(20) two <- sim.fluency(20) # Run partial bootstrap networks two.result <- bootSemNeT(one, two, prop = .50, iter = 100, sim = "cosine", cores = 2, type = "node", method = "TMFG") # Compute tests test.bootSemNeT(two.result) # Two-way ANOVA example ## Simulated data hihi <- sim.fluency(50, 500) hilo <- sim.fluency(50, 500) lohi <- sim.fluency(50, 500) lolo <- sim.fluency(50, 500) ## Create groups groups <- matrix( c("high", "high", "high", "low", "low", "high", "low", "low" ), ncol = 2, byrow = TRUE) ## Change column names (variable names) colnames(groups) <- c("gf","caq") ## Run partial bootstrap networks boot.fifty <- bootSemNeT(hihi, hilo, lohi, lolo, prop = .50, type = "node", method = "TMFG", cores = 2, iter = 100) boot.sixty <- bootSemNeT(hihi, hilo, lohi, lolo, prop = .60, type = "node", method = "TMFG", cores = 2, iter = 100) ## Compute tests test.bootSemNeT(boot.fifty, boot.sixty, test = "ANOVA", formula = "y ~ gf*caq", groups = groups)
# Simulate Dataset one <- sim.fluency(20) two <- sim.fluency(20) # Run partial bootstrap networks two.result <- bootSemNeT(one, two, prop = .50, iter = 100, sim = "cosine", cores = 2, type = "node", method = "TMFG") # Compute tests test.bootSemNeT(two.result) # Two-way ANOVA example ## Simulated data hihi <- sim.fluency(50, 500) hilo <- sim.fluency(50, 500) lohi <- sim.fluency(50, 500) lolo <- sim.fluency(50, 500) ## Create groups groups <- matrix( c("high", "high", "high", "low", "low", "high", "low", "low" ), ncol = 2, byrow = TRUE) ## Change column names (variable names) colnames(groups) <- c("gf","caq") ## Run partial bootstrap networks boot.fifty <- bootSemNeT(hihi, hilo, lohi, lolo, prop = .50, type = "node", method = "TMFG", cores = 2, iter = 100) boot.sixty <- bootSemNeT(hihi, hilo, lohi, lolo, prop = .60, type = "node", method = "TMFG", cores = 2, iter = 100) ## Compute tests test.bootSemNeT(boot.fifty, boot.sixty, test = "ANOVA", formula = "y ~ gf*caq", groups = groups)
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, depend = FALSE)
TMFG(data, depend = FALSE)
data |
Matrix or data frame. Must be a square matrix |
depend |
Boolean.
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 an TMFG filtered adjacency matrix
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(similarity(sim.fluency(100), method = "cor"))
# Pearson's correlation only for CRAN checks A <- TMFG(similarity(sim.fluency(100), method = "cor"))
A result of bootSemNeT
from two simulated datasets
data(two.result)
data(two.result)
two.result (list, length = 6)
data("two.result")
data("two.result")
Plots for vignette taken from Christensen & Kenett (2019)
data(vignette.plots)
data(vignette.plots)
vignette.plots (list, length = 3)
Christensen, A. P., & Kenett, Y. N. (2019) Semantic network analysis (SemNA): A tutorial on preprocessing, estimating, and analyzing semantic networks. PsyArXiv.
data("vignette.plots")
data("vignette.plots")