Skip to contents

The cosine similarity between the nodes of one side of the latent product: between its rows (nodes = "row") or its columns (nodes = "col"). Two nodes with similarity near 1 connect to the other side in the same pattern, near -1 in the opposite one. It uses every fitted dimension, so it does not depend on the rotation of the positions. uv_plot(fit, layout = "heatmap", nodes = "row") draws it.

Usage

latent_similarity(fit, nodes, time_point = NULL)

Arguments

fit

A fitted ame, lame or ame_als model with R > 0.

nodes

"row" (row actors; senders in a one-mode network) or "col" (column actors; receivers).

time_point

For a fit with dynamic positions, the period (an index or a period name; the default is the last). Fits with static positions take no time_point.

Value

A symmetric matrix of similarities with the node names as dimnames, with attributes "order" (the clustering order: average linkage on one minus the similarity, the weak nodes last) and "weak" (the names of the nodes not distinguishable from zero; character(0) when there are none or the fit has no posterior sds of its positions).

Details

With \(U\), \(V\) the reported positions and \(M\) the middle matrix of the fit (the identity, fit$G for bipartite fits, fit$L for symmetric fits), the product is \(U M V'\). The similarity of its rows is \(U M V'V M' U'\) scaled to unit diagonal, that of its columns \(V M' U'U M V'\) scaled the same way. Both are computed from the factors, without forming the product. A node whose position is not distinguishable from zero (every coordinate within 1.96 posterior sds of zero) has no defined direction: it is listed in the attribute "weak" and placed last in "order". At most 2,000 nodes are compared.

The latent product is centred (zero row and column means), so positions are relative to the average node of each side. A node with no structure of its own does not sit at the origin but opposite the average pattern, and several such nodes look similar to each other.

Author

Cassy Dorff, Shahryar Minhas, Tosin Salau

Examples

# \donttest{
data(YX_nrm)
# chains = 1 keeps the example short; the default runs two chains and compares them
fit <- ame(YX_nrm$Y, Xdyad = YX_nrm$X, R = 3,
           burn = 10, nscan = 100, odens = 1, verbose = FALSE, chains = 1)
sim <- latent_similarity(fit, "row")
round(sim[attr(sim, "order")[1:5], attr(sim, "order")[1:5]], 2)
#>        node38 node67 node70 node29 node12
#> node38   1.00   0.96   0.96   0.94   0.93
#> node67   0.96   1.00   1.00   0.88   0.91
#> node70   0.96   1.00   1.00   0.90   0.93
#> node29   0.94   0.88   0.90   1.00   0.99
#> node12   0.93   0.91   0.93   0.99   1.00
# }