| sfa | R Documentation |
Performs exploratory factor analysis on language model embeddings of scale
items. Given item text, sfa embeds each item, transforms embeddings
into a similarity matrix, and runs EFA to recover latent factor structure
entirely from the text.
sfa(
items,
nfactors = NULL,
rotate = "oblimin",
fm = "minres",
encoding = "atomic",
embed = "sbert",
model = NULL,
embeddings = NULL,
similarity = NULL,
scoring = NULL,
n_factors_method = "parallel",
dim_select = c("none", "dynega"),
n.obs = NA,
parallel_iter = 100L,
seed = 42L,
calibrate = FALSE,
calibrate_iter = 100L,
label_factors = FALSE,
leximax = list(),
...
)
items |
Character vector of item text, or a data.frame with an
|
nfactors |
Integer number of factors to extract, or |
rotate |
Rotation method passed to |
fm |
Extraction method passed to |
encoding |
Similarity transform: |
embed |
Embedding backend: |
model |
Model name for the embedding backend. If |
embeddings |
Optional precomputed numeric matrix (n_items x embedding_dim). When supplied, skips the embedding step entirely. |
similarity |
Optional precomputed symmetric item-by-item similarity
matrix (n_items x n_items). When supplied, embedding and the encoding
transform are skipped and this matrix is used directly — e.g. a signed
NLI matrix from |
scoring |
Numeric vector of +1/-1 per item. If |
n_factors_method |
Retention rule when |
dim_select |
Embedding-dimension selection before analysis:
|
n.obs |
Sample size passed to |
parallel_iter |
Iterations for embedding parallel analysis. |
seed |
Random seed for stochastic operations, used via
|
calibrate |
Logical: run an isotropic random-embedding Monte Carlo null calibration of the fit diagnostics? (Inspired by Pokropek 2026, but using a random-Gaussian unit-vector null rather than Pokropek's corpus-word resampling. The two nulls differ in kind: corpus resampling preserves the baseline thematic similarity that all words in a topic-specific corpus share, whereas the Gaussian unit-vector null has zero expected inter-item similarity and is therefore a stricter, structure-free reference.) |
calibrate_iter |
Iterations for calibration. |
label_factors |
If |
leximax |
Options list for |
... |
Additional arguments passed to |
An object of class "sfa" containing factor loadings,
communalities, eigenvalues, variance accounted for, and embedding-specific
diagnostics (KMO, TEFI, RMSR, CAF, McDonald's omega). The $loadings
component has class "loadings" and works with
factor.congruence and fa.sort.
Use as_psych to obtain the underlying psych::fa
object.
Milano, N., Luongo, M., Ponticorvo, M., & Marocco, D. (2025). Semantic analysis of test items through large language model embeddings predicts a-priori factorial structure of personality tests. Current Research in Behavioral Sciences, 8, 100168. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.crbeha.2025.100168")}
Casella, M., Luongo, M., Marocco, D., Milano, N., & Ponticorvo, M. (2024). LLM embeddings on test items predict post hoc loadings in personality tests. Ital-IA 2024: 4th National Conference on Artificial Intelligence, CEUR Workshop Proceedings.
Guenole, N., D'Urso, E. D., Samo, A., Sun, T., & Haslbeck, J. M. B. (Preprint). Enhancing Scale Development: Pseudo Factor Analysis of Language Embedding Similarity Matrices. OSF. https://osf.io/3mpzb/
Pellert, M., Lechner, C. M., Sen, I., & Strohmaier, M. (2026). Neural network embeddings recover value dimensions from psychometric survey items on par with human data. Findings of the Association for Computational Linguistics: EACL 2026, 5738–5752.
Pokropek, A. (2026). From keyword-based text measures to latent variables: Confirmatory factor analysis with word embeddings. EPJ Data Science. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1140/epjds/s13688-026-00654-1")}
sfa_similarity, sfa_parallel,
sfa_nfactors, sfa_embed,
sfa_congruence, as_psych
data(big5)
# nfactors = 5 keeps this example fast; omit it to let embedding-adapted
# parallel analysis (sfa_parallel) choose the number of factors.
fit <- sfa(big5$items, embeddings = big5$embeddings, scoring = big5$scoring,
nfactors = 5)
print(fit)
plot(fit, type = "scree")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.