net_prune() removes weak or non-significant edges from a network and
returns the pruned network with a record of what it removed, so the
pruning can be undone and re-applied. It is Nestimate's counterpart of
tna::prune(); the net_ prefix avoids a name clash with it. It takes a
netobject or a netobject_group, whose networks are pruned one by one
with the same settings, and offers four methods (see Methods).
Pruning is non-destructive: the network carries a "pruning" attribute
with the original weights, the pruned weights, the settings used and a
table of the removed edges. net_deprune() restores the original weights
and net_reprune() re-applies the pruning, both without recomputing
anything; net_pruning_details() lists what was removed.
"threshold" and "lowest" remove small weights; they do not show that
those edges are absent, and the cut-off is the analyst's choice.
"disparity" and "bootstrap" keep an edge on a statistical criterion.
Before reading a pruned network, see which edges went with
net_pruning_details() and whether the conclusions hold at another
cut-off; bootstrap_network() gives the uncertainty of each edge.
Usage
net_prune(
x,
method = "threshold",
threshold = 0.1,
lowest = 0.05,
level = 0.5,
boot = NULL,
...
)
# S3 method for class 'netobject'
net_prune(
x,
method = "threshold",
threshold = 0.1,
lowest = 0.05,
level = 0.5,
boot = NULL,
...
)
# S3 method for class 'netobject_group'
net_prune(
x,
method = "threshold",
threshold = 0.1,
lowest = 0.05,
level = 0.5,
boot = NULL,
...
)
# Default S3 method
net_prune(
x,
method = "threshold",
threshold = 0.1,
lowest = 0.05,
level = 0.5,
boot = NULL,
...
)Arguments
- x
The network: a
netobjector anetobject_group. Another class raises an error. A network whose pruning is active raises an error of classnestimate_bad_input; afternet_deprune()it can be pruned again with other settings, which replaces its pruning record.- method
The pruning method:
"threshold"(default),"lowest","disparity"or"bootstrap"(see Methods).- threshold
For
method = "threshold": the largest weight that is removed. Default0.1. Ignored by the other methods, but must still be a single number.- lowest
For
method = "lowest": the quantile, between 0 and 1, of the positive weights that sets the cut-off. Default0.05. Ignored by the other methods, but checked whatever the method: a value outside[0, 1]raises an error.- level
For
method = "disparity": the significance level, between 0 and 1; an edge is kept when its p-value is below it. Default0.5. Ignored by the other methods, but checked whatever the method: a value outside[0, 1]raises an error.- boot
For
method = "bootstrap": anet_bootstrapfrombootstrap_network()of this network. With the defaultNULL, the bootstrap is run here onx. For anetobject_group, pass thenet_bootstrap_groupofbootstrap_network()on the group, matched to the networks by name, orNULLto bootstrap each network on its own. Another object, a bootstrap of another network (its weights differ), a singlenet_bootstrapfor a group, or a group bootstrap missing one of the networks raises an error of classnestimate_bad_input.- ...
For
method = "bootstrap"withboot = NULL: arguments passed tobootstrap_network(), such asiter. Ignored otherwise.
Value
The input, of the same class, with the pruned weights, its edge
table and edge count updated to them, and the "pruning" attribute
described above. net_pruning_details() reads the record,
net_deprune() and net_reprune() switch between the original and
the pruned weights. For a netobject_group, each network is pruned
and carries its own record.
Methods
"threshold"Removes positive edges with weight at most
threshold."lowest"Removes positive edges with weight at most the
lowestquantile of the positive weights (self-loops included in the quantile; each pair counted once on an undirected network)."disparity"Keeps the backbone found by the disparity filter of Serrano, Boguna & Vespignani (2009): an edge stays when, at its source's outgoing or its target's incoming edges, its share of the strength is significant at
levelagainst a uniform split of that strength; the filter is defined for non-negative weights."bootstrap"Removes the edges that
bootstrap_network()finds non-significant: pass a computed result asboot, or bootstrap arguments through....
For "threshold" and "lowest", the candidate edges are visited one at
a time, column by column and down each column, and each is removed
only when the network
stays weakly connected without it, so a network that is not weakly
connected to begin with loses no edge to these two methods.
"disparity" and "bootstrap" apply no connectivity check. Negative
edges are never candidates for "threshold" and "lowest", whatever
their size. On a signed network, "disparity" treats negative edges as
not significant and removes them at the default level; at a level
above 0.5, a negative edge leaving a state with no positive outgoing edge
(or entering one with no positive incoming edge) can stay. "bootstrap"
removes the non-significant edges of either sign.
On an undirected network an edge is a pair of cells: it is removed in both directions or kept in both, so the pruned matrix stays symmetric, and the record lists and counts it once.
Self-loops (the diagonal) are observed data: they count towards the
"lowest" quantile but are never removed by any method. This is a
deliberate difference from tna::prune(), which prunes self-loops like
any other edge.
References
Serrano, M. A., Boguna, M., & Vespignani, A. (2009). Extracting the multiscale backbone of complex weighted networks. Proceedings of the National Academy of Sciences, 106(16), 6483–6488. doi:10.1073/pnas.0808904106
Examples
seqs <- data.frame(
V1 = c("A","B","A","C","B"), V2 = c("B","C","B","A","C"),
V3 = c("C","A","C","B","A"))
net <- build_network(seqs, method = "relative")
pruned <- net_prune(net, method = "threshold", threshold = 0.2)
net_pruning_details(pruned)
#> Pruning details
#> Method: user-specified threshold (0.2)
#> Removed: 0 edges
#> Retained: 3 edges
#>
#> (no edges removed)