Learn R Programming

lame (version 1.3.4)

latent_positions: Extract latent positions as a tidy data frame

Description

Extracts multiplicative latent factor positions (U and V) from a fitted ame, lame or ame_als model and returns them as a tidy data frame suitable for plotting and analysis. Optionally applies Procrustes alignment for dynamic models and includes posterior standard deviations when posterior samples are available.

Usage

latent_positions(object, ...)

# S3 method for ame latent_positions(object, align = FALSE, ...)

# S3 method for lame latent_positions(object, align = TRUE, ...)

# S3 method for ame_als latent_positions(object, align = FALSE, ...)

Value

A data frame with columns:

actor

Character. Actor name (from rownames of U or V).

dimension

Integer. Latent dimension index (1 to R).

time

Character. Time period label. Dynamic fits use the time labels from the input; static (cross-sectional) fits return "1" for every row so downstream filtering by time behaves the same in both cases.

value

Numeric. The posterior mean latent position.

posterior_sd

Numeric. Posterior standard deviation of the latent position, or NA if posterior samples are not available. To enable, fit the model with posterior_opts = posterior_options(save_UV = TRUE).

type

Character. "U" for sender/row positions, "V" for receiver/column positions. Symmetric models have only "U".

Returns a zero-row data frame with correct column names if R = 0.

Arguments

object

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

...

Additional arguments (currently unused).

align

Logical. For dynamic models (dynamic_uv = TRUE), apply Procrustes alignment across time to remove rotational indeterminacy. Default is FALSE for ame objects and TRUE for lame objects.

Author

Cassy Dorff, Shahryar Minhas, Tosin Salau

See Also

procrustes_align for standalone Procrustes alignment, uv_plot for visualizing latent positions, posterior_options for enabling posterior sampling of U/V

Examples

Run this code
# \donttest{
data(YX_nrm)
fit <- ame(YX_nrm$Y, Xdyad = YX_nrm$X, R = 2,
           burn = 5, nscan = 5, odens = 1, verbose = FALSE)
lp <- latent_positions(fit)
head(lp)
# }

Run the code above in your browser using DataLab