View source: R/wrangle-weights.R
| threshold_edges | R Documentation |
Keeps the edges that satisfy every criterion supplied. This is the network
equivalent of qgraph's minimum/cut arguments and of
tna::prune(), except that it returns a network rather than a plot
setting, so the thresholded network can be analysed, not only drawn.
threshold_edges(
x,
minimum = NULL,
maximum = NULL,
proportion = NULL,
density = NULL,
top = NULL,
absolute = TRUE,
keep_isolates = TRUE,
keep_format = FALSE,
directed = NULL
)
x |
Network input: cograph_network, matrix, igraph, network, tna, or an edge-list data frame. |
minimum |
Numeric. Keep edges whose weight is at least this value. |
maximum |
Numeric. Keep edges whose weight is at most this value. |
proportion |
Numeric in (0, 1]. Keep this fraction of the edges, the strongest first. |
density |
Numeric in (0, 1]. Keep as many of the strongest edges as gives this density (edges as a fraction of the possible edges). |
top |
Integer. Keep this many edges, the strongest first. |
absolute |
Logical. Compare |
keep_isolates |
Logical. Keep nodes that end up with no edges? Default
TRUE. Set FALSE, or call |
keep_format |
Logical. Return the input format when TRUE. |
directed |
Logical or NULL. If NULL (default), auto-detect. |
When several criteria are given they are combined with AND: for example
threshold_edges(x, minimum = 0.2, top = 20) keeps the twenty
strongest edges among those of weight at least 0.2.
Ties at the cut point are all kept, so top = 10 can return more than
ten edges when the tenth and eleventh weights are equal. This is deliberate:
breaking ties on edge order would make the result depend on how the network
was built.
A cograph_network with the surviving edges, or the input
format when keep_format = TRUE. Every node is kept unless
keep_isolates = FALSE; nodes the threshold stranded are reported in
a cograph_isolates_created warning. An out-of-range
minimum, maximum, proportion, density or
top raises a cograph_bad_selection error.
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(4), 1–18.
binarize, filter_edges,
disparity_filter, remove_isolates
adj <- matrix(c(0, .5, .8, 0,
.5, 0, .3, .6,
.8, .3, 0, .4,
0, .6, .4, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")
threshold_edges(adj, minimum = 0.5)
threshold_edges(adj, top = 2)
threshold_edges(adj, density = 0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.