| Title: | Methods and Measures for Semantic Network Analysis |
| Version: | 2.0.0 |
| Date: | 2026-09-12 |
| Maintainer: | Alexander P. Christensen <alexpaulchristensen@gmail.com> |
| 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), and a function to compute global network measures. Significance tests and plotting features are also implemented. |
| Depends: | R (≥ 3.6.0) |
| License: | GPL (≥ 3.0) |
| Encoding: | UTF-8 |
| LazyData: | true |
| Imports: | methods, utils, stats, graphics, future, future.apply, progressr, igraph, qgraph, car, broom, effects |
| Suggests: | testthat (≥ 3.0.0), shiny (≥ 1.8.0), shinyjs, shinyalert, DT, promises, spreadr, shinyMatrix, shinyBS, readxl, foreign, R.matlab, tools, ggplot2 |
| URL: | https://github.com/AlexChristensen/SemNeT |
| BugReports: | https://github.com/AlexChristensen/SemNeT/issues |
| NeedsCompilation: | yes |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| Packaged: | 2026-09-12 14:53:09 UTC; alextops |
| Author: | Alexander P. Christensen
|
| Repository: | CRAN |
| Date/Publication: | 2026-09-12 15:10:08 UTC |
SemNeT–package
Description
Implements several functions for the analysis of semantic networks including partial node bootstrapping (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.
Author(s)
Alexander P. Christensen <alexpaulchristensen@gmail.com> & Yoed N. Kenett <yoedkenett@gmail.com>
References
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.
See Also
Useful links:
Report bugs at https://github.com/AlexChristensen/SemNeT/issues
Naive Random Walk Network Estimation
Description
Estimates a semantic network using the Naive Random Walk method described in Lerner, Ogrocki, and Thomas (2009)
Usage
NRW(data, type = c("num", "prop"), threshold = 0)
nrw(data, type = c("num", "prop"), threshold = 0)
Arguments
data |
Matrix or data frame.
A preprocessed verbal fluency matrix where rows are participants and
columns are the order of their verbal fluency responses. Content may be
the raw word responses or an ordered numeric response matrix (see
|
type |
Character.
Type of
Defaults to |
threshold |
Numeric.
Value of the minimum number or proportion of co-occurrences.
Defaults to |
Value
Returns an undirected semantic network
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
Lerner, A. J., Ogrocki, P. K., & Thomas, P. J. (2009). Network graph analysis of category fluency testing. Cognitive and Behavioral Neurology, 22, 45-52.
Examples
# Get data
data <- open.clean
# Organize group data
group <- open.group
low <- data[which(group == "Low"), ]
high <- data[which(group == "High"), ]
# Compute networks
low_net <- nrw(low)
high_net <- nrw(high)
Pathfinder Network
Description
Estimates a pathfinder network using the MST-Pathfinder Network method from Quirin et al. (2008; see also Schvaneveldt, 1990)
Usage
PF(data)
pf(data)
Arguments
data |
Matrix or data frame. A binary response matrix, or the original raw word responses |
Value
An adjacency matrix. The pre-binarization, Chebyshev-distance-weighted
network is attached as the "weighted" attribute, rather than being
computed and discarded
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# Obtain data
data <- open.binary
# Estimate network
pf_net <- pf(data)
Modularity
Description
Computes a global modularity measure (Q) using the Louvain community detection algorithm
Usage
Q(A)
q(A, resolution = 1, seed = NULL, signed = FALSE)
Arguments
A |
Matrix or data frame. An adjacency matrix of network data |
resolution |
Numeric.
Adjusts modularity to prefer smaller ( |
seed |
Numeric.
A seed for the Louvain algorithm's internal random number generator, for
reproducible community detection.
Defaults to |
signed |
Boolean.
Whether modularity should be computed on the signed network (Gomez et
al., 2009), discounting negative edges instead of folding them in as
positive.
Defaults to |
Details
Community detection runs via a compiled Louvain implementation
(Blondel et al., 2008) whose internal randomness depends only on
seed, not on R's global random number generator – unlike
igraph::cluster_louvain(), calling set.seed() beforehand has
no effect on q()'s reproducibility; pass seed directly instead.
Value
Returns Q, a measure of how well the network partitions into distinct, densely-connected communities
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Gomez, S., Jensen, P., & Arenas, A. (2009). Analysis of community structure in networks of correlated data. Physical Review E, 80, 016114.
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
Examples
# Pearson's correlation only for CRAN checks
fluency_data <- matrix(sample(0:1, 1000, replace = TRUE), nrow = 100, ncol = 10)
A <- suppressWarnings(tmfg(similarity(fluency_data, method = "cor")))
modularity <- q(A, seed = 1)
Shiny App for SemNeT
Description
Launches an interactive Shiny application for semantic
network analysis, covering network estimation, comparison, bootstrap and
permutation testing, random walk simulation, and spreading activation.
Results are retrieved via the app's own download buttons (as .rds/
.csv/image files), not returned to the R session that launched it –
each browser session keeps its own results independently, so the app can
be run locally or shared with multiple simultaneous users
Usage
SemNeTShiny()
Value
Invisibly returns NULL. Launches the app as a side effect;
see the app's own "Export" tab for how to retrieve results
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
if(interactive()){
SemNeTShiny()
}
Triangulated Maximally Filtered Graph
Description
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). Construction begins by forming a tetrahedron from the four nodes with the largest sum of correlations, then iteratively adds each remaining node to the connected set of three nodes (a triangle) it correlates with most strongly, until every node is included.
Usage
TMFG(data, depend = FALSE)
tmfg(data, depend = FALSE)
Arguments
data |
Matrix or data frame. A square association matrix (e.g. a correlation or similarity matrix) |
depend |
Boolean.
Is the network a dependency (directed) network?
Defaults to |
Details
The TMFG method applies a structural constraint on the network, which restrains the network to retain a certain number of edges (3n - 6). The network is composed of 3- and 4-node cliques (a triangle and a tetrahedron, respectively). Notably, TMFG can use any association measure and does not assume the data is multivariate normal.
Value
Returns a TMFG-filtered adjacency matrix
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# Pearson's correlation only for CRAN checks
fluency_data <- matrix(sample(0:1, 1000, replace = TRUE), nrow = 100, ncol = 10)
A <- suppressWarnings(tmfg(similarity(fluency_data, method = "cor")))
Frequency of Animal Responses
Description
Frequency of animal responses from Christensen & Kenett (2019). These frequencies
are used to generate data in the sim.fluency function.
Usage
data(animals.freq)
Format
animals.freq (vector, length = 367)
Examples
data("animals.freq")
Average Shortest Path Length
Description
Computes the global average shortest path length of a network
Usage
aspl(A, weighted = FALSE)
ASPL(A, weighted = FALSE)
Arguments
A |
Matrix or data frame. An adjacency matrix of network data |
weighted |
Boolean.
Is the network weighted?
Defaults to |
Value
Returns the network's ASPL. The per-node average shortest path
length and eccentricity are attached as the "node" and
"eccentricity" attributes, rather than being computed and discarded
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
Examples
# Pearson's correlation only for CRAN checks
fluency_data <- matrix(sample(0:1, 1000, replace = TRUE), nrow = 100, ncol = 10)
A <- suppressWarnings(tmfg(similarity(fluency_data, method = "cor")))
# Unweighted
network_aspl <- aspl(A)
Bootstrapped Semantic Network Analysis (Legacy)
Description
Backward-compatible wrapper for
bootstrap_SemNeT – bootSemNeT() was renamed
bootstrap_SemNeT() in SemNeT 2.0.0. The returned object gets both
the old class ("bootSemNeT", so plot() still dispatches to
plot.bootSemNeT) and the new one ("bootstrap_SemNeT",
so it can also be passed straight into bootstrap_test_SemNeT
or bootstrap_test_SemNeT's own legacy wrapper,
test.bootSemNeT)
Usage
bootSemNeT(
...,
method = c("CN", "NRW", "PF", "TMFG"),
methodArgs = list(),
type = c("case", "node"),
prop = 0.5,
sim,
weighted = FALSE,
iter = 1000,
cores
)
Arguments
... |
Matrices or data frames.
Response matrices, one per group, e.g. |
method |
Character.
See |
methodArgs |
List.
See |
type |
Character.
See |
prop |
Numeric.
See |
sim |
Character.
See |
weighted |
Boolean.
Unused – was already dead code in the original |
iter |
Numeric.
See |
cores |
Numeric.
See |
Value
See bootstrap_SemNeT
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Bootstrapped Semantic Network Analysis
Description
Repeatedly re-estimates each group's semantic network from
resampled data (dropping a proportion of nodes, or resampling participants
with replacement) to build a bootstrap distribution of aspl,
cc, and q for every group
Usage
bootstrap_SemNeT(
...,
method = c("tmfg", "cn", "nrw", "pf"),
method_args = list(),
type = c("case", "node"),
prop = 0.5,
sim = "cosine",
minimum_cases = 2,
iter = 1000,
cores = 1,
keep_networks = FALSE
)
Arguments
... |
Named matrices or data frames.
At least one response matrix, one per group, e.g.
|
method |
Character.
Network estimation method to use: |
method_args |
List.
Additional arguments passed on to the chosen |
type |
Character.
Type of bootstrap to perform: |
prop |
Numeric.
Only for |
sim |
Character.
Similarity measure to use, |
minimum_cases |
Numeric.
Only for |
iter |
Numeric.
Number of bootstrapped samples to generate per group.
Defaults to |
cores |
Numeric.
Number of processing cores to use.
Defaults to |
keep_networks |
Boolean.
Whether every bootstrapped network itself should be kept in the result, in
addition to its measures. A full set of |
Value
Returns a list of class "bootstrap_SemNeT":
groups |
A named list, one entry per group in |
meta |
A list of |
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Simulate datasets
one <- simulate_fluency(20)
two <- simulate_fluency(20)
# Bootstrap node-drop (partial) networks
boot_result <- bootstrap_SemNeT(
one = one, two = two, prop = .50, iter = 100, cores = 2,
method = "tmfg", type = "node"
)
# Bootstrap case-resampled networks -- equating (see `equate()`) requires
# named responses, so this uses real word responses instead
low <- open.clean[which(open.group == "Low"), ]
high <- open.clean[which(open.group == "High"), ]
boot_result <- bootstrap_SemNeT(
low = low, high = high, iter = 100, cores = 2,
method = "tmfg", type = "case", minimum_cases = 2
)
Statistical Tests for bootstrap_SemNeT
Description
Computes statistical tests comparing groups' bootstrapped
network measures from one or more bootstrap_SemNeT results
Usage
bootstrap_test_SemNeT(
...,
test = c("t-test", "ANOVA", "ANCOVA"),
measures = c("aspl", "cc", "q"),
formula = NULL,
groups = NULL
)
Arguments
... |
One or more |
test |
Character.
Type of statistical test: |
measures |
Character.
One or more of |
formula |
Character.
Only for |
groups |
Matrix or data frame.
One row per group (matched to |
Value
Returns a list of class "bootstrap_test_SemNeT":
test |
The |
measures |
The |
groups |
The (possibly defaulted) |
results |
A named list, one entry per |
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Get openness data
low <- open.clean[which(open.group == "Low"), ]
high <- open.clean[which(open.group == "High"), ]
# Bootstrap networks
boot_result <- bootstrap_SemNeT(
low = low, high = high, iter = 100, cores = 2,
type = "case", method = "tmfg"
)
# Compute tests
bootstrap_test_SemNeT(boot_result)
Clustering Coefficient
Description
Computes the global clustering coefficient (CC) of a network
Usage
cc(A, weighted = FALSE)
CC(A, weighted = FALSE)
Arguments
A |
Matrix or data frame. An adjacency matrix of network data |
weighted |
Boolean.
Is the network weighted?
Defaults to |
Value
Returns the network's CC. The per-node clustering coefficient is
attached as the "node" attribute, rather than being computed and discarded
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
Examples
# Pearson's correlation only for CRAN checks
fluency_data <- matrix(sample(0:1, 1000, replace = TRUE), nrow = 100, ncol = 10)
A <- suppressWarnings(tmfg(similarity(fluency_data, method = "cor")))
# Unweighted
network_cc <- cc(A)
Community Network Estimation
Description
Estimates a semantic network using the Community Network method described in Goni et al. (2011)
Usage
cn(data, window = 2, alpha = 0.05, enrich = FALSE)
CN(data, window = 2, alpha = 0.05, enrich = FALSE)
Arguments
data |
Matrix or data frame.
A preprocessed verbal fluency matrix where rows are participants and
columns are the order of their verbal fluency responses. Content may be
the raw word responses or an ordered numeric response matrix (see
|
window |
Numeric.
Size of window to look for co-occurrences in.
Defaults to |
alpha |
Numeric.
Significance value.
Defaults to |
enrich |
Boolean.
Should the network be enriched by connecting all nodes within their
respective modules?
Defaults to |
Value
Returns an undirected semantic network
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# Get data
data <- open.clean
# Organize group data
group <- open.group
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)
Compare Graphs (Legacy)
Description
Backward-compatible wrapper for compare_networks
– compare_nets() was renamed compare_networks() in SemNeT
2.0.0
Usage
compare_nets(
...,
title,
config,
placement = c("match", "default"),
weighted = FALSE,
qgraph.args = list()
)
Arguments
... |
Matrices or data frames.
Networks to plot, e.g. |
title |
List.
See |
config |
Character.
See |
placement |
Character.
See |
weighted |
Boolean.
See |
qgraph.args |
List.
See |
Value
See compare_networks
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Plot Networks for Comparison
Description
Uses qgraph to plot networks side by
side. Accepts any number of networks and arranges the plots using
floor(sqrt(length(...))) side-by-side columns (e.g. 3 networks: 1
row of 3; 6 networks: 2 rows of 3; 9 networks: 3 rows of 3)
Usage
compare_networks(
...,
title,
config = "spring",
placement = c("default", "match"),
weighted = FALSE,
qgraph_args = list()
)
Arguments
... |
Named matrices or data frames.
At least two network adjacency matrices, e.g.
|
title |
List.
Titles for each plot, in the same order as |
config |
Character.
Defaults to |
placement |
Character. How should nodes be placed when comparing networks?
Defaults to |
weighted |
Boolean.
Should networks be plotted with weights?
Defaults to |
qgraph_args |
List.
Additional arguments passed on to |
Value
Plots networks side by side using qgraph;
returns NULL invisibly
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# Simulate datasets
one <- simulate_fluency(10)
two <- simulate_fluency(10)
# Compute similarity matrices
cos1 <- similarity(one, method = "cosine")
cos2 <- similarity(two, method = "cosine")
# Compute networks
net1 <- suppressWarnings(tmfg(cos1))
net2 <- suppressWarnings(tmfg(cos2))
# Compare networks
compare_networks(one = net1, two = net2, config = "spring")
# Change edge colors
compare_networks(
one = net1, two = net2, config = "spring",
qgraph_args = list(edge.color = "blue")
)
Convert an Adjacency Matrix to Cytoscape Format
Description
Converts an adjacency matrix to Cytoscape's sparse edge-list format
Usage
convert2cytoscape(A)
Arguments
A |
Matrix or data frame. A cleaned, finalized network matrix ready to be visualized |
Value
A sparse matrix formatted for Cytoscape, with columns
nodeTO, nodeFROM, and nodeWEIGHT
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# Simulate toy binarized datasets
one <- matrix(sample(0:1, 100, replace = TRUE), nrow = 10, ncol = 10)
two <- matrix(sample(0:1, 100, replace = TRUE), nrow = 10, ncol = 10)
# Compute similarity matrices
cos1 <- similarity(one, method = "cosine")
cos2 <- similarity(two, method = "cosine")
# Compute networks
net1 <- suppressWarnings(tmfg(cos1))
net2 <- suppressWarnings(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)
Convert a Network to igraph's Format
Description
Converts an adjacency matrix into igraph's network format
Usage
convert2igraph(A)
Arguments
A |
Matrix or data frame. An adjacency (network) matrix |
Value
Returns a network in igraph's format
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Pearson's correlation only for CRAN checks
fluency_data <- matrix(sample(0:1, 500, replace = TRUE), nrow = 50, ncol = 10)
A <- suppressWarnings(tmfg(similarity(fluency_data, method = "cor")))
igraph_network <- convert2igraph(A)
Equate Groups
Description
Equates multiple binary response matrices to one another, so that every group retains exactly the responses common to all of them
Usage
equate(...)
Arguments
... |
Named binary response matrices or data frames.
At least two, e.g. |
Value
A named list of the equated binary response matrices, one per input, each containing the same responses (columns) in the same order
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Obtain binary data
bin <- open.binary
# Finalize each group
mat1 <- finalize(bin[c(1:5), ])
mat2 <- finalize(bin[c(6:10), ])
# Equate the groups
eq <- equate(mat1 = mat1, mat2 = mat2)
# Obtain respective equated response matrices
eq_mat1 <- eq$mat1
eq_mat2 <- eq$mat2
Finalize a Response Matrix
Description
Finalizes a binary response matrix by keeping only responses given by at least a minimum number of participants
Usage
finalize(data, minimum_cases = 2)
Arguments
data |
Matrix or data frame. A binary response matrix (participants x responses) |
minimum_cases |
Numeric.
Minimum number of participants required to have given a response for that
response to be kept.
Defaults to |
Value
A binary response matrix containing only responses given by at
least minimum_cases participants
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Obtain binary data
bin <- open.binary
# Finalize
final <- finalize(bin)
Forward Flow
Description
Computes the "forward flow" of a sequence of verbal fluency or free association responses (Gray et al., 2019): for each response after the first, the mean semantic distance (1 - cosine similarity) between that response and every response that preceded it, using word vectors from a user-supplied embedding matrix.
Unlike the pre-2.0.0 version of this function, no semantic space is downloaded automatically – CRAN policy prohibits a package silently authenticating with and downloading files from an external service at runtime. Bring your own pre-trained (e.g. GloVe, word2vec) or custom word embeddings instead
Usage
forward_flow(
response_matrix,
embeddings,
min_response = 3,
max_response = NULL,
type = c("fluency", "free"),
cores = 1
)
Arguments
response_matrix |
Matrix or data frame.
For |
embeddings |
Matrix or data frame. A word-embedding matrix: one row per vocabulary term (row names are the terms themselves), one column per embedding dimension. Not bundled or downloaded by this package – supply your own pre-trained or custom vectors. A response with no matching row is treated as missing (excluded from the distances it would have contributed to, rather than corrupting every flow value it touches) |
min_response |
Numeric.
Minimum number of responses a participant ( |
max_response |
Numeric.
Maximum number of responses to use, keeping only the first |
type |
Character.
|
cores |
Numeric.
Number of computer processing cores to use. Defaults to |
Value
For type = "fluency", a list with:
mean_flow |
A data frame of each participant's average forward flow |
response_flow |
A list, one element per participant, of that participant's response-by-response forward flow |
For type = "free", a list with:
mean_flow |
A data frame of each participant's average forward flow, across all of their cues |
mean_response_flow |
A data frame of each participant-cue pair's average forward flow |
response_flow |
A list, one element per participant (itself a list with one element per cue), of that cue's response-by-response forward flow |
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com> & Brendan Baker <bsb5477@psu.edu>
References
Gray, K., Anderson, S., Chen, E. E., Kelly, J. M., Christian, M. S., Patrick, J., ... & Lewis, K. (2019). "Forward flow": A new measure to quantify free thought and predict creativity. American Psychologist, 74(5), 539-554.
Beaty, R. E., Zeitlen, D. C., Baker, B. S., & Kenett, Y. N. (2021). Forward flow and creative thought: Assessing associative cognition and its role in divergent thinking. Thinking Skills and Creativity, 100859.
Examples
# A tiny toy embedding space and toy fluency data -- illustrates the
# interface only; use real pre-trained vectors (GloVe, word2vec, etc.) in
# practice
set.seed(1)
words <- c("dog", "cat", "wolf", "car", "truck", "bus")
embeddings <- matrix(rnorm(length(words) * 5), nrow = length(words))
row.names(embeddings) <- words
responses <- matrix(
c("dog", "wolf", "cat", "car", "truck", "bus"),
nrow = 2, byrow = TRUE, dimnames = list(c("P1", "P2"), NULL)
)
result <- forward_flow(responses, embeddings, min_response = 2)
result$mean_flow
High Openness to Experience Network
Description
High openness to experience network from Christensen & Kenett (2019)
Usage
data(net.high)
Format
net.high (matrix, 160 x 160)
References
Christensen, A. P., & Kenett, Y. N. (2019) Semantic network analysis (SemNA): A tutorial on preprocessing, estimating, and analyzing semantic networks. PsyArXiv.
Examples
data("net.high")
Low Openness to Experience Network
Description
Low openness to experience network from Christensen & Kenett (2019)
Usage
data(net.low)
Format
net.low (matrix, 160 x 160)
References
Christensen, A. P., & Kenett, Y. N. (2019) Semantic network analysis (SemNA): A tutorial on preprocessing, estimating, and analyzing semantic networks. PsyArXiv.
Examples
data("net.low")
Simulated Result for Dataset One
Description
A result of bootSemNeT from a simulated dataset
Usage
data(one.result)
Format
one.result (list, length = 4)
Examples
data("one.result")
Binary response Matrices (Openness and Verbal Fluency)
Description
Binary response matrices for the Animals verbal fluency data (n = 516) from Christensen et al. (2018).
Usage
data(open.binary)
Format
open.binary (matrix, 516 x 367)
References
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.
Examples
data("open.binary")
Cleaned response Matrices (Openness and Verbal Fluency)
Description
Cleaned response matrices for the Animals verbal fluency data (n = 516) from Christensen et al. (2018).
Usage
data(open.clean)
Format
open.clean (matrix, 516 x 35)
References
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.
Examples
data("open.clean")
Groups for Openness and Verbal Fluency
Description
Groups for the Animals verbal fluency data (n = 516)
from Christensen et al. (2018; see also open.clean).
Usage
data(open.group)
Format
open.group (vector, length = 516)
References
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.
Examples
data("open.group")
Permutation Test for Network Measures
Description
Computes a permutation test to determine whether there's a difference in a global network measure between two samples
Usage
permutation_SemNeT(
sample_1 = NULL,
sample_2 = NULL,
method = c("tmfg", "cn", "nrw", "pf"),
method_args = list(),
sim = "cosine",
minimum_cases = 2,
measure = c("aspl", "cc", "q"),
alternative = c("two_tailed", "less", "greater"),
iter = 1000,
cores = 1,
previous = NULL,
keep_networks = FALSE
)
Arguments
sample_1 |
Matrix or data frame.
Response matrix to be compared with |
sample_2 |
Matrix or data frame.
Response matrix to be compared with |
method |
Character.
Network estimation method to use: |
method_args |
List.
Additional arguments passed on to the chosen |
sim |
Character.
Similarity measure to use, |
minimum_cases |
Numeric.
Only for |
measure |
Character.
Global network measure to compare: one of |
alternative |
Character.
Alternative hypothesis: |
iter |
Numeric.
Number of permuted samples to generate.
Defaults to |
cores |
Numeric.
Number of processing cores to use.
Defaults to |
previous |
A |
keep_networks |
Boolean.
Whether every permuted sample's estimated networks should be kept in the
result, in addition to the measure values already computed from them. Only
needed to test a second |
Value
Returns a list of class "permutation_SemNeT":
result |
A data frame with |
networks |
A list of |
method |
The |
differences |
The observed measure difference for every permutation |
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Get openness data -- equating (see `equate()`) requires named responses
low <- open.clean[which(open.group == "Low"), ]
high <- open.clean[which(open.group == "High"), ]
# aspl
perm_aspl <- permutation_SemNeT(
low, high, method = "tmfg", measure = "aspl", iter = 100, cores = 2,
keep_networks = TRUE
)
# cc, reusing the same permuted networks
perm_cc <- permutation_SemNeT(previous = perm_aspl, measure = "cc", cores = 2)
Plot for bootSemNeT (Legacy)
Description
Backward-compatible wrapper for
plot.bootstrap_SemNeT – dispatches for objects returned by
the legacy bootSemNeT, which carry the old class alongside
the new one
Usage
## S3 method for class 'bootSemNeT'
plot(..., groups = NULL, measures = c("ASPL", "CC", "Q"))
Arguments
... |
An object from |
groups |
Character.
Labels for groups in the order they were entered into
|
measures |
Character.
One or more of |
Value
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Plot for bootstrap_SemNeT
Description
Plots the bootstrapped distribution of each requested measure as a raincloud plot (Allen, Poggiali, Whitaker, Marshall, & Kievit, 2018) – a half (flat) violin showing the full distribution's shape, paired with a boxplot and the raw jittered bootstrap values – one panel per measure, grouped side by side
Usage
## S3 method for class 'bootstrap_SemNeT'
plot(x, measures = c("aspl", "cc", "q"), ...)
Arguments
x |
A |
measures |
Character.
One or more of |
... |
Currently unused |
Value
A ggplot object, returned visibly (so it prints automatically
at the console, and renders correctly inside shiny::renderPlot())
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
Allen, M., Poggiali, D., Whitaker, K., Marshall, T. R., & Kievit, R. A. (2018). Raincloud plots: a multi-platform tool for robust data visualization. PeerJ Preprints, 6, e27137v1. doi:10.7287/peerj.preprints.27137v1
Examples
# Get openness data
low <- open.clean[which(open.group == "Low"), ]
high <- open.clean[which(open.group == "High"), ]
# Bootstrap networks
boot_result <- bootstrap_SemNeT(
low = low, high = high, iter = 100, cores = 2,
type = "case", method = "tmfg"
)
# Plot
plot(boot_result)
Random Network Test (Legacy)
Description
Backward-compatible wrapper for
random_network_test – randnet.test() was renamed
random_network_test() in SemNeT 2.0.0
Usage
randnet.test(..., iter, cores)
Arguments
... |
Matrices or data frames.
Networks to test, e.g. |
iter |
Numeric.
See |
cores |
Numeric.
See |
Value
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Test Against Random Networks
Description
Performs significance tests for global measures of semantic networks against the global measures of equivalent size (and density) random networks
Usage
random_network_test(..., iter = 1000, cores = 1)
Arguments
... |
Named matrices or data frames.
Semantic networks to be compared against random networks, e.g.
|
iter |
Numeric.
Number of random networks to generate per input network.
Defaults to |
cores |
Numeric.
Number of computer processing cores to use.
Defaults to |
Value
Returns a named list (one entry per input network) of data frames
with the p-value, and the random-network distribution's mean and
standard deviation, for each of aspl, cc, and q
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# 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
random_network_test(low = net_one, high = net_two, iter = 100, cores = 2)
Random Walk Simulation
Description
Simulates random walks over two networks to examine the characteristics of spontaneous spreading activation (see Kenett & Austerweil, 2016)
Usage
random_walk(
A,
B,
name_a = "A",
name_b = "B",
reps = 20,
steps = 10,
iter = 10000,
cores = 1
)
Arguments
A |
Matrix or data frame. Adjacency matrix of a semantic network |
B |
Matrix or data frame. A comparison adjacency matrix of a semantic network |
name_a |
Character.
Label for network |
name_b |
Character.
Label for 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.
Defaults to |
Value
A list with long (every simulated summary statistic, all
numeric) and short (a compact, correctly-typed summary with
Mann-Whitney p-values and effect directions)
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com> and Yoed Kenett <yoedkenett@gmail.com>
References
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.
Examples
# Simulate toy binarized datasets
one <- matrix(sample(0:1, 100, replace = TRUE), nrow = 10, ncol = 10)
two <- matrix(sample(0:1, 100, replace = TRUE), nrow = 10, ncol = 10)
# Compute similarity matrices
cos1 <- similarity(one, method = "cosine")
cos2 <- similarity(two, method = "cosine")
# Compute networks
net1 <- suppressWarnings(tmfg(cos1))
net2 <- suppressWarnings(tmfg(cos2))
# Run random walk analysis
rw_results <- random_walk(net1, net2, iter = 100, cores = 2)
Random Walk Simulation (Legacy)
Description
Backward-compatible wrapper for random_walk –
randwalk() was renamed random_walk() in SemNeT 2.0.0
Usage
randwalk(A, B, reps = 20, steps = 10, iter = 10000, cores)
Arguments
A, B |
Matrix or data frame.
Two networks to compare – names are captured from the given expressions,
matching the original's own |
reps |
Numeric.
See |
steps |
Numeric.
See |
iter |
Numeric.
See |
cores |
Numeric.
See |
Value
See random_walk
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Read a Response or Group File in Any Supported Format
Description
Multi-format file reader dispatching on a file's extension:
.rds, .RData, .csv, .txt, .xls/.xlsx
(via readxl), .sav (via foreign), .mat (via
R.matlab), or no/unrecognized extension (read as plain delimited
text). Used by the Shiny app's upload widgets, and usable directly for the
same purpose outside Shiny
Usage
read_uploaded_file(datapath, filename, header = TRUE, sep = ",")
Arguments
datapath |
Character.
Path to the file's actual content on disk (e.g. Shiny's |
filename |
Character.
The file's original name, used only to determine its format from its
extension – kept separate from |
header |
Boolean.
Does the file have a header row (for delimited-text and spreadsheet formats)?
Defaults to |
sep |
Character.
Field delimiter (for delimited-text formats).
Defaults to |
Value
The file's contents as a data frame (or the single object it
contains, for .rds/.RData)
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
path <- tempfile(fileext = ".csv")
write.csv(data.frame(x = 1:3, y = c("a", "b", "c")), path, row.names = FALSE)
read_uploaded_file(path, "responses.csv")
Response Pattern Analysis (Legacy)
Description
Backward-compatible wrapper for response_analysis
– response.analysis() was renamed response_analysis() in
SemNeT 2.0.0
Usage
response.analysis(...)
Arguments
... |
Matrices or data frames.
Response matrices, e.g. |
Value
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Response Analysis
Description
Computes the difference in the total and unique number of responses between groups (follows Christensen et al., 2018). With more than two groups, every pairwise comparison is returned, since both underlying tests (a two-sample t-test and McNemar's test) are inherently pairwise
Usage
response_analysis(...)
Arguments
... |
Named matrices or data frames.
At least two response matrices (raw word responses or already-binary), one
per group, e.g. |
Value
With exactly two groups, a list with:
total |
A named vector comparing the total responses given by each participant via a two-sample t-test and Cohen's d |
unique |
A named vector comparing the number of unique responses provided by each group via McNemar's test |
With more than two groups, a named list of such lists, one per pair of
groups (named "<group1>_vs_<group2>")
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# Obtain data
low <- open.clean[which(open.group == "Low"), ]
high <- open.clean[which(open.group == "High"), ]
# Perform analysis
response_analysis(low = low, high = high)
Convert Raw Responses to a Binary Response Matrix
Description
Converts a raw word-response matrix (participants by response order, one word per cell) into a binary (participant by vocabulary) response matrix, alongside a matching matrix recording response order
Usage
responses_to_binary(responses)
Arguments
responses |
Matrix or data frame.
A raw word-response matrix: participants (rows) by response order
(columns), one word per cell (e.g. verbal fluency data). Empty, missing,
and placeholder cells ( |
Value
A list of class "responses_to_binary" with:
binary |
A participant by vocabulary matrix of 0s (never said) and 1s (said) |
order |
A participant by vocabulary matrix of 0s (never said) and the response's 1-based order (first said, second said, ...) otherwise |
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Raw fluency responses, 2 participants, up to 3 responses each
responses <- matrix(
c("dog", "cat", NA, "cat", "wolf", "dog"),
nrow = 2, byrow = TRUE
)
result <- responses_to_binary(responses)
result$binary
result$order
Semantic Network Measures
Description
Computes the average shortest path length (aspl),
clustering coefficient (cc), and modularity (q)
of a network
Usage
semantic_network_measures(
A,
measures = c("aspl", "cc", "q"),
weighted = FALSE,
seed = NULL
)
Arguments
A |
Matrix or data frame. An adjacency matrix of a network |
measures |
Character.
Which global network measures to compute: any of |
weighted |
Boolean.
Should weighted measures be computed?
Defaults to |
seed |
Numeric.
Passed on to |
Value
Returns a named numeric vector with one value per requested measure
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Simulate a toy binarized dataset
one <- matrix(sample(0:1, 100, replace = TRUE), nrow = 10, ncol = 10)
# Compute a similarity matrix
cos <- similarity(one, method = "cosine")
# Compute a network
net <- suppressWarnings(tmfg(cos))
# Compute global network measures
global_measures <- semantic_network_measures(net)
Semantic Network Measures (Legacy)
Description
Backward-compatible wrapper for
semantic_network_measures – semnetmeas() was renamed
semantic_network_measures() in SemNeT 2.0.0
Usage
semnetmeas(A, meas = c("ASPL", "CC", "Q"), weighted = FALSE)
Arguments
A |
Matrix or data frame.
See |
meas |
Character.
One or more of |
weighted |
Boolean.
See |
Value
A named numeric vector, named to match meas (uppercase),
as in the original
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Simulate Verbal Fluency Data (Legacy)
Description
Backward-compatible wrapper for simulate_fluency
– sim.fluency() was renamed simulate_fluency() in SemNeT 2.0.0
Usage
sim.fluency(nodes, cases, random = FALSE)
Arguments
nodes |
Numeric.
See |
cases |
Numeric.
See |
random |
Boolean.
See |
Value
See simulate_fluency
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Measures of Similarity
Description
Computes a similarity matrix between the columns of a binarized verbal fluency or linguistic dataset (see Choi, Cha, & Tappert, 2010 for additional measures)
Usage
similarity(
data,
method = c("cosine", "angular", "cor", "euclid", "faith", "jaccard", "phi", "rr")
)
Arguments
data |
Matrix or data frame. A binarized dataset of verbal fluency or linguistic data |
method |
Character.
Type of similarity measure to compute. One of |
Value
A symmetric similarity matrix
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
References
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.
Examples
# Simulate a toy binarized dataset
one <- matrix(sample(0:1, 100, replace = TRUE), nrow = 10, ncol = 10)
# Compute a cosine similarity matrix
cos <- similarity(one, method = "cosine")
Simulate a Verbal Fluency Binary Response Matrix
Description
Simulates verbal fluency data based on the number of nodes
desired in the resulting network. Each response's total endorsement count
is simulated from a Poisson distribution (see rpois), using
frequencies from the animals.freq data; participants'
individual responses are then simulated with a probability of endorsing
each response equal to that response's simulated total over the number
of participants
Usage
simulate_fluency(nodes = 100, cases = 500, random = FALSE)
Arguments
nodes |
Numeric.
Number of nodes (unique responses) to simulate.
Defaults to |
cases |
Numeric.
Number of participants to simulate.
Defaults to |
random |
Boolean.
Should response frequencies be randomly sampled (with replacement) from
|
Value
A binary matrix with cases rows (participants) and
nodes columns (responses)
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Examples
# Simulate data for 50 nodes and 200 participants
simulate_fluency(nodes = 50, cases = 200)
Statistical Tests for bootSemNeT (Legacy)
Description
Backward-compatible wrapper for
bootstrap_test_SemNeT – test.bootSemNeT() was
renamed bootstrap_test_SemNeT() in SemNeT 2.0.0. Only accepts
objects produced by this package's own bootSemNeT /
bootstrap_SemNeT, not a raw object saved from SemNeT
< 2.0.0
Usage
test.bootSemNeT(
...,
test = c("ANCOVA", "ANOVA", "t-test"),
measures = c("ASPL", "CC", "Q"),
formula = NULL,
groups = NULL
)
Arguments
... |
One or more |
test |
Character.
See |
measures |
Character.
One or more of |
formula |
Character.
See |
groups |
Matrix or data frame.
See |
Value
Author(s)
Alexander Christensen <alexpaulchristensen@gmail.com>
Simulated Result for Dataset One and Two
Description
A result of bootSemNeT from two simulated datasets
Usage
data(two.result)
Format
two.result (list, length = 6)
Examples
data("two.result")
Plots for Vignette
Description
Plots for vignette taken from Christensen & Kenett (2019)
Usage
data(vignette.plots)
Format
vignette.plots (list, length = 3)
References
Christensen, A. P., & Kenett, Y. N. (2019) Semantic network analysis (SemNA): A tutorial on preprocessing, estimating, and analyzing semantic networks. PsyArXiv.
Examples
data("vignette.plots")