| 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, and a function to compute global network measures. Significance tests, including permutation testing, and plotting features are also implemented. |
| Authors: | Alexander P. Christensen [aut, cre] (ORCID: <https://orcid.org/0000-0002-9798-7037>), Yoed N. Kenett [aut, ctb] (ORCID: <https://orcid.org/0000-0003-3872-7689>), Chun-Ying Tu [ctb] (ORCID: <https://orcid.org/0000-0002-0607-6191>, Identified an inferential error in the bootstrapping procedure in versions <= 1.4.5), Martin Chodorow [ctb] (ORCID: <https://orcid.org/0000-0001-5780-2598>, Identified an inferential error in the bootstrapping procedure in versions <= 1.4.5), Patricia J. Brooks [ctb] (ORCID: <https://orcid.org/0000-0001-8030-8811>, Identified an inferential error in the bootstrapping procedure in versions <= 1.4.5), Emilia Ezrina [ctb] (ORCID: <https://orcid.org/0000-0001-6598-0773>, Identified an inferential error in the bootstrapping procedure in versions <= 1.4.5), Virginia Valian [ctb] (ORCID: <https://orcid.org/0000-0002-2128-5856>, Identified an inferential error in the bootstrapping procedure in versions <= 1.4.5) |
| Maintainer: | Alexander P. Christensen <[email protected]> |
| License: | GPL (>= 3.0) |
| Version: | 2.1.1 |
| Built: | 2026-10-25 16:51:44 UTC |
| Source: | https://github.com/alexchristensen/semnet |
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.
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 simulate_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 a network
aspl(A, weighted = FALSE, type = c("arithmetic", "harmonic")) ASPL(A, weighted = FALSE)aspl(A, weighted = FALSE, type = c("arithmetic", "harmonic")) ASPL(A, weighted = FALSE)
A |
Matrix or data frame. An adjacency matrix of network data. A non-symmetric matrix is treated as a directed network (a path follows the direction of an edge from row to column), whereas the other measures require an undirected (symmetric) network |
weighted |
Boolean.
Is the network weighted? A weighted edge's length is the inverse of its
weight (weights are strengths), so the value depends on the scale of the
weights and negative weights are not allowed.
Defaults to |
type |
Character (length = 1).
How the shortest-path distances are averaged.
Defaults to
|
For a connected network, "arithmetic" is the usual average
shortest path length (e.g., igraph::mean_distance()), and
"harmonic" is smaller than it. They differ most for a disconnected
network: "arithmetic" ignores unreachable pairs, which makes a
fragmented network look better connected than it is and weights each node by
the size of its component, whereas "harmonic" counts them. A network
with no connected pair has an Inf harmonic ASPL.
Returns the network's ASPL. The per-node average distance
(type-matched; NaN for an isolated node when
"arithmetic", Inf when "harmonic") and the
eccentricity (the longest finite shortest path) are attached as the
"node" and "eccentricity" attributes, rather than being
computed and discarded
Alexander Christensen <[email protected]>
Latora, V., & Marchiori, M. (2001). Efficient behavior of small-world networks. Physical Review Letters, 87, 198701.
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 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)# 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)
Converts a binary (participant by vocabulary) response matrix,
or the result of responses2binary, back into a raw
word-response matrix (participants by response order, one word per cell)
binary2responses(binary_matrix)binary2responses(binary_matrix)
binary_matrix |
Matrix, data frame, or |
A matrix of words with participants as rows and response order as
columns (Response_01, Response_02, ...). Rows are left-aligned
and padded with NA
Alexander Christensen <[email protected]>
# Raw fluency responses, 2 participants, up to 3 responses each responses <- matrix( c("dog", "cat", NA, "cat", "wolf", "dog"), nrow = 2, byrow = TRUE ) # Round trip: raw -> binary -> raw binary2responses(responses2binary(responses))# Raw fluency responses, 2 participants, up to 3 responses each responses <- matrix( c("dog", "cat", NA, "cat", "wolf", "dog"), nrow = 2, byrow = TRUE ) # Round trip: raw -> binary -> raw binary2responses(responses2binary(responses))
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)
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.
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 |
See bootstrap_SemNeT
Alexander Christensen <[email protected]>
Estimates each group's semantic network from iter
resampled datasets (participants resampled with replacement or a proportion
of nodes dropped) to build bootstrap distributions of aspl,
cc, and q
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, seed = NULL )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, seed = NULL )
... |
Named matrices or data frames.
One response matrix per group (at least one), e.g.,
|
method |
Character (length = 1).
Network estimation method.
Defaults to |
method_args |
List.
Additional arguments passed to |
type |
Character (length = 1).
Type of bootstrap.
Defaults to
|
prop |
Numeric (length = 1).
Only for |
sim |
Character (length = 1).
Similarity measure for |
minimum_cases |
Numeric (length = 1).
Only for |
iter |
Numeric (length = 1).
Number of bootstrap samples per group.
Defaults to |
cores |
Numeric (length = 1).
Number of processing cores.
Defaults to |
keep_networks |
Boolean (length = 1).
Should every bootstrapped network be kept?
These can be large ( |
seed |
Numeric (length = 1).
Defaults to |
Returns a list containing:
groups |
A named list with one list per group containing
|
meta |
A list containing |
Alexander Christensen <[email protected]>
bootstrap_test_SemNeT for testing group differences and
plot for plotting the distributions
# 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, # increase for more precise results cores = 2, method = "tmfg", type = "node", seed = 1234 ) # 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, # increase for more precise results cores = 2, method = "tmfg", type = "case", minimum_cases = 2 )# 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, # increase for more precise results cores = 2, method = "tmfg", type = "node", seed = 1234 ) # 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, # increase for more precise results cores = 2, method = "tmfg", type = "case", minimum_cases = 2 )
bootstrap_SemNeT
Compares groups' bootstrapped network measures using Wald tests and confidence intervals of the within-iteration group contrasts. The bootstrap samples are never treated as independent observations
bootstrap_test_SemNeT( ..., measures = c("aspl", "cc", "q"), groups = NULL, formula = NULL, ci_level = 0.95, adjust = c("none", "bonferroni"), ci_type = c("normal", "bc", "percentile"), test = NULL, legacy = FALSE )bootstrap_test_SemNeT( ..., measures = c("aspl", "cc", "q"), groups = NULL, formula = NULL, ci_level = 0.95, adjust = c("none", "bonferroni"), ci_type = c("normal", "bc", "percentile"), test = NULL, legacy = FALSE )
... |
One or more |
measures |
Character.
One or more of |
groups |
Matrix or data frame.
One row per group (matched to the group names by row name if present,
otherwise by the order groups were entered), one column per design variable.
With one variable, every pair of its levels is compared; with several,
the main effect of each variable is compared (the unweighted average of the
groups at each level).
Defaults to |
formula |
Character (length = 1).
Only for multiple variables in |
ci_level |
Numeric (length = 1).
Confidence level between 0 and 1 (exclusive).
Defaults to |
adjust |
Character (length = 1).
Multiplicity adjustment across the comparisons within each measure. Nothing
is ever adjusted across the measures or across the objects passed in
|
ci_type |
Character (length = 1).
Type of test and interval (not used for node results).
Defaults to
|
test |
Character (length = 1).
Only for |
legacy |
Boolean (length = 1).
Should the parametric tests on bootstrap replicates from versions before
2.1.0 be reproduced?
These tests are statistically invalid: they treat bootstrap samples
as independent observations and divide the bootstrap standard deviation
(already a standard error) by |
Always run permutation_SemNeT alongside this function
and report both: the bootstrap shows how precisely each group's networks and
their difference are estimated, whereas the permutation test asks whether
group membership matters.
Groups are bootstrapped independently, so the difference between two groups' measures within a bootstrap iteration is a draw from the bootstrap distribution of the group difference.
With ci_type = "normal" (default), the test statistic is the Wald
statistic , where is the
observed contrast and is the standard deviation of the
within-iteration contrasts (the bootstrap standard error). The
p-value is and matches the interval
. The null hypothesis is
that the contrast at the study's sample sizes is zero, not the
large-sample contrast, because network measures depend on sample size. The
test relies on a normal approximation and was conservative in permuted-data
checks. When group labels can be permuted, permutation_SemNeT
is the exact test and should be preferred.
For ci_type = "bc" and "percentile", a difference is reliable if
the interval excludes 0 (Tu et al., under review). No p-value is
reported (p_value is NA): the smallest level at which such an
interval excludes 0 is not a null-distribution p-value and was easily
mistaken for one. Use ci_type = "normal" for a Wald p-value, or
permutation_SemNeT for a test. Case resampling changes
each resampled network's size, so the bootstrap distribution is not centred on
the full-data statistic (reported as bias).
Node results (type = "node") subsample words, not participants, and
the subsample sizes change the measures themselves, so they are summarized
descriptively instead of tested.
Returns a list containing:
test |
|
measures |
The measures that were tested |
groups |
The |
results |
A named list with one list per object in
For node results, |
meta |
A named list like |
ci_level |
The confidence level used |
adjust |
The multiplicity adjustment used |
ci_type |
The test and interval type used |
legacy |
Whether the legacy (invalid) tests were run |
Alexander Christensen <[email protected]>
Bootstrap
Efron, B., & Tibshirani, R. J. (1993).
An introduction to the bootstrap.
Chapman & Hall.
Inflated bootstrap statistics
Tu, C.-Y., Chodorow, M., Brooks, P. J., Ezrina, E., & Valian, V. (under review).
Inflated statistics lead to incorrect inference: How (not) to make
cognitive network group comparisons.
permutation_SemNeT for a permutation test and
bootstrap_SemNeT for generating the bootstrap samples
# 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 = 1000, cores = 2, type = "case", method = "tmfg" ) # Wald tests of the group differences bootstrap_test_SemNeT(boot_result) # Percentile intervals bootstrap_test_SemNeT(boot_result, ci_type = "percentile")# 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 = 1000, cores = 2, type = "case", method = "tmfg" ) # Wald tests of the group differences bootstrap_test_SemNeT(boot_result) # Percentile intervals bootstrap_test_SemNeT(boot_result, ci_type = "percentile")
Computes the clustering coefficient (CC) of a network, either as the average of the nodes' local clustering coefficients (the default) or as the global clustering coefficient (transitivity)
cc(A, weighted = FALSE, na.rm = FALSE, type = c("average", "global")) CC(A, weighted = FALSE)cc(A, weighted = FALSE, na.rm = FALSE, type = c("average", "global")) CC(A, weighted = FALSE)
A |
Matrix or data frame. A symmetric adjacency matrix of network data |
weighted |
Boolean.
Is the network weighted? The weighted coefficient generalizes the
triangle count to the geometric-mean triangle intensity (Onnela et al., 2005;
Rubinov & Sporns, 2010), which is defined for weights scaled by the network's
largest absolute weight, so the weights are divided by it first: CC does not
depend on the scale of the weights. With negative weights (a signed
network) a triangle's intensity can be negative, so CC can be negative; this
signed extension (the signed cube root of the weights) is not part of the
cited definitions.
Defaults to |
na.rm |
Boolean.
A node with fewer than two neighbors has no possible triangle, so its local
clustering coefficient is undefined. With |
type |
Character (length = 1). How CC is computed:
Defaults to |
The local clustering coefficient of a node is the (weighted)
triangle count of the node divided by , where is
the node's number of neighbors. The average coefficient weights every node
equally, so nodes with few neighbors count as much as hubs. The global
coefficient sums triangles and triples over the nodes before dividing, so it
is dominated by high-degree nodes; the two can differ substantially in
networks with hubs. For an unweighted network, type = "global" equals
igraph::transitivity(type = "global"), which is NaN (as it is
here) when no node has two neighbors, because no triangle is then possible.
Returns the network's CC. The per-node (local) clustering coefficient
is attached as the "node" attribute (NA for a node with fewer
than two neighbors when na.rm = TRUE, and 0 otherwise)
Alexander Christensen <[email protected]>
Newman, M. E. J. (2003). The structure and function of complex networks. SIAM Review, 45, 167-256.
Onnela, J.-P., Saramaki, J., Kertesz, J., & Kaski, K. (2005). Intensity and coherence of motifs in weighted complex networks. Physical Review E, 71, 065103.
Rubinov, M., & Sporns, O. (2010). Complex network measures of brain connectivity: Uses and interpretations. NeuroImage, 52, 1059-1069.
Watts, D. J., & Strogatz, S. H. (1998). Collective dynamics of 'small-world' networks. Nature, 393, 440-442.
# 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"))) # Average of the local clustering coefficients network_cc <- cc(A) # Global clustering coefficient (transitivity) global_cc <- cc(A, type = "global")# 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"))) # Average of the local clustering coefficients network_cc <- cc(A) # Global clustering coefficient (transitivity) global_cc <- cc(A, type = "global")
Estimates a semantic network using the Community Network method described in Goni et al. (2011)
cn(data, window = 2, alpha = 0.05, enrich = FALSE, cutoff = 0.5) CN(data, window = 2, alpha = 0.05, enrich = FALSE, cutoff = 0.5)cn(data, window = 2, alpha = 0.05, enrich = FALSE, cutoff = 0.5) CN(data, window = 2, alpha = 0.05, enrich = FALSE, cutoff = 0.5)
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 (a whole number; Goni et al.
(2011) require it to be smaller than the average number of responses per
participant).
Defaults to |
alpha |
Numeric.
Significance level of the test of each pair of responses' co-occurrence
against chance, following Goni et al. (2011): the pair's co-occurrence rate
gets a two-sided |
enrich |
Boolean.
Should the network be enriched by connecting all nodes within their
respective modules?
Defaults to |
cutoff |
Numeric.
Height at which the hierarchical clustering of the generalized topological
overlap dissimilarity is cut into modules when |
Returns an undirected semantic network. As in Goni et al. (2011), only the largest connected component is kept: responses without a significant co-occurrence with the others (typically many of the less frequent responses) are dropped, so the network has fewer nodes than there are distinct responses. A 0 x 0 network (with a warning) is returned when no pair of responses co-occurs significantly
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 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)# 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)
Backward-compatible wrapper for compare_networks
– compare_nets() was renamed compare_networks() in SemNeT
2.0.0
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.
Networks to plot, e.g. |
title |
List.
See |
config |
Character.
See |
placement |
Character.
See |
weighted |
Boolean.
See |
qgraph.args |
List.
See |
See compare_networks
Alexander Christensen <[email protected]>
Uses qgraph to plot networks side by
side. Accepts any number of networks and arranges the plots using
floor(sqrt(length(...))) rows (e.g. 3 networks: 1 row of 3; 6 networks:
2 rows of 3; 9 networks: 3 rows of 3)
compare_networks( ..., title, config = "spring", placement = c("default", "match"), weighted = FALSE, qgraph_args = list() )compare_networks( ..., title, config = "spring", placement = c("default", "match"), weighted = FALSE, qgraph_args = list() )
... |
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 |
Plots networks side by side using qgraph;
returns NULL invisibly
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.
# 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") )# 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") )
Converts an adjacency matrix to Cytoscape's sparse edge-list format
convert2cytoscape(A)convert2cytoscape(A)
A |
Matrix or data frame. A cleaned, finalized network matrix ready to be visualized |
A sparse matrix formatted for Cytoscape, with columns
nodeTO, nodeFROM, and nodeWEIGHT. An undirected edge
is listed twice, once in each direction (as Cytoscape expects for a directed
edge list), and the weights are stored as text together with the node names
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 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)# 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)
Converts an adjacency matrix into igraph's network format.
Nodes without any edge (a nonzero entry in their row or column) are
removed, so the returned network can have fewer nodes than A
convert2igraph(A)convert2igraph(A)
A |
Matrix or data frame. A symmetric adjacency (network) matrix |
Returns a network in igraph's format
Alexander Christensen <[email protected]>
# 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)# 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)
Equates multiple binary response matrices to one another, so that every group retains exactly the responses common to all of them
equate(...)equate(...)
... |
Named binary response matrices or data frames.
At least two, e.g. |
A named list of the equated binary response matrices, one per input, each containing the same responses (columns) in the same order
Alexander Christensen <[email protected]>
# 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# 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
Finalizes a binary response matrix by keeping only responses given by at least a minimum number of participants
finalize(data, minimum_cases = 2)finalize(data, minimum_cases = 2)
data |
Matrix or data frame. A binary response matrix (participants x responses) |
minimum_cases |
Numeric.
Minimum number of participants (at least |
A binary response matrix containing only responses given by at
least minimum_cases participants
Alexander Christensen <[email protected]>
# Obtain binary data bin <- open.binary # Finalize final <- finalize(bin)# Obtain binary data bin <- open.binary # Finalize final <- finalize(bin)
textcleaner Objects in the Global EnvironmentScans .GlobalEnv for objects inheriting class
"textcleaner" and "fluency" (from SemNetCleaner's
own textcleaner()/textcleaner_shiny() – a sibling
package) – used by the Shiny app's Load Data tab to offer loading one
directly, as a second data source alongside its own file-upload widget.
Restricted to type = "fluency" results: a type = "free"
result's $data$clean is a long-format response/cue/ID table, a
different shape than the participant x response-slot word matrix this
package's own responses2binary() (and every bundled example
dataset) expects – not something to silently reshape without a real
design decision, so it's excluded here rather than offered and failing
downstream.
find_textcleaner_objects()find_textcleaner_objects()
A character vector of object names in .GlobalEnv that are
usable textcleaner results (possibly empty)
Alexander Christensen <[email protected]>
find_textcleaner_objects()find_textcleaner_objects()
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
forward_flow( response_matrix, embeddings, min_response = 3, max_response = NULL, type = c("fluency", "free"), cores = 1 )forward_flow( response_matrix, embeddings, min_response = 3, max_response = NULL, type = c("fluency", "free"), cores = 1 )
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 |
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 |
Alexander Christensen <[email protected]> & Brendan Baker <[email protected]>
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.
# 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# 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 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)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 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 |
Returns an 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 group <- open.group 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 group <- open.group 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")
Tests whether global network measures differ between two samples by comparing the observed difference with a null distribution from randomly re-dealing the pooled participants into two samples
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", "two_tailed_centered", "two_tailed_doubled", "less", "greater"), iter = 1000, cores = 1, previous = NULL, keep_networks = FALSE, seed = NULL, alpha = 0.05 )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", "two_tailed_centered", "two_tailed_doubled", "less", "greater"), iter = 1000, cores = 1, previous = NULL, keep_networks = FALSE, seed = NULL, alpha = 0.05 )
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 (length = 1).
Network estimation method.
Defaults to |
method_args |
List.
Additional arguments passed to |
sim |
Character (length = 1).
Similarity measure for |
minimum_cases |
Numeric (length = 1).
Only for |
measure |
Character.
One or more of |
alternative |
Character (length = 1).
Alternative hypothesis.
Defaults to
|
iter |
Numeric (length = 1).
Number of permutations (the first is the observed data).
Defaults to |
cores |
Numeric (length = 1).
Number of processing cores.
Defaults to |
previous |
|
keep_networks |
Boolean (length = 1).
Should every permuted network be kept?
Only needed to test other measures later with |
seed |
Numeric (length = 1).
Defaults to |
alpha |
Numeric (length = 1).
Significance level between 0 and 1 (exclusive) used to label the printed
|
Always run bootstrap_test_SemNeT (on
bootstrap_SemNeT results) alongside this function and report
both: the permutation test asks whether group membership matters, whereas the
bootstrap shows how precisely each group's networks and their difference are
estimated.
The null hypothesis is that the participants' group labels are
exchangeable: both groups' participants come from the same population of
responses. A rejection therefore says the groups differ in their responses
(their vocabularies, how many responses they give, and the size of the
resulting networks as well as their structure); it does not by itself show a
difference in semantic structure. diagnostics shows how the networks'
sizes vary across permutations.
The permutation null answers a different question than a bootstrap
interval, so their spreads need not agree: a permutation pools both groups'
participants and re-deals them, so the permuted networks' node and edge counts
(which ASPL and CC depend on) vary, whereas a case bootstrap
(bootstrap_SemNeT) resamples within each group. Use
diagnostics to see how the network sizes vary.
The three two-sided definitions agree when the null is centred on 0 and
symmetric, which is the case when the two groups have (about) the same size.
With unequal group sizes the permutation null is generally not centred on 0,
because the measures (e.g., ASPL, CC) depend on a network's size. All three
are valid tests of the same null (the participants' group labels are
exchangeable) because the observed difference is one of the permutations.
"two_tailed" also counts the size-induced offset as evidence;
"two_tailed_centered" measures how far the observed difference is
from what the group sizes alone produce, assuming the null is roughly
symmetric about its mean; "two_tailed_doubled" makes no symmetry
assumption. The one-sided tests are unaffected by centring.
When several measures are tested, each is tested against its own null:
the p-values are not adjusted for the number of
measures.
Returns a list containing:
result |
A data frame with one row per |
networks |
A list of |
method |
The |
seed |
The |
differences |
The measure difference for every permutation: a vector for
one |
diagnostics |
A data frame with a row per permutation containing each
sample's measure value ( |
alpha |
The |
Alexander Christensen <[email protected]>
bootstrap_test_SemNeT for bootstrap tests of group differences
# Get openness data -- equating (see `equate()`) requires named responses low <- open.clean[which(open.group == "Low"), ] high <- open.clean[which(open.group == "High"), ] # Perform permutation test perm_test <- permutation_SemNeT( low, high, method = "tmfg", iter = 100, # increase for more precise results cores = 2, keep_networks = TRUE, seed = 1234 )# Get openness data -- equating (see `equate()`) requires named responses low <- open.clean[which(open.group == "Low"), ] high <- open.clean[which(open.group == "High"), ] # Perform permutation test perm_test <- permutation_SemNeT( low, high, method = "tmfg", iter = 100, # increase for more precise results cores = 2, keep_networks = TRUE, seed = 1234 )
Estimates a semantic network from verbal fluency data by applying the MST-Pathfinder Network algorithm (Quirin et al., 2008; see also Schvaneveldt, 1990) to a distance between responses
PF( data, method = c("chebyshev", "euclidean", "manhattan", "cosine", "hamming", "jaccard", "paulsen"), q = NULL, r = Inf ) pf( data, method = c("chebyshev", "euclidean", "manhattan", "cosine", "hamming", "jaccard", "paulsen"), q = NULL, r = Inf )PF( data, method = c("chebyshev", "euclidean", "manhattan", "cosine", "hamming", "jaccard", "paulsen"), q = NULL, r = Inf ) pf( data, method = c("chebyshev", "euclidean", "manhattan", "cosine", "hamming", "jaccard", "paulsen"), q = NULL, r = Inf )
data |
Matrix or data frame.
A preprocessed verbal fluency matrix where rows are participants. Content
may be the raw word responses (columns are the order of the responses), an
ordered numeric response matrix (see |
method |
Character (length = 1).
Distance between responses that the Pathfinder algorithm prunes.
Defaults to
|
q |
Numeric (length = 1).
Maximum number of links in the indirect paths that can remove a link (the
Pathfinder |
r |
Numeric (length = 1).
Minkowski metric used to combine the distances along a path into the path's
length (the Pathfinder Suggested
|
The distance is a modeling choice. The MST-Pathfinder algorithm (Quirin et al., 2008) is fully specified once a distance is given, but it does not say which distance to use, and no distance is established as the correct one for semantic networks. Different distances can give noticeably different networks from the same data, so the choice should be justified by the research question, should be reported, and, when conclusions depend on it, should be checked against another distance.
The co-occurrence profile of a response is its row of the
co-occurrence matrix (the number of participants who gave both it and each
other response, with the diagonal set to zero). "chebyshev",
"euclidean", "manhattan", "cosine", and
"hamming" (called "dominance", "Euclidean", "city block", "cosine",
and "Hamming" in the Pathfinder software of Schvaneveldt, pfnets.net) compare two
responses by how similar those profiles are, so two responses are close when
they co-occur with the same other responses (not necessarily with each
other). These distances use only whether a response was given, not where.
Responses given by a participant who gave nothing else have an empty profile
and, for "cosine", an undefined distance, which is treated as
infinite (see below).
"jaccard" compares the sets of participants directly: the distance is
1 - a / (a + b + c), where a is the number of participants who
gave both responses and b and c are the numbers who gave only
one. It also ignores order.
"paulsen" follows Paulsen et al. (1996):
where is the number of positions between the two responses in
participant 's list, is that participant's number of
responses (the largest position in their row), is the number of participants who gave both
responses, and is the number of participants. Responses that are
close together in many participants' lists, relative to how many responses
they gave, are close. The positions are
those of responses2binary's $order (a response a
participant repeats is positioned at its last occurrence).
A pair that no participant gave together has an infinite distance for
"paulsen" and "jaccard" (and an undefined cosine distance is
set to infinite), so it can only be linked through other responses.
Responses nobody gave are not nodes.
The network keeps a link between two responses only if no indirect path of
up to q links between them is shorter than the direct distance, where
path lengths are combined with the Minkowski metric r (a
PFnet(, ); Schvaneveldt, 1990). With the defaults
( and ) this is computed with the
MST-Pathfinder algorithm (Quirin et al., 2008): the union of all minimum
spanning trees of the distance matrix. Pairs at exactly the same distance
are all kept when none is bridged by shorter links, and identical responses
(distance zero) are linked. When some responses have no finite distance to the others the
network is not connected (responses with no finite distance to any other are
isolated nodes).
An adjacency matrix. The distances () of the retained
links are attached as the "weighted" attribute (0 where there
is no link, so a link at a distance of exactly zero also shows 0)
Alexander Christensen <[email protected]>
Paulsen, J. S., Romero, R., Chan, A., Davis, A. V., Heaton, R. K., & Jeste, D. V. (1996). Impairment of the semantic network in schizophrenia. Psychiatry Research, 63, 109-121.
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.clean[1:100, ] # Estimate network (default distance: Chebyshev) pf_net <- pf(data) # Estimate network with the response-order distance of Paulsen et al. pf_paulsen <- pf(data, method = "paulsen") # Estimate a denser network (paths of up to 2 links, Euclidean path lengths) pf_dense <- pf(data, method = "euclidean", q = 2, r = 2)# Obtain data data <- open.clean[1:100, ] # Estimate network (default distance: Chebyshev) pf_net <- pf(data) # Estimate network with the response-order distance of Paulsen et al. pf_paulsen <- pf(data, method = "paulsen") # Estimate a denser network (paths of up to 2 links, Euclidean path lengths) pf_dense <- pf(data, method = "euclidean", q = 2, r = 2)
bootSemNeT (Legacy)Backward-compatible wrapper for
plot.bootstrap_SemNeT – dispatches for objects returned by
the legacy bootSemNeT, which carry the old class alongside
the new one
## 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"))
... |
An object from |
groups |
Character.
Labels for groups in the order they were entered into
|
measures |
Character.
One or more of |
Alexander Christensen <[email protected]>
bootstrap_SemNeT
Plots each measure's bootstrap distribution as a raincloud plot (Allen et al., 2018): a half violin, boxplot, and the jittered bootstrap values, with one panel per measure and the groups side by side. A bootstrap confidence interval of each group's value is drawn below its boxplot
## S3 method for class 'bootstrap_SemNeT' plot( x, measures = c("aspl", "cc", "q"), ci = TRUE, ci_level = 0.95, ci_type = c("normal", "bc", "percentile"), ... )## S3 method for class 'bootstrap_SemNeT' plot( x, measures = c("aspl", "cc", "q"), ci = TRUE, ci_level = 0.95, ci_type = c("normal", "bc", "percentile"), ... )
x |
A |
measures |
Character.
One or more of |
ci |
Boolean (length = 1).
Whether to draw each group's confidence interval below its boxplot.
Defaults to |
ci_level |
Numeric (length = 1).
Confidence level between 0 and 1 (exclusive).
Defaults to |
ci_type |
Character (length = 1).
Type of interval, as in
|
... |
Not used |
Returns a ggplot object (printed at the console and
compatible with shiny::renderPlot())
Alexander Christensen <[email protected]>
Raincloud plots
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
# 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)# 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)
permutation_SemNeT
Plots each measure's permutation null distribution as a raincloud plot (Allen et al., 2018): a half violin, boxplot, and the jittered permuted differences (the first sample minus the second), with one panel per measure. The observed difference is marked and the central range of the null distribution is drawn below the boxplot, so an observed difference outside that range corresponds to a small p-value
## S3 method for class 'permutation_SemNeT' plot(x, measures = NULL, null_range = TRUE, level = 0.95, ...)## S3 method for class 'permutation_SemNeT' plot(x, measures = NULL, null_range = TRUE, level = 0.95, ...)
x |
A |
measures |
Character.
One or more of the measures tested in |
null_range |
Boolean (length = 1).
Whether to draw the central range of the null distribution below its
boxplot.
Defaults to |
level |
Numeric (length = 1).
Proportion of the permuted differences inside the null range, between 0 and
1 (exclusive); the range is bounded by the |
... |
Not used |
The null range is not a confidence interval: it describes the
differences expected when group membership does not matter, not the
precision of an estimate (see plot.bootstrap_SemNeT for that).
The permuted differences include the observed one (the first permutation).
The p-value in each panel's title is the one stored in x, so it
follows the alternative used in permutation_SemNeT
(the range and violin are not adjusted for it).
Returns a ggplot object (printed at the console and
compatible with shiny::renderPlot())
Alexander Christensen <[email protected]>
Raincloud plots
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
# Get openness data low <- open.clean[which(open.group == "Low"), ] high <- open.clean[which(open.group == "High"), ] # Perform permutation test perm_test <- permutation_SemNeT( low, high, method = "tmfg", measure = c("aspl", "cc", "q"), iter = 100, cores = 2, seed = 1234 ) # Plot plot(perm_test)# Get openness data low <- open.clean[which(open.group == "Low"), ] high <- open.clean[which(open.group == "High"), ] # Perform permutation test perm_test <- permutation_SemNeT( low, high, method = "tmfg", measure = c("aspl", "cc", "q"), iter = 100, cores = 2, seed = 1234 ) # Plot plot(perm_test)
Computes a global modularity measure (Q) using the Louvain community detection algorithm
Q(A) q(A, resolution = 1, seed = NULL, signed = FALSE)Q(A) q(A, resolution = 1, seed = NULL, signed = FALSE)
A |
Matrix or data frame. An adjacency matrix of network data. Must be symmetric |
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 |
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.
A given nonzero seed always gives the same partition; seed = 0
(like NULL) seeds from the clock.
With signed = TRUE, the partition (found on the absolute-value
network) is scored as
(Gomez et al., 2009), where and are the total positive
and absolute negative weights and and are the modularity
of the positive and of the absolute negative edges.
Returns Q, a measure of how well the network partitions into
distinct, densely-connected communities. A network without edges has no
defined modularity (NaN)
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.
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.
# 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)# 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)
Backward-compatible wrapper for
random_network_test – randnet.test() was renamed
random_network_test() in SemNeT 2.0.0.
Output changed: the p-values are now Monte Carlo
p-values, computed for Erdos-Renyi and degree-preserving random
networks (p_value, p_value_degree, ...), and a network's edge
count is the number of nonzero cells (weights are no longer summed); see
random_network_test
randnet.test(..., iter, cores)randnet.test(..., iter, cores)
... |
Matrices or data frames.
Networks to test, e.g. |
iter |
Numeric.
See |
cores |
Numeric.
See |
Alexander Christensen <[email protected]>
Tests global measures of semantic networks against the distribution of the same measures in random networks of equivalent size and density (Erdos-Renyi) and in random networks that also keep every node's degree
random_network_test( ..., iter = 1000, cores = 1, type = c("arithmetic", "harmonic"), cc_type = c("average", "global"), seed = NULL )random_network_test( ..., iter = 1000, cores = 1, type = c("arithmetic", "harmonic"), cc_type = c("average", "global"), seed = NULL )
... |
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 |
type |
Character (length = 1).
Type of |
cc_type |
Character (length = 1).
Type of |
seed |
Numeric.
A seed for reproducible results (including the community detection behind
|
Every network is binarized (any nonzero edge becomes 1) before its measures are computed, and its edge count is the number of nonzero off-diagonal entries (a weighted network's weights are not summed).
Two null models are used, because they answer different questions. An
Erdos-Renyi network has the observed node and edge counts but otherwise random
edges, so any structure (including the degree distribution that nearly every
semantic network has) distinguishes the observed network from it. A
degree-preserving network is the observed network after many random edge
swaps (rewire), so it keeps every node's degree and
asks whether the measure differs beyond what the degrees imply.
p-values are Monte Carlo p-values, with no normality
assumption: ,
where are the iter random-network values and
their mean. They cannot be smaller than 1 / (iter + 1) (and are
reported to 4 significant digits, so that they are not rounded to 0). Neither null
model guarantees a connected network, and aspl ignores unreachable
pairs (with type = "arithmetic"), so a sparse random network can differ
from a connected observed one for that reason alone; use
type = "harmonic" to avoid this. Random networks whose measure is
undefined (NaN) are left out of that measure's mean, standard
deviation, and p-value, with a warning. The tests are not adjusted for
the number of measures.
Returns a named list (one entry per input network) of data frames
with, for each of aspl, cc, and q, the Monte Carlo
p-value and the mean and standard deviation of the random-network
distribution: p_value, random_mean, and random_sd for
Erdos-Renyi networks, and p_value_degree, random_mean_degree,
and random_sd_degree for degree-preserving networks
Alexander Christensen <[email protected]>
Erdos, P., & Renyi, A. (1960). On the evolution of random graphs. Publications of the Mathematical Institute of the Hungarian Academy of Sciences, 5, 17-61.
Maslov, S., & Sneppen, K. (2002). Specificity and stability in topology of protein networks. Science, 296, 910-913.
# 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, cores = 2, iter = 100 # increase for more precise results )# 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, cores = 2, iter = 100 # increase for more precise results )
Simulates random walks over two networks to examine the characteristics of spontaneous spreading activation (see Kenett & Austerweil, 2016)
random_walk( A, B, name_a = "A", name_b = "B", reps = 20, steps = 10, iter = 10000, cores = 1 )random_walk( A, B, name_a = "A", name_b = "B", reps = 20, steps = 10, iter = 10000, cores = 1 )
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.
Sets the largest number of steps tested, |
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 |
The comparison is descriptive. Each network's walks are
iter simulated draws, and iter is chosen by the user, so the
p-value of a test on those draws would only reflect how many walks
were simulated: any difference, however small, becomes “significant”
with enough of them. No p-values are reported. Each statistic
(number of unique nodes visited, similarity between the start and the last
newly visited node of the walk, and the same at the 5th unique node) is
instead summarized by
the difference in means (A minus B) with a Monte Carlo
95% interval, which describes the error from simulating a finite number
of walks (and shrinks as iter grows), not uncertainty about the
networks
Cohen's d, which does not depend on iter
Neither accounts for the uncertainty in the estimated networks; use
bootstrap_SemNeT for that. The number of unique nodes visited
depends mechanically on a network's size and density, so networks of
different sizes (e.g., unequated networks) differ on it partly for that
reason alone.
Every walk starts at a node drawn at random from the nodes with at least one
connection in each network (an isolated node cannot be walked from), and the
two networks' walks share each step's random draw. When the pooled standard
deviation of a statistic is 0, is 0 for no difference in
means and Inf (signed) for a difference, since any difference is then
infinitely large in standard deviation units. The 5-unique-node statistic is
measured at each network's own 5th distinct node (or its last, if the walk
visited fewer).
A list with long (every simulated summary statistic, all
numeric: each network's mean and standard deviation, and the difference,
its Monte Carlo interval limits, and Cohen's d for each statistic)
and short (a compact, correctly-typed summary with the difference,
Cohen's d, and a direction that is the network with the larger mean
when (Cohen's small effect) and "negligible"
otherwise)
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 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)# 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)
Backward-compatible wrapper for random_walk –
randwalk() was renamed random_walk() in SemNeT 2.0.0.
Output changed: the Wilcoxon p-values are gone (they only
reflected how many walks were simulated) and $short is a data frame
of differences, Cohen's d, and directions; see
random_walk
randwalk(A, B, reps = 20, steps = 10, iter = 10000, cores)randwalk(A, B, reps = 20, steps = 10, iter = 10000, cores)
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 |
See random_walk
Alexander Christensen <[email protected]>
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
read_uploaded_file(datapath, filename, header = TRUE, sep = ",")read_uploaded_file(datapath, filename, header = TRUE, sep = ",")
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 |
The file's contents as a data frame (or the single object it
contains, for .rds/.RData)
Alexander Christensen <[email protected]>
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")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")
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
response_analysis(...)response_analysis(...)
... |
Named matrices or data frames.
At least two response matrices (raw word responses or already-binary), one
per group, e.g. |
The number of responses unique to each group (unique) grows
with a group's number of participants, and the responses are not independent
observations, so the McNemar test on those counts should be read as a
description, not as a test of the groups. The vocabulary statistics
compare groups at the same number of participants instead.
McNemar's test only uses the two off-diagonal cells (the numbers of responses
unique to each group), so here it is a continuity-corrected sign test on those
two counts; it is NA when neither group has a unique response.
phi is the correlation between the two groups' indicators of giving
each response across the responses given by either group. Because no response
is given by neither group, it is at most 0 by construction (and reported as an
absolute value), so it describes the overlap of the vocabularies and not an
association between the groups. The t-test is NA when it is
undefined (e.g., every participant gave the same number of responses).
With exactly two groups, a list with:
total |
A named vector comparing the number of distinct responses given
by each participant (a response repeated by a participant counts once) via a
two-sample t-test and Cohen's d (absolute; the sign of the
difference is that of |
unique |
A named vector comparing the number of responses unique to
each group via McNemar's test (and |
vocabulary |
Descriptive statistics for the groups' vocabularies that
account for the groups' sizes, unlike |
With more than two groups, a named list of such lists, one per pair of
groups (named "<group1>_vs_<group2>")
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.
Hurlbert, S. H. (1971). The nonconcept of species diversity: A critique and alternative parameters. Ecology, 52, 577-586.
# Obtain data low <- open.clean[which(open.group == "Low"), ] high <- open.clean[which(open.group == "High"), ] # Perform analysis response_analysis(low = low, high = high)# Obtain data low <- open.clean[which(open.group == "Low"), ] high <- open.clean[which(open.group == "High"), ] # Perform analysis response_analysis(low = low, high = high)
Backward-compatible wrapper for response_analysis
– response.analysis() was renamed response_analysis() in
SemNeT 2.0.0
response.analysis(...)response.analysis(...)
... |
Matrices or data frames.
Response matrices, e.g. |
Alexander Christensen <[email protected]>
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
responses2binary(responses)responses2binary(responses)
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 ( |
A list of class "responses2binary" 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 |
Alexander Christensen <[email protected]>
# Raw fluency responses, 2 participants, up to 3 responses each responses <- matrix( c("dog", "cat", NA, "cat", "wolf", "dog"), nrow = 2, byrow = TRUE ) result <- responses2binary(responses) result$binary result$order# Raw fluency responses, 2 participants, up to 3 responses each responses <- matrix( c("dog", "cat", NA, "cat", "wolf", "dog"), nrow = 2, byrow = TRUE ) result <- responses2binary(responses) result$binary result$order
Computes the average shortest path length (aspl),
clustering coefficient (cc), and modularity (q)
of a network
semantic_network_measures( A, measures = c("aspl", "cc", "q"), weighted = FALSE, seed = NULL, na.rm = FALSE, signed = FALSE, type = c("arithmetic", "harmonic"), cc_type = c("average", "global") )semantic_network_measures( A, measures = c("aspl", "cc", "q"), weighted = FALSE, seed = NULL, na.rm = FALSE, signed = FALSE, type = c("arithmetic", "harmonic"), cc_type = c("average", "global") )
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 |
na.rm |
Boolean.
Passed on to |
signed |
Boolean.
Passed on to |
type |
Character.
Passed on to |
cc_type |
Character.
Passed on to |
Returns a named numeric vector with one value per requested measure
Alexander Christensen <[email protected]>
Gomez, S., Jensen, P., & Arenas, A. (2009). Analysis of community structure in networks of correlated data. Physical Review E, 80, 016114.
# 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)# 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)
Backward-compatible wrapper for
semantic_network_measures – semnetmeas() was renamed
semantic_network_measures() in SemNeT 2.0.0
semnetmeas(A, meas = c("ASPL", "CC", "Q"), weighted = FALSE)semnetmeas(A, meas = c("ASPL", "CC", "Q"), weighted = FALSE)
A |
Matrix or data frame.
See |
meas |
Character.
One or more of |
weighted |
Boolean.
See |
A named numeric vector, named to match meas (uppercase),
as in the original
Alexander Christensen <[email protected]>
SemNeT
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
SemNeTShiny()SemNeTShiny()
Invisibly returns NULL. Launches the app as a side effect;
see the app's own "Export" tab for how to retrieve results
Alexander Christensen <[email protected]>
if(interactive()){ SemNeTShiny() }if(interactive()){ SemNeTShiny() }
Backward-compatible wrapper for simulate_fluency
– sim.fluency() was renamed simulate_fluency() in SemNeT 2.0.0
sim.fluency(nodes, cases, random = FALSE)sim.fluency(nodes, cases, random = FALSE)
nodes |
Numeric.
See |
cases |
Numeric.
See |
random |
Boolean.
See |
See simulate_fluency
Alexander Christensen <[email protected]>
Computes a similarity matrix between the columns of a binarized verbal fluency or linguistic dataset (see Choi, Cha, & Tappert, 2010 for additional measures)
similarity( data, method = c("cosine", "angular", "cor", "euclid", "faith", "jaccard", "phi", "rr") )similarity( data, method = c("cosine", "angular", "cor", "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. One of |
"angular", "faith", "jaccard" and "rr"
are computed from the 2 x 2 table of two columns' agreements and
disagreements across participants, which needs 0/1 data (other values are an
error); missing or infinite values are an error for every measure. A response nobody gave (an all-zero column) makes
"cosine", "angular" and "jaccard" undefined (NaN),
and a response everybody gave (or nobody) makes "cor"/"phi"
undefined; remove such responses first (finalize removes
responses given by too few participants, not responses everybody gave). A
participant who gave no response still counts as a case in which every
response is absent, which matters for the measures that use joint absences
("cor", "phi", "faith", "rr"). "euclid"
mostly reflects how often each response was given: two rare responses that
never co-occur look similar.
A symmetric similarity matrix. The diagonal is set to 1
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 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 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")
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 (plus 1) over 1.05
times the largest such total. The probability therefore does not depend on
the number of participants, and every response is simulated independently of
the others: the data contain no association between responses, so a network
estimated from them (which still has its full complement of edges, e.g.
tmfg) describes noise. Use them to try out functions, not as a
model of semantic structure
simulate_fluency(nodes = 100, cases = 500, random = FALSE)simulate_fluency(nodes = 100, cases = 500, random = FALSE)
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
|
A binary matrix with cases rows (participants) and
nodes columns (responses)
Alexander Christensen <[email protected]>
# Simulate data for 50 nodes and 200 participants simulate_fluency(nodes = 50, cases = 200)# Simulate data for 50 nodes and 200 participants simulate_fluency(nodes = 50, cases = 200)
bootSemNeT (Legacy)Backward-compatible wrapper for
bootstrap_test_SemNeT – test.bootSemNeT() was
renamed bootstrap_test_SemNeT() in SemNeT 2.0.0.
Legacy warning: before SemNeT 2.1.0, this function ran
t-tests/ANOVAs/ANCOVAs on the bootstrap replicates themselves, which
is statistically invalid (the replicates are not independent observations,
and the bootstrap standard deviation – already a standard error – was
divided by sqrt(iter), inflating test statistics by roughly
sqrt(iter)). It now always warns and returns the results of
bootstrap_test_SemNeT(): by default a Wald test of each contrast
using the bootstrap standard error (with normal intervals), or percentile
intervals, which have no p-value.
Results from earlier versions should be recomputed. Only accepts
objects produced by this package's own bootSemNeT /
bootstrap_SemNeT, not a raw object saved from SemNeT
< 2.0.0
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 )
... |
One or more |
test |
Character.
|
measures |
Character.
One or more of |
formula |
Character.
See |
groups |
Matrix or data frame.
See |
Alexander Christensen <[email protected]>
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 strength (the sum of their absolute associations that exceed the matrix's average absolute association, diagonal included), then iteratively adds each remaining node to the connected set of three nodes (a triangle) it is most strongly associated with, until every node is included. Edges are chosen on absolute association (a strong negative association is a strong edge); the signed values are kept in the returned network.
TMFG(data, depend = FALSE) tmfg(data)TMFG(data, depend = FALSE) tmfg(data)
data |
Matrix or data frame. A square, symmetric association matrix (e.g. a correlation or similarity matrix) |
depend |
Ignored (with a warning) and kept only so that earlier calls
of the legacy |
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.
Returns a 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 fluency_data <- matrix(sample(0:1, 1000, replace = TRUE), nrow = 100, ncol = 10) A <- suppressWarnings(tmfg(similarity(fluency_data, method = "cor")))# 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")))
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")