Type: | Package |
Title: | Exploratory Structural Equation Modeling ESEM |
Version: | 2.0.0 |
Description: | A collection of functions developed to support the tutorial on using Exploratory Structural Equiation Modeling (ESEM) (Asparouhov & Muthén, 2009) https://www.statmodel.com/download/EFACFA810.pdf) with Longitudinal Study of Australian Children (LSAC) dataset (Mohal et al., 2023) <doi:10.26193/QR4L6Q>. The package uses 'tidyverse','psych', 'lavaan','semPlot' and provides additional functions to conduct ESEM. The package provides general functions to complete ESEM, including esem_c(), creation of target matrix (if it is used) make_target(), generation of the Confirmatory Factor Analysis (CFA) model syntax esem_cfa_syntax(). A sample data is provided - the package includes a sample data of the Strengths and Difficulties Questionnaire of the Longitudinal Study of Australian Children (SDQ LSAC) in sdq_lsac(). 'ESEM' package vignette presents the tutorial demonstrating the use of ESEM on SDQ LSAC data. |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | lavaan, magrittr, psych, tidyr, dplyr, rlang, tibble, methods, utils |
RoxygenNote: | 7.2.3 |
Suggests: | rmarkdown, knitr |
VignetteBuilder: | knitr |
URL: | https://github.com/maria-pro/esem |
BugReports: | https://github.com/maria-pro/esem/issues |
Depends: | R (≥ 2.10), GPArotation |
NeedsCompilation: | no |
Packaged: | 2023-07-03 07:57:51 UTC; e5028514 |
Author: | Maria Prokofieva |
Maintainer: | Maria Prokofieva <maria.prokofieva@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2023-07-05 14:03:03 UTC |
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling 'rhs(lhs)'.
Create a referent list
Description
Create a referent list
Usage
create_referent(esem_efa_results)
Arguments
esem_efa_results |
is a psych::fa() object with the results of exploratory factor analysis (EFA) The object can be created using psych::fa() or a wrapper esem_efa() function The function uses efa object to identify referents A referent indicator is selected for each factor It is the item that has a large (target) loading for the factor it measures and The referents are used to ensure model identification and are used as starting values/ fixed values in the the next step to create a lavaan model syntax. |
Value
A list with factors and corresponding referents (i.e. referents in that factor)
Exploratory Structural Equiation Modeling ESEM (ESEM)
Description
Exploratory Structural Equiation Modeling ESEM (ESEM)
Usage
esem_c(
data,
nfactors,
fm = "ML",
rotate = "geominT",
scores = "regression",
residuals = TRUE,
Target = NULL,
missing = TRUE,
mimic = c("MPlus"),
std.lv = TRUE,
ordered = TRUE
)
Arguments
data |
is a raw data matrix. |
nfactors |
is number of factors to extract |
fm |
is factoring method to be used in factor estimation. The suggested methods are available in psych::fa() |
rotate |
is the rotation method to be used. The suggested methods are available in psych::fa() |
scores |
is the factor scores to be used in EFA estimation. The default scores are estimated using regression as set in "regression". |
residuals |
is set to FALSE by default. In case the residual matrix is required in the output, this parameter should be set to TRUE |
Target |
is the target rotation matrix to be used. In case no target matrix is provided, EFA proceeds with alternative approach. The list of target rotations are available from GPArotation |
missing |
is used with scores set to TRUE. The default is missing=TRUE which imputes missing values using either the median or the mean. |
mimic |
allows to mimic the final output results (i.e. CFA stage) to MPLUS to allow the user to compare the output. |
std.lv |
is set to TRUE by default to provide standardized latent variables. |
ordered |
is set to TRUE by default to allow the use of categorical variables. |
Value
An object of class lavaan::lavaan-class, for which several methods are available, including a summary method.
Confirmatory factor anaysis (CFA) step for ESEM-with-CFA
Description
is a wrapper for lavaan::cfa() function
Usage
esem_cfa(model, data, mimic = c("MPlus"), std.lv = TRUE, ordered = TRUE)
Arguments
model |
is a character vector with a lavaan syntax for the ESEM model. |
data |
is a raw data matrix. |
mimic |
allows to mimic the final output results (i.e. CFA stage) to MPLUS to allow the user to compare the output. |
std.lv |
is set to TRUE by default to provide standardized latent variables. |
ordered |
is set to TRUE by default to allow the use of categorical variables. |
Value
An object of class lavaan::lavaan-class, for which several methods are available, including a summary method.
Exploratory Structural Equiation Modeling ESEM (ESEM) with geominT rotation
Description
Exploratory Structural Equiation Modeling ESEM (ESEM) with geominT rotation
Usage
esem_cfa2(
data,
nfactors,
fm = "ML",
rotate = "geominT",
scores = "regression",
residuals = TRUE,
Target = NULL,
missing = TRUE,
mimic = c("MPlus"),
std.lv = TRUE,
ordered = TRUE
)
Arguments
data |
is a raw data matrix. |
nfactors |
is number of factors to extract |
fm |
is factoring method to be used in factor estimation. The suggested methods are available in psych::fa() |
rotate |
is the rotation method to be used. The suggested methods are available in psych::fa() |
scores |
is the factor scores to be used in EFA estimation. The default scores are estimated using regression as set in "regression". |
residuals |
is set to FALSE by default. In case the residual matrix is required in the output, this parameter should be set to TRUE |
Target |
is the target rotation matrix to be used. In case no target matrix is provided, EFA proceeds with alternative approach. The list of target rotations are available from GPArotation |
missing |
is used with scores set to TRUE. The default is missing=TRUE which imputes missing values using either the median or the mean. |
mimic |
allows to mimic the final output results (i.e. CFA stage) to MPLUS to allow the user to compare the output. |
std.lv |
is set to TRUE by default to provide standardized latent variables. |
ordered |
is set to TRUE by default to allow the use of categorical variables. |
Value
An object of class lavaan::lavaan-class, for which several methods are available, including a summary method.
Title
Description
Title
Title
Usage
esem_cfa_syntax(loadings)
esem_cfa_syntax(loadings)
Arguments
loadings |
is a matrix with loadings values |
Value
A character vector with the syntax of the model tp be used at the CFA stage.
A character vector with the syntax of the model tp be used at the CFA stage.
Exploratory factor analysis (EFA) for ESEM
Description
Exploratory factor analysis (EFA) for ESEM
Usage
esem_efa(
data,
nfactors,
fm = "ML",
rotate = "geominT",
scores = "regression",
residuals = TRUE,
Target = NULL,
missing = TRUE
)
Arguments
data |
is a raw data matrix. |
nfactors |
is number of factors to extract |
fm |
is the factoring method. |
rotate |
is the rotation method to be used. The suggested methods are available in psych::fa() |
scores |
is the factor scores to be used in EFA estimation. The default scores are estimated using regression as set in "regression". |
residuals |
is set to FALSE by default. In case the residual matrix is required in the output, this parameter should be set to TRUE |
Target |
is the target rotation matrix to be used. In case no target matrix is provided, EFA proceeds with alternative approach. The list of target rotations are available from GPArotation |
missing |
is used with scores set to TRUE. The default is missing=TRUE which imputes missing values using either the median or the mean. |
Value
Eigen values of the common factor solution and reporting results for EFA stage
Examples
sdq_lsac<-sdq_lsac
esem_efa(data=sdq_lsac,
nfactors=5,
fm = 'ML',
rotate="geominT",
scores="regression",
residuals=TRUE,
missing=TRUE)
Create a model syntax for ESEM-with-CFA
Description
Create a model syntax for ESEM-with-CFA
Usage
esem_syntax(esem_efa_results, referent_list = NULL)
Arguments
esem_efa_results |
is a psych::fa() object with the results of exploratory factor analysis (EFA) The object can be created using psych::fa() or a wrapper esem_efa() function |
referent_list |
is a list with latent variables (factors) and their corresponding referent items. referent_list can be generated using create_referent() function. If no referent_list is provided, the list is generated automatically |
Value
A character vector with a lavaan syntax for the ESEM model.
Title
Description
Title
Usage
esem_syntax_keys(key_matrix, fixed)
Arguments
key_matrix |
is a matrix to be used to generate loadings |
fixed |
is the values fixed or should be freely estimated |
Value
A character vector with the syntax of the model tp be used at the CFA stage.
Create a model syntax for ESEM-with-CFA compatible with MPlus
Description
Create a model syntax for ESEM-with-CFA compatible with MPlus
Usage
esem_syntax_mplus(key_matrix = NULL)
Arguments
key_matrix |
is a key matrix with the primary factor items. It can be made with the make.keys() function. The primary factor items in the matrix are used as referent items. |
Value
A character vector with a lavaan syntax for the ESEM model that imitates MPlus.
Title
Description
Title
Usage
make_target(data, keys)
Arguments
data |
is a dataset to be used in EFA |
keys |
is a key matrix with the primary factor items. It can be made with the make.keys() function. The primary factor items in the matrix are used as referent items. |
Value
a list with target matrix
Strengths and Difficulties Questionnaire (SDQ) of the Longitudinal Study of Australian Children (LSAC)
Description
The Longitudinal Study of Australian Children (LSAC) is a major study following the development of 10,000 young people and their families from all parts of Australia. It is conducted in partnership between the Department of Social Services, the Australian Institute of Family Studies and the Australian Bureau of Statistics with advice provided by a consortium of leading researchers.
Usage
sdq_lsac
Format
A tibble with 3840 rows and 25 variables
Details
The study began in 2003 with a representative sample of children from urban and rural areas of all states and territories in Australia. The study has a multi-disciplinary base, and examines a broad range of topics, including parenting, family, peers, education, child care and health.
Data are collected from two cohorts every two years. The first cohort of 5,000 children was aged 0–1 years in 2003–04, and the second cohort of 5,000 children was aged 4–5 years in 2003–04. The full dataset is available here The SDQ is a 25-item instrument for children aged 4-17 years and includes fives scales: the “Hyperactivity,” “Emotional Symptoms,” “Conduct Problems,” “Peer Problems,” and “Prosocial Behaviors”.
The dataset was pre-processed and includes only variables relevant to the original latent variables. The cleaning included:
- reverse coding items s7_1, s11_1, s14_1, s21_1, s25_1. The reversed variables are named with R in the end: s7_1R, s11_1R, s14_1R, s21_1R,s25_1R
- the missing data treatment was done is addressed following guidelines of Baraldi & Enders, 2010 and Baraldi & Enders, 2010.
The cases with more than 10 with 5 iterations using multivariate imputations by chained equations approach that is based on Fully Conditional Specification, where each incomplete variable is imputed by a separate model (see