View source: R/factor_scores.R
| factor_scores | R Documentation |
Returns a data frame of estimated latent factor scores, one column per
factor and one row per observation. Works with any esem_fit,
plain lavaan object, or esem_invariance result.
factor_scores(
x,
method = c("regression", "bartlett"),
level = "auto",
align = NULL,
dCFI_cutoff = -0.01,
...
)
x |
An |
method |
Character. Estimation method: |
level |
Character. Only used when |
align |
Optional alignment of the score columns.
Internally calls |
dCFI_cutoff |
Numeric. The |
... |
Reserved for future use. |
For multi-group ordered B-ESEM scoring, a single pooled polychoric
correlation matrix is applied to every group. A warning is issued because
scores for non-reference groups may be biased when their correlation
structures differ. If the polychoric correlation matrix or the
score-information matrix is singular, factor_scores() raises an
informative error identifying the singular matrix rather than exposing a
bare solve() failure.
A data.frame with one column per latent factor (named by
the model's factor labels) and one row per observation. A group
column is prepended automatically for multi-group models. Rows for
missing observations contain NA in all factor columns.
data("HolzingerSwineford1939", package = "lavaan")
d <- HolzingerSwineford1939[, paste0("x", 1:9)]
# Single fit
fit <- esem(d, nfactors = 3)
scores <- factor_scores(fit)
head(scores)
# Merge back to original data
d_with_scores <- cbind(d, factor_scores(fit))
# Bartlett method
scores_b <- factor_scores(fit, method = "bartlett")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.