FACTOR_SCORES: Estimate factor scores for an EFA model

View source: R/FACTOR_SCORES.R

FACTOR_SCORESR Documentation

Estimate factor scores for an EFA model

Description

This is a wrapper function for psych::factor.scores to be used directly with an output from EFA or by manually specifying the factor loadings and intercorrelations. Calculates factor scores according to the specified methods if raw data are provided, and only factor weights if a correlation matrix is provided.

Usage

FACTOR_SCORES(
  x,
  f,
  Phi = NULL,
  method = c("Thurstone", "tenBerge", "Anderson", "Bartlett", "Harman", "components"),
  impute = c("none", "means", "median")
)

Arguments

x

data.frame or matrix. Dataframe or matrix of raw data (needed to get factor scores) or matrix with correlations.

f

object of class EFA or matrix.

Phi

matrix. A matrix of factor intercorrelations. Only needs to be specified if a factor loadings matrix is entered directly into f. Default is NULL, in which case all intercorrelations are assumed to be zero.

method

character. The method used to calculate factor scores. One of "Thurstone" (regression-based; default), "tenBerge", "Anderson", "Bartlett", "Harman", or "components". See psych::factor.scores for details.

impute

character. Whether and how missing values in x should be imputed. One of "none" (default, only complete cases are scored), "median", or "mean".

Value

A list of class FACTOR_SCORES containing the following:

scores

The factor scores (only if raw data are provided.)

weights

The factor weights.

r.scores

The correlations of the factor score estimates.

missing

A vector of the number of missing observations per subject (only if raw data are provided.

R2

Multiple R2 of the scores with the factors.

settings

A list of the settings used.

Examples

# Example with raw data with method "Bartlett" and no imputation
EFA_raw <- EFA(DOSPERT_raw, n_factors = 10, type = "EFAtools", method = "PAF",
               rotation = "oblimin")
fac_scores_raw <- FACTOR_SCORES(DOSPERT_raw, f = EFA_raw, method = "Bartlett",
                                impute = "none")

# Example with a correlation matrix (does not return factor scores)
EFA_cor <- EFA(test_models$baseline$cormat, n_factors = 3, N = 500,
               type = "EFAtools", method = "PAF", rotation = "oblimin")
fac_scores_cor <- FACTOR_SCORES(test_models$baseline$cormat, f = EFA_cor)


EFAtools documentation built on Jan. 6, 2023, 5:16 p.m.