sfa_dimselect: Embedding-Dimension Selection by EGA Depth Optimization

View source: R/dimselect.R

sfa_dimselectR Documentation

Embedding-Dimension Selection by EGA Depth Optimization

Description

Selects how many leading embedding coordinates ("depth") to use before factor analysis, instead of defaulting to the full vector. This adapts the depth-optimization objective of Golino (2026); it is not a reimplementation of Dynamic EGA (DynEGA) – it does not perform DynEGA's time-delay embedding or derivative (GLLA) estimation, but applies static EGA at each depth and optimizes Golino's composite. Following Golino (2026), the embedding is treated as a searchable landscape: structural information is not uniformly distributed across coordinates, so a sub-range of dimensions can recover the construct structure more cleanly than the whole vector (and denoise the over-factoring seen with some embedding models).

Usage

sfa_dimselect(
  embeddings,
  factors = NULL,
  scoring = NULL,
  encoding = "atomic",
  min_depth = 3L,
  max_depth = NULL,
  step = NULL,
  max_eval = 150L,
  weights = c(nmi = 0.7, tefi = 0.3),
  algorithm = "walktrap"
)

Arguments

embeddings

Numeric matrix (n_items x embedding_dim).

factors

Optional character/factor vector of theoretical labels, one per item, enabling the NMI term. If NULL, TEFI-only selection.

scoring

Optional numeric +1/-1 vector (keying), passed to the similarity transform.

encoding

Similarity transform used at each depth (default "atomic", matching sfa). See sfa_similarity.

min_depth

Smallest depth to evaluate (default 3, with a minimum of 3 imposed for TMFG stability).

max_depth

Largest depth to evaluate (default: full embedding dimension).

step

Depth increment. Default chooses a step giving at most max_eval evaluations. (Golino 2026 swept depths in increments of 5 coordinates over a large range, not 5 total evaluations.)

max_eval

Soft cap on the number of depths evaluated when step is left at its default (default 150).

weights

Named numeric vector c(nmi=, tefi=) for the composite (default c(nmi = 0.70, tefi = 0.30)).

algorithm

Community-detection algorithm passed to EGAnet (default "walktrap").

Details

The coordinate index is swept as an ordered depth axis. The function sweeps increasing depths d; at each depth it builds the item-by-item association matrix from the first d coordinates, estimates the network with the Triangulated Maximally Filtered Graph (TMFG) and detects communities with the Walktrap algorithm (both via EGAnet, as in Golino 2026), then scores the resulting partition with:

  • the Total Entropy Fit Index (TEFI; lower is better), and

  • Normalized Mutual Information (NMI) against the theoretical factor labels, when available (higher is better).

Both metrics are min-max normalized across the swept depths and combined into a composite C(d) = w_{NMI}\,NMI_{norm} - w_{TEFI}\,TEFI_{norm} (default weights 0.70 / 0.30, per Golino 2026). The depth maximizing C is returned. With no theoretical labels the selection falls back to minimizing TEFI alone (less reliable; a single metric can yield structurally incoherent optima).

Value

An object of class "sfa_dimselect": a list with optimal_depth, the full trajectory data frame (depth, n_dim, nmi, tefi, and normalized/composite columns), the weights used, and full_dim.

Selection engine vs. analysis engine

Depth is scored with the EGA network / Walktrap partition (Golino's engine). When the chosen depth then feeds fa-based extraction (the default in sfa), the subspace that is best for EGA recovery is not guaranteed to be best for the EFA solution. For results that match the selection criterion, pair dim_select = "dynega" with n_factors_method = "EGA". Golino (2026) also reports the largest gains for moderate-to-large item pools (roughly 10–20+ items per dimension); short scales may see little or no benefit.

References

Golino, H. (2026). Optimizing the landscape of LLM embeddings with Dynamic Exploratory Graph Analysis for generative psychometrics: A Monte Carlo study. Manuscript under review, Proceedings of the 90th Annual International Meeting of the Psychometric Society. arXiv:2601.17010.

See Also

sfa (use dim_select = "dynega"), sfa_similarity

Examples

data(big5)

if (requireNamespace("EGAnet", quietly = TRUE)) {
  # small depth grid for a quick illustration
  ds <- sfa_dimselect(big5$embeddings, factors = big5$factors,
                      scoring = big5$scoring, max_depth = 80, step = 20)
  ds$optimal_depth
}


semanticfa documentation built on Sept. 2, 2026, 1:07 a.m.