compute_fscore | R Documentation |
Compute factor scores
compute_fscore(
y,
lambda,
theta,
psi = NULL,
nu = NULL,
alpha = NULL,
method = c("regression", "Bartlett"),
center_y = TRUE,
acov = FALSE,
fs_matrices = FALSE
)
y |
An N x p matrix where each row is a response vector. If there is only one observation, it should be a matrix of one row. |
lambda |
A p x q matrix of factor loadings. |
theta |
A p x p matrix of unique variance-covariances. |
psi |
A q x q matrix of latent factor variance-covariances. |
nu |
A vector of length p of measurement intercepts. |
alpha |
A vector of length q of latent means. |
method |
A character string indicating the method for computing factor scores. Currently, only "regression" is supported. |
center_y |
Logical indicating whether |
acov |
Logical indicating whether the asymptotic covariance matrix of factor scores should be returned as an attribute. |
fs_matrices |
Logical indicating whether covariances of the error
portion of factor scores ( |
An N x p matrix of factor scores.
library(lavaan)
fit <- cfa(" ind60 =~ x1 + x2 + x3
dem60 =~ y1 + y2 + y3 + y4 ",
data = PoliticalDemocracy)
fs_lavaan <- lavPredict(fit, method = "Bartlett")
# Using R2spa::compute_fscore()
est <- lavInspect(fit, what = "est")
fs_hand <- compute_fscore(lavInspect(fit, what = "data"),
lambda = est$lambda,
theta = est$theta,
psi = est$psi,
method = "Bartlett")
fs_hand - fs_lavaan # same scores
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.