These functions construct a square, node-by-node matrix of how alike the nodes of a one-mode network are:

  • to_proximity() compares each pair of nodes on their ties, using any of the measures that to_mode1() offers. Given a two-mode network, or a node-by-feature profile matrix such as a motif census, it compares the rows or the columns as they lie.

  • to_correlation() performs a Pearson pairwise correlation, choosing how to treat the diagonal and the reciprocal ties from the network's format.

  • to_cosine() takes the cosine of the angle between the columns of a matrix.

Where to_mode1() compares nodes on their affiliations to a second mode, these functions compare nodes on their ties to one another. The two share one measure vocabulary and differ only in the profile compared. For a two-mode network there is no difference, and to_proximity() returns what to_mode1() or to_mode2() would.

to_proximity(
  .data,
  similarity = c(.proj_measures, .proj_rules),
  across = c("rows", "columns", "both"),
  dyad = NULL
)

to_correlation(.data, method = NULL)

to_cosine(.data)

Arguments

.data

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

similarity

How to measure how alike two nodes are. The default is "count". Each measure compares the ties of two nodes to the other mode.

The measures are in groups below. The measures in one group put the pairs of nodes in the same order, and differ only in their scale. So the choice of group is more important than the choice in a group.

Measures for valued and binary data:

  • "count" counts the shared ties, as \(XX'\). For valued data, it adds the products of the tie weights, and a repeated tie counts as many times as it is repeated. For signed data, it adds the products of their absolute values, since the signed rules below read the signs. It is the default, and the fastest.

  • "match" counts the nodes of the other mode where the two nodes have the same value. This includes the nodes that neither of them has a tie to. For binary data, it is "rand" times the number of nodes in the other mode. Use it when the level of each tie is important.

  • "crossmin" adds the smaller of the two weights for each shared node. It shows what two nodes can give together. For binary data, it is the same as "count".

  • "overlap" divides "crossmin" by the smaller of the two nodes' totals. This is the Szymkiewicz-Simpson coefficient. For data with no negative values, it is from 0 to 1. Use it when one node is much more active than the other. For valued data, xUCINET divides the count and not "crossmin", so its values can be more than 1.

  • "ruzicka" divides "crossmin" by the sum of the two nodes' totals minus "crossmin". This is Ruzicka's weighted Jaccard coefficient, from 0 to 1. For binary data, it is the same as "jaccard". Use it when you want "jaccard" but must keep the tie weights.

  • "maxcrossmin" takes the largest of these smaller weights, not their sum. So one strong shared tie is enough. For binary data, it only shows if two nodes share any tie.

  • "sqdiff" adds the squared differences of the weights, as \(d\). It gives \(1/(1+d)\), so that a larger value means more alike. Two nodes with the same ties get 1. To get \(d\) back, calculate \(1/x - 1\).

  • "pearson" is the correlation of the two nodes' ties. "covariance" is the same, but not standardised. Use "covariance" when the variance of the ties is important.

  • "spearman" and "kendall" are rank correlations. Use them when the order of the weights is reliable, but the spacing is not. An example is ordinal ratings.

  • "cosine" is the cosine of the angle between the two nodes' ties. It is like "pearson", but it does not centre the ties first. So two nodes are alike when their ties are proportional. For binary data, it is the same as "ochiai". For a node with no ties, "cosine" gives 0, but "ochiai" divides by zero.

  • "euclidean" and "manhattan" use the distance \(d\) between the two nodes' ties, and give \(1/(1+d)\), as "sqdiff" does. "manhattan" adds the absolute differences. "euclidean" gives more weight to one large difference than to many small differences. To get \(d\) back, calculate \(1/x - 1\).

Measures for binary data only. These measures change valued data to binary data first, and give a warning. For two nodes, \(a\) is the number of nodes in the other mode that both have a tie to. \(b\) and \(c\) are the numbers that only one of them has a tie to. \(d\) is the number that neither has a tie to.

  • Measures that do not use \(d\). Use them when two missing ties tell you nothing, for example in a sparse network with many events. "jaccard" is \(a/(a+b+c)\). "czekanowski" (also Dice or Sorensen) is \(2a/(2a+b+c)\), which gives more weight to \(a\). "sokalsneath" is \(a/(a+2(b+c))\), which gives more weight to \(b\) and \(c\). For valued data, use "ruzicka" in place of "jaccard".

  • Measures that count \(d\) as a match. Use them when a missing tie tells you as much as a tie. "rand" (simple matching) is \((a+d)/(a+b+c+d)\). "hamann" is \(((a+d)-(b+c))/(a+b+c+d)\), from -1 to 1. It is positive when there are more matches than differences. "rogerstanimoto" is \((a+d)/(a+2(b+c)+d)\).

  • Measures from the odds ratio \(ad/bc\). "yule" is Yule's Q, \((ad-bc)/(ad+bc)\). "bonacich" is \(\sqrt{ad}/(\sqrt{ad}+\sqrt{bc})\), which is Yule's Y from 0 to 1. Both give 1 when \(b\) or \(c\) is 0.

  • Geometric measures. "ochiai" is \(a/\sqrt{(a+b)(a+c)}\), the cosine for binary data. "ochiai2" (Sokal and Sneath's fifth measure) is \(ad/\sqrt{(a+b)(a+c)(d+b)(d+c)}\), which also uses \(d\). These two do not put pairs in the same order as any other group, so try them too.

  • "hamming" counts the differences, \(b+c\), as the Hamming distance. It gives \(1/(1+b+c)\). It puts pairs in the same order as "rand".

Measures that change "count" for how active each node is:

  • "activity" divides "count" by the average number of ties of the two nodes. For binary data, it is the same as "czekanowski".

  • "association" divides "count" by the count that chance would give. A value above 1 means that two nodes share more than chance would give. This is the association strength of van Eck and Waltman (2009).

  • "fractional" shares each node of the other mode among its members. For example, a work with \(n\) authors adds \(1/(n-1)\) to each pair of its authors. Each author then gets a total of 1 from each work. A work with one author adds nothing. This is the fractional counting of Perianes-Rodriguez et al. (2016).

Measures that read the sign of each tie: "agreement", "disagreement", and "signed". See the section on weighted and signed networks below.

These six measures count every tie, also when a node has more than one tie to the same node.

across

Which margin of the network the operation is taken over. "rows" is the sending margin, so that each node is treated by the ties it sends; "columns" is the receiving margin; and "both" combines them. The two margins coincide for an undirected network, where all three options therefore agree. A two-mode network raises no such question, so "rows" and "columns" there are just the two nodesets.

Note that both the default and what "both" combines differ by function. to_normalised() defaults to "both", where it divides by the square root of the two denominators multiplied together, since that is the only rescaling that preserves a network's symmetry. to_proximity() defaults to "rows", the conventional profile for structural equivalence, and there "both" compares each node's sent and received ties together.

dyad

How the cells within the compared pair's own dyad are treated.

Four of the cells in any comparison are not like the others: \(i\)'s tie to \(j\), \(j\)'s tie to \(i\), and each node's self-tie. These cannot be compared where they lie the way the rest can. In column \(j\), node \(i\)'s entry is a tie to \(j\), but node \(j\)'s entry is its own self-tie: two different things in the same position. Two managers who happen to be tied to one another are not less structurally equivalent for it, but comparing those cells where they lie makes them look that way.

  • "exclude" drops all four cells, so that nodes are compared only on their ties to third parties. This is the strictest reading of structural equivalence, and the default for an undirected network.

  • "reciprocal" drops the self-ties, but compares \(i\)'s tie to \(j\) against \(j\)'s tie to \(i\), so that a reciprocated pair counts as alike there. This is the default for a directed network.

  • "complex" does the same, and additionally compares the two nodes' self-ties against each other. This is the default where the network has self-ties, since there they carry information.

  • "include" compares every cell where it lies, with no special treatment. Use it only where the diagonal genuinely holds comparable values. It is also the quickest, since it needs no pairwise walk.

By default the appropriate treatment is chosen from the network's format, as described above.

A two-mode network has no dyad of this kind, so only NULL or "include" is accepted for one. Pass "include" for a profile matrix whose rows are nodes and whose columns are something else, such as a motif census. A square census with no dimnames otherwise reads as a one-mode network, and would have its cells dropped as if they were ties.

method

How the diagonal and the reciprocal ties are treated. "all" includes all information, "diag" excludes the diagonal (self-ties), "recip" excludes the diagonal but compares pairs' reciprocal ties, and "complex" compares pairs' reciprocal ties and their self ties. By default the appropriate method is chosen based on the network format.

These correspond to to_proximity()'s dyad argument, except that "recip" and "complex" append each node's tie to the other to profiles otherwise taken over the columns. to_proximity() instead keeps the profile and the appended cells on the same margin. The two therefore agree for an undirected network but not for a directed one.

Value

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.

Details

Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:

               data.frame default igraph matrix network stocnet tbl_graph
to_correlation                  *             *
to_cosine                       *             *
to_proximity            *       *      *      *       *       *         *

Node correlation

to_correlation() performs a Pearson pairwise correlation. It includes a switch: whereas for a two-mode network it performs a regular correlation, including all rows, for an undirected network it performs a correlation on a matrix with the diagonals removed, for a reciprocated network it includes the difference between reciprocated ties, and for complex networks it includes also the difference between the self ties in each pairwise calculation. This function runs in \(O(mn^2)\) complexity.

Like the other functions here, it returns the class of object it was given, so that the correlations between the nodes of a network are returned as a weighted network of the same class. The correlations are calculated on a matrix, however, so a network is coerced to one and the result coerced back. Passing a matrix, e.g. to_correlation(as_matrix(.data)), spares both, and returns the matrix of correlations that further calculation most often wants.

Node cosine

to_cosine() takes the cosine of the angle between each pair of the matrix's columns, without projecting it. It is to_proximity()'s "cosine" measure over the columns rather than the rows, and so accepts a two-mode network, where it describes the second mode.

References

On structural equivalence

Lorrain, Francois, and Harrison C. White. 1971. "Structural equivalence of individuals in social networks". The Journal of Mathematical Sociology 1(1): 49-80. doi:10.1080/0022250X.1971.9989788

See also

to_mode1(), which applies the same measures to a two-mode network, comparing nodes on their affiliations rather than on their ties.

Other modifications: modif_backbone, modif_concepts, modif_direction, modif_from_parts, modif_from_ternary, modif_influence, modif_labels, modif_layers, modif_levels, modif_loops, modif_miss, modif_motifs, modif_paths, modif_permutation, modif_project, modif_scope, modif_split, modif_weight

Examples

to_proximity(ison_algebra, "pearson")
#> 
#> ── # Proximities of M182 Algebra Class ─────────────────────────────────────────
#> # A signed, weighted, undirected network of 16 nodes and 120 ties
#> # Transformed by projection: proximity (pearson)
#> 
#> ── Ties 
#> # A tibble: 120 × 4
#>    from    to  weight  sign
#>   <int> <int>   <dbl> <dbl>
#> 1     1     2 -0.0515    -1
#> 2     1     3 -0.206     -1
#> 3     1     4  0.741      1
#> 4     1     5 -0.0809    -1
#> 5     1     6 -0.162     -1
#> 6     1     7 -0.133     -1
#> # ℹ 114 more rows
#> 
to_proximity(ison_adolescents, "jaccard")
#> ── # Proximities of The Adolescent Society ─────────────────────────────────────
#> # A labelled, weighted, undirected network of 8 nodes and 16 ties
#> # Transformed by projection: proximity (jaccard)
#> 
#> ── Nodes 
#> # A tibble: 8 × 1
#>   label
#>   <chr>
#> 1 Betty
#> 2 Sue  
#> 3 Alice
#> 4 Jane 
#> 5 Dale 
#> 6 Pam  
#> # ℹ 2 more rows
#> 
#> ── Ties 
#> # A tibble: 16 × 3
#>    from    to weight
#>   <int> <int>  <dbl>
#> 1     1     3  0.25 
#> 2     1     5  0.333
#> 3     1     6  0.333
#> 4     2     3  0.5  
#> 5     2     4  0.5  
#> 6     2     5  0.25 
#> # ℹ 10 more rows
#> 
to_proximity(ison_southern_women, "ruzicka", across = "columns")
#> ── # Projection of Southern Women Data ─────────────────────────────────────────
#> # A labelled, weighted, undirected network of 14 nodes and 66 ties
#> # Transformed by projection: mode 2 (ruzicka)
#> 
#> ── Nodes 
#> # A tibble: 14 × 3
#>   label Surname active
#>   <chr> <chr>   <lgl> 
#> 1 E1    6/27    FALSE 
#> 2 E2    3/2     FALSE 
#> 3 E3    4/12    FALSE 
#> 4 E4    9/26    FALSE 
#> 5 E5    2/25    FALSE 
#> 6 E6    5/19    FALSE 
#> # ℹ 8 more rows
#> 
#> ── Ties 
#> # A tibble: 66 × 3
#>    from    to weight
#>   <int> <int>  <dbl>
#> 1     1     2  0.5  
#> 2     1     3  0.5  
#> 3     1     4  0.4  
#> 4     1     5  0.375
#> 5     1     6  0.375
#> 6     1     7  0.182
#> # ℹ 60 more rows
#>