ESEM: Exploratory Structural Equation Modeling

View source: R/ESEM.R

ESEMR Documentation

Exploratory Structural Equation Modeling

Description

An easy-to-use function for exploratory structural equation measurement models via lavaan

Usage

ESEM(data, method = 'startvalues',
     Nfactors = NULL, extraction = 'ml', 
     rotation_EFA = 'oblimin',  
     rotation_LV  = 'geomin',  
     corkind = 'pearson', anchors = NULL, estimator = 'ML', 
     ordered = FALSE, target = NULL, target_keys = NULL, 
     bifactor = FALSE, verbose = TRUE)

Arguments

data

A dataframe with the variables (and no other variables).
Example: data = data_RSE

method

When method = 'efa_blocks' (the default), the function uses the lavaan EFA blocks method. When method = 'startvalues', the function will first run an EFA (using the Nfactors, extraction, and rotation arguments) to obtain starting values and anchors for the ESEM analyses.

Nfactors

The number of factors to extract. If Nfactors is not specified, and method = 'startvalues', then the EMPKC function is used to determine the number of factors.

extraction

The factor extraction method for the analysis. The options are 'ml' (the default), 'paf', 'image', 'minres', 'uls', 'ols', 'wls', 'gls', 'alpha', and 'fullinfo'.

rotation_EFA

The factor rotation method for the EFA analysis (if conducted).
The orthogonal rotation options are: 'varimax' (the default), 'quartimax', 'bentlerT', 'equamax', 'geominT', 'bigeominT', 'bifactorT', 'entropy', and 'none'.
The oblique rotation options are: 'promax' (the default), 'quartimin', 'oblimin', 'oblimax', 'simplimax', 'bentlerQ', 'geominQ', 'bigeominQ', 'bifactorQ', and 'none'.

rotation_LV

The factor rotation method for the lavaan cfa analysis (if conducted). The options are varimax, quartimax, orthomax, oblimin, quartimin, geomin (the default), promax, entropy, mccammon, infomax, tandem2, oblimax, bentler, simplimax, target, cf, crawford-ferguson, cf-quartimax, cf-varimax, cf-equamax, cf-parsimax, and cf-facparsim.

corkind

The kind of correlation matrix to be used if data is not a correlation matrix. The options are 'pearson' (the default), 'kendall', 'spearman', 'gamma', and 'polychoric'.

anchors

(optional) The names of the anchor variables in data, if any.
Example: anchors = c('v1', 'v5', 'v8')

estimator

The name of the lavaan estimator to be used in the analyses.
The options for basic estimators (continuous data) are ML, GLS, WLS, DWLS, ULS, DLS, and PML.
The options for robust estimators are MLM, MLMVS, MLMV, MLF, MLR, WLSM, WLSMVS, WLSMV, ULSM, ULSMVS, and ULSMV.
Example: estimator = 'ML'

ordered

(optional) Set ordered = TRUE for ordered, categorical data (e.g., binary or Likert scale responses). The default is FALSE, for continuous data.

target

(optional) A target loading matrix to be used instead of a data-driven EFA loading matrix.

target_keys

(optional) A vector of numbers that will be used to create a target loading matrix (instead of using the above "target" argument). The length of target_keys should be equal to the number of variables in data. Each value in target_keys indicates the factor that the ith variable should be free to load on. For example, c(2, 1, 3) would indicate that the first variable loads on the second factor, the second variable loads on the first factor, and the third variable loads on the third factor. The target matrix that is generated by target_keys will have 'NA' for all of the loading variables, which indicates that the actual loadings should be estimated in the analyses. All other elements in the created target will be zeros.
Example: target_keys = c(1, 1, 2, 1, 2, 1, 1, 2, 2, 2)

target_keys is used as the group factor keys when bifactor = TRUE.

bifactor

(logical) Should bifactor ESEM analyses be conducted?
TRUE (default) or FALSE

verbose

(optional) Should detailed results be displayed in console?
TRUE or FALSE (the default)

Details

This function is for lavaan measurement models and not for structural models.

The function can be run with just a single line of code, as in

ESEM(data=data_RSE, Nfactors = 2)

or

ESEM(data=data_RSE, target_keys = c(1, 1, 2, 1, 2, 1, 1, 2, 2, 2))

It is the ESEM model code that distinguishes ESEM from a regular CFA. In a typical CFA, an equation is written for each latent variable specifying the items or variables that load onto each latent variable. Cross-loadings are usually not provided or are not possible in CFA. In ESEM, longer, more elaborate equations for each latent variable are created. These equations contain coefficients/loadings for every item/variable on each latent variable. The coefficients come from either a preliminary exploratory factor analysis or from a specific target loading matrix.

Inside the ESEM function, there are two broad steps in the analyses: preparing ESEM model code, and then running the lavaan cfa function (Rosseel, 2012) using the prepared ESEM model code.

method = 'startvalues' provides more user options (via the extraction and rotation arguments) than does the default method = 'efa_blocks'. The results from the two methods are usually quite similar.

When method = 'startvalues', the preliminary exploratory factor analysis is empirically driven. The extraction method is usually ML, or a robust version of ML. The rotation method is usually oblique geomin, which has an epsilon value that researchers can adjust to reduce the size of cross-loadings and factor correlations. Morin (2023) recommended using an epsilon value of .5 to maximally reduce factor correlations, which in turn helps to obtain more accurate estimates of relations between constructs. The ESEM function in this package uses ML as the default factor extraction method and geominT (oblique) as the default rotation method.

When a target loading matrix is provided (for either method = 'startvalues' or method = 'efa_blocks'), the analyses are more deliberately guided by the researcher's theoretical assumptions or perhaps by a prior factor model for the data. "When using a target rotation, researchers are able to specify the main indicators for each construct, allowing these loadings to be freely estimated, but 'targeting' all cross-loadings to be as close to zero as possible while allowing them to be freely estimated. When based on a target rotation procedure, ESEM can be considered a fundamentally confirmatory method" (Swami et al., 2023, p. 7). For the ESEM function in this package, simply use the "target" argument, or the "target_keys"" argument, to provide a target loading matrix.

(When method = 'startvalues', the function uses the GPArotation package to conduct a targeted rotation of the EFA loadings instead of using geomin rotation. The rotation must be either 'targetQ' (oblique) or 'targetT' (orthogonal)).

When method = 'startvalues' and a target loading matrix is not provided, the ESEM function identifies the highest loading item/variable on each factor and uses these items as anchors in the subsequent CFA. The rotated loadings for non-anchor variables, in contrast, are treated as starting-point loadings in the CFA. The automatic anchor-finding method is by-passed if anchor variables are provided by the user on the "anchors" argument.

Value

A list with the loadings, the anchors, the target matrix, and the esem_model output.

Author(s)

Brian P. O'Connor

References

Afolabi, K. & Konold, T. R. (2024). The circle of methods for evaluating latent variable measurement models: EFA, CFA, and ESEM. Practical Assessment, Research, and Evaluation, 29, Article 15

Morin, A. J. (2023). Exploratory structural equation modeling. In R. Hoyle (Ed.), Handbook of structural equation modeling (2nd ed.). Guilford.

Prokofieva, M., Zarate, D., Parker, A., Palikara, O., & Stavropoulos, V. (2023). Exploratory structural equation modeling: A streamlined step by step approach using the R Project software. BMC Psychiatry, 23(1), Article 546. https://doi.org/10.1186/s12888-023-05028-9

Rosseel, Y. (2012). lavaan: An R package for structural equation modeling. Journal of Statistical Software, 48, 136.

Swami, V., Maano, C., & Morin, A. J. S. (2023). A guide to exploratory structural equation modeling (ESEM) and bifactor-ESEM in body image research. Body Image, 47, Article 101641. https://doi.org/10.1016/j.bodyim.2023.101641

Examples

ESEM(data=data_RSE, method = 'startvalues', Nfactors = 2)

# creating and using a target loading matrix for the ESEM
F1_target <- c(NA, NA, 0, NA, 0, NA, NA, 0, 0, 0)
F2_target <- c(0, 0, NA, 0, NA, 0, 0, NA, NA, NA)
RSE_target <- cbind(F1_target, F2_target)
rownames(RSE_target) <- names(data_RSE)
RSE_target

ESEM(data=data_RSE, method = 'startvalues', target = RSE_target) 

# more simply: use target_keys to create a target loading matrix for the ESEM
ESEM(data=data_RSE, target_keys = c(1, 1, 2, 1, 2, 1, 1, 2, 2, 2)) 
        
         
# Run this command for additional Examples:  vignette("EXAMPLES_vignettes")


EFA.dimensions documentation built on Sept. 14, 2026, 9:08 a.m.