These functions reduce or combine the layers of a network, or the other tie columns that divide its ties: the reports of its reporters, the gossip about each target, and its moments.
to_layer() reduces a multiplex network to one of its layers.
Use to_layers() to split a network into all of its layers at once.
to_aggregated() combines the ties of a network that differ only in
one tie column, dyad by dyad, according to a rule:
its layers, the reports of its reporters, the gossip about each target,
or its moments. It can also combine parallel ties.
Where to_layer() selects one layer and discards the rest,
to_aggregated() retains what every layer records.
to_firsthand() keeps, for each dyad of a cognitive social structure,
only the reports of the two nodes in it.
to_consensus() keeps the ties of a cognitive social structure that at
least a share of its reporters report.
to_disaggregated() turns tie weights back into that many parallel
ties, reversing to_aggregated(over = NULL, rule = "sum").
If the format condition is not met,
for example to_layer() is used on a network that holds no layers,
the network data is returned unaltered.
Unlike the as_*() group of functions,
these functions always return the same class as they are given,
only transforming these objects' properties.
An object of a {manynet}-consistent class:
adjacency or incidence matrix from {base} R
edgelist data.frame from {base} R or tbl/tbl_df from {tibble}
stocnet stocnet, from the {manynet} package
igraph igraph, from the {igraph} package
network network, from the {network} package
tidygraph tbl_graph, from the {tidygraph} package
How the networks' tie values are reconciled into a single value per dyad. A dyad tied in only one of the networks counts as untied in the others, which is what makes rules such as "min" and "product" meaningful.
"max" (the default) takes the largest of the values, so that a tie in any of the networks is a tie in the result. This is the union of the networks.
"min" takes the smallest, so that only ties present in all of them survive. This is their intersection.
"mean" averages the values, treating the networks as several readings of one underlying relationship.
"sum" adds them, so that ties reinforce one another.
"product" multiplies them, so that a tie survives only where every network records one, and strong ties are rewarded disproportionately.
Missing values propagate rather than being ignored, so that a dyad
unobserved in any of the networks is unobserved in the result.
Use impute_ties() first to state a different assumption.
The share of the reporters that must report a tie for the
consensus to hold it, above 0 and at most 1.
By default 0.5, so that a tie is held where at least half of the
reporters report it, and 1 holds only the ties that all of them report.
Character string naming one of the layers, or tie types,
in the network, i.e. one of those returned by layer_names(),
to which the network should be reduced.
Where a network holds no tie types, it is already uniplex
and is returned unchanged.
Deprecated name for layer, retained for one version.
The tie column over which ties are combined, one of
the columns that as_stocnet() takes from the third dimension of an
array:
"layer" (the default) combines the layers of a multiplex network,
"by" combines the reports of the reporters in a cognitive social structure,
"about" combines the gossip about each target,
"time" combines the moments of a longitudinal network.
NULL combines only parallel ties, the ties that tie_is_parallel()
marks. to_disaggregated() reverses this where rule = "sum".
Each tie counts by its weight, or by its sign where it has no weight, and otherwise as 1. Signed values can cancel one another out, and a combined value of zero is no tie.
Which reports are combined where over = "by":
"all" (the default) combines the reports of every reporter.
"sender" takes, for the tie from i to j, the report of i.
"receiver" takes, for the tie from i to j, the report of j.
"both" combines the reports of i and j by the rule.
With rule = "min" this is the intersection locally aggregated structure
of Krackhardt (1987), and with rule = "max" it is the union one.
An object of the same class as the function was given, modified as explained in the function description, details, or section. Functions that split a network return a list of such objects.
Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:
to_firsthand() keeps, for each dyad of a cognitive social structure,
only the reports of the two nodes in it.
These reports are firsthand: each node reports a tie it is part of,
where its report about the ties of others is secondhand.
This is the locally aggregated structure of Krackhardt (1987):
a tie from i to j where both i and j report it
(rule = "min", the intersection), or where either of them does
(rule = "max", the union).
It is to_aggregated(over = "by", reporters = "both") by another name.
to_consensus() gives the consensus structure of Krackhardt (1987):
a tie from i to j where at least the threshold share of the reporters
report it.
Where to_firsthand() asks only i and j, this asks every reporter, so a
tie can be held that its own two nodes do not report.
A reporter that did not report is left out of the share,
as to_aggregated() leaves it out.
It is to_aggregated(over = "by", rule = "mean") followed by
to_unweighted(threshold = threshold).
Over reporters, "max" gives a tie where any reporter reports one,
"min" where all of them do, "mean" the share of the reporters that do,
and "sum" how many of them do.
A consensus structure is therefore
to_aggregated(.data, over = "by", rule = "mean") followed by
to_unweighted(threshold = 0.5), which to_consensus() does.
A reporter that did not report is left out of the reports that are
combined, rather than making every tie missing, and a tie is missing
only where none of the reporters it is pooled over reported it.
Egocentric data has no roster that all the egos report on,
so its reports cannot be combined.
to_disaggregated() turns each tie of weight w into w parallel ties,
and so reverses to_aggregated(over = NULL, rule = "sum").
No other aggregation can be reversed, since the values it combined are
not kept; to_layers(), to_reporters(), and to_times() split a
network into its parts without losing them.
The weights must be whole numbers.
A negative weight becomes that many negative ties, held as weights of -1,
which is how a signed network holds its signs.
A matrix cannot hold parallel ties, so it is returned as it is.
Krackhardt, David. 1987. "Cognitive social structures". Social Networks, 9(2): 109-134. doi:10.1016/0378-8733(87)90009-8
css <- as_stocnet(array(rbinom(27, 1, 0.5), c(3, 3, 3)), over = "by")
to_firsthand(css)
#> # A directed network of 3 nodes and 1 arcs
#> # Transformed by aggregation: locally aggregated reports (min)
#>
#> ── Ties
#> # A tibble: 1 × 2
#> from to
#> <int> <int>
#> 1 2 3
#>
to_consensus(css)
#> # A complex, directed network of 3 nodes and 6 arcs
#> # Transformed by aggregation: reporters and dichotomisation: threshold 0.5
#>
#> ── Ties
#> # A tibble: 6 × 2
#> from to
#> <int> <int>
#> 1 2 1
#> 2 3 1
#> 3 3 2
#> 4 2 3
#> 5 3 3
#> 6 1 3
#>
to_consensus(css, threshold = 1)
#> # A directed network of 3 nodes and 1 arcs
#> # Transformed by aggregation: reporters and dichotomisation: threshold 1
#>
#> ── Ties
#> # A tibble: 1 × 2
#> from to
#> <int> <int>
#> 1 2 3
#>
as_tidygraph(create_filled(5)) |>
mutate_ties(type = sample(c("friend", "enemy"), 10, replace = TRUE)) |>
to_layer("friend")
#> # A tbl_graph: 5 nodes and 5 edges
#> #
#> # An undirected simple graph with 1 component
#> #
#> # Node Data: 5 × 0 (active)
#> #
#> # Edge Data: 5 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 5
#> 3 2 4
#> # ℹ 2 more rows
to_aggregated(ison_florentine, rule = "sum")
#> # A labelled, weighted, undirected network of 16 nodes and 27 ties
#> # Transformed by aggregation: layers (sum)
#>
#> ── Nodes
#> # A tibble: 16 × 4
#> label wealth priorates totalties
#> <chr> <int> <int> <int>
#> 1 Acciaiuoli 10 53 2
#> 2 Albizzi 36 65 3
#> 3 Barbadori 55 0 14
#> 4 Bischeri 44 12 9
#> 5 Castellani 20 22 18
#> 6 Ginori 32 0 9
#> # ℹ 10 more rows
#>
#> ── Ties
#> # A tibble: 27 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 1 9 1
#> 2 2 6 1
#> 3 2 7 1
#> 4 2 9 1
#> 5 3 5 2
#> 6 3 6 1
#> # ℹ 21 more rows
#>
to_disaggregated(to_aggregated(ison_koenigsberg, over = NULL, rule = "sum"))
#> ── # Seven Bridges of Koenigsberg ──────────────────────────────────────────────
#> # A labelled, undirected network of 4 landmasses and 7 bridge ties (4 parallel)
#> # Transformed by aggregation and disaggregation
#>
#> ── Nodes
#> # A tibble: 4 × 3
#> label lat lon
#> <chr> <dbl> <dbl>
#> 1 Altstadt 54.7 20.5
#> 2 Kneiphof 54.7 20.5
#> 3 Lomse 54.7 20.5
#> 4 Vorstadt 54.7 20.5
#>
#> ── Ties
#> # A tibble: 7 × 2
#> from to
#> <int> <int>
#> 1 1 2
#> 2 1 2
#> 3 1 3
#> 4 2 3
#> 5 2 4
#> 6 2 4
#> # ℹ 1 more row
#>