Procrustes alignment of latent positions across time
Source:R/procrustes_align.R
procrustes_align.RdAligns dynamic latent positions across time periods to remove arbitrary rotational indeterminacy. This is essential for interpreting temporal trajectories of latent positions, since the latent space is only identified up to rotation at each time point.
Uses Procrustes rotation: at each time step, finds the orthogonal rotation matrix that best aligns the current sender coordinates to the preceding period, then applies it sequentially through the series.
Usage
procrustes_align(
object = NULL,
U = NULL,
V = NULL,
G = NULL,
return_fit = FALSE,
per_draw = FALSE,
...
)Arguments
- object
A fitted
ameorlameobject, or NULL if raw arrays are provided viaU/V/G.- U
Optional 3D array
[n, R, T]of sender latent positions. Ifobjectis provided andUis NULL, extracted fromobject$U.- V
Optional 3D array
[n, R, T]of receiver latent positions. For unipartite asymmetric models, U and V share one rotation per period so U V' is unchanged. For bipartite models, aligned jointly with U through the G interaction matrix.- G
Optional
[R_row, R_col]interaction matrix for bipartite models; it is returned unchanged, and each period's U G V' is preserved.- return_fit
Logical. If TRUE and
objectis provided, returns a modified copy of the fit object with aligned latent positions. Default FALSE.- per_draw
Logical. When TRUE, run Procrustes alignment per posterior draw rather than on the posterior-mean trajectory. This uses
object$U_draws/object$V_drawson a dynamic fit, orobject$U_sampleson a static one (populated byposterior_opts = list(save_UV_draws = TRUE)) when present; otherwise falls back to mean-trajectory alignment and emits an informational note. On a bipartite fit each draw is aligned with its own interaction-matrix draw fromobject$G_samples, so every draw's U G V' is unchanged; without those draws per-draw alignment is an error. Per-draw alignment is the methodologically correct treatment – rotation indeterminacy is a per-draw property, not a per-mean one – but is more memory-hungry. Default FALSE.- ...
Additional arguments (currently unused).
Value
If return_fit = FALSE (default): a list with components
U (aligned sender positions), V (aligned receiver positions,
if applicable), and G (the interaction matrix, for bipartite).
If return_fit = TRUE: a copy of object with aligned latent
positions replacing the originals.
Details
For directed unipartite networks, U and V share one Procrustes rotation per period, found from the stacked positions, so the product U V' is unchanged. For symmetric networks the product is \(U L U'\) with a diagonal L, which only a sign change of a column of U leaves unchanged; each period takes the column signs that best match the period before it.
For bipartite networks, one G serves every period, so a period's product
U %*% G %*% t(V) is unchanged only by transformations
R_U, R_V with t(R_U) %*% G %*% R_V = G. In the
singular-vector bases of G these are sign changes of a singular direction,
applied to U and V together; each period takes the sign changes that best
match the period before it, and G is returned unchanged.
If U is a 2D matrix (static model with a single time point), it is returned unchanged with an informational message.
Alignment is within one fit: each period of a single dynamic trajectory is
rotated onto the period before it. Two different fits are never aligned to
each other automatically. Because raw arrays are accepted, you can do that
explicitly: stack the two fits' U matrices into an [n, R, 2]
array (same actors in the same order, same R) and call
procrustes_align(U = that_array); the second slice comes back
rotated onto the first.
See also
latent_positions for extracting aligned positions as
a tidy data frame, uv_plot for visualizing latent positions
Examples
# \donttest{
data(YX_bin_list)
# YX_bin_list$Y stores latent-scale values; threshold to 0/1 first
Y_bin <- lapply(YX_bin_list$Y, function(y) 1 * (y > 0))
# chains = 1 keeps the example short; the default runs two chains and compares them
fit <- lame(Y_bin, Xdyad = YX_bin_list$X, R = 2,
family = "binary", dynamic_uv = TRUE,
burn = 5, nscan = 5, odens = 1,
verbose = FALSE, chains = 1)
aligned <- procrustes_align(fit)
str(aligned$U) # aligned 3D array [n, R, T]
#> num [1:50, 1:2, 1:4] -0.4061 0.0163 -0.3369 0.8471 0.3153 ...
#> - attr(*, "dimnames")=List of 3
#> ..$ : chr [1:50] "303" "304" "317" "321" ...
#> ..$ : NULL
#> ..$ : NULL
# }