ESEM output omits oblique-rotated residual covariances
TDJorgensen opened this issue · 1 comments
This one came up while reviewing an example you have seen, but the
data are attached here as a CSV file for convenience.
library(lavaan)
Study_1_data_for_sharing <- read.csv("Study.1.data.for.sharing.csv")
esem1 <- '
##the long format (more flexible) each factor is defined separately
efa("teacher")*Teacher_autonomy =~ T_autonomy1 + T_autonomy2 + T_autonomy3 + T_competence1 + T_competence2 + T_competence3 + T_relatedness1 + T_relatedness2 + T_relatedness3
efa("teacher")*Teacher_competence =~ T_autonomy1 + T_autonomy2 + T_autonomy3 + T_competence1 + T_competence2 + T_competence3 + T_relatedness1 + T_relatedness2 + T_relatedness3
efa("teacher")*Teacher_relatedness =~ T_autonomy1 + T_autonomy2 + T_autonomy3 + T_competence1 + T_competence2 + T_competence3 + T_relatedness1 + T_relatedness2 + T_relatedness3
##the short format (less flexible) all factors defined in one instance (remove ”##” if you want to use this)
##efa("teacher")*Teacher_autonomy +
##efa("teacher")*Teacher_competence +
##efa("teacher")*Teacher_relatedness =~ T_autonomy1 + T_autonomy2 + T_autonomy3 + T_competence1 + T_competence2 + T_competence3 + T_relatedness1 + T_relatedness2 + T_relatedness3
##definging the second ESEM block
efa("self")*Self_Meaning =~ S_meaning1 + S_meaning2 + S_meaning3 + S_confidence1 + S_confidence2 + S_confidence3 + S_Intrinsic1 + S_Intrinsic2+S_Intrinsic3
efa("self")*Self_Confidence =~ S_meaning1 + S_meaning2 + S_meaning3 + S_confidence1 + S_confidence2 + S_confidence3 + S_Intrinsic1 + S_Intrinsic2+S_Intrinsic3
efa("self")*Intrinsic_Motivation =~ S_meaning1 + S_meaning2 + S_meaning3 + S_confidence1 + S_confidence2 + S_confidence3 + S_Intrinsic1 + S_Intrinsic2+S_Intrinsic3
##definging the outcome variable
Intent_to_Quit =~ Intent_to_withdraw1 + Intent_to_withdraw2 + Intent_to_withdraw3 + Intent_to_withdraw4 + Intent_to_withdraw5
##definging the structural part
Self_Meaning ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness
Self_Confidence ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness
Intrinsic_Motivation ~ Teacher_autonomy + Teacher_competence + Teacher_relatedness
Intent_to_Quit ~ Self_Meaning + Self_Confidence + Intrinsic_Motivation +
Teacher_autonomy + Teacher_competence + Teacher_relatedness
'
out1 <- sem(model = esem1, data = Study_1_data_for_sharing,
rotation = "geomin", rotation.args = list(geomin.epsilon = 0.5))
There is an EFA block ("teacher"
) among 3 exogenous factors, and another EFA block ("self"
) among 3 endogenous factors. Both are of course obliquely rotated, but only the exogenous factor covariances are shown in the parameterEstimates()
and by extension summary()
output:
PE <- parameterEstimates(out1)
PE[PE$op == "~~", ] # bottom 3 are factor covariances
The rotated factor covariances are visible in the list of parameter matrices:
lavInspect(out1, "est")$psi
But their delta-method SEs do not appear to be calculated:
lavInspect(out1, "se")$psi
The exogenous-factor covariances seem to be added to the parameter table with a $user
code 7:
PT <- parTable(out1)
PT[PT$op == "~~", ]
Perhaps the endogenous-factor covariances need to be added the same way?
Indeed. The reason was that the 'self' factors are mediators, and in lavaan's logic, the (residual) covariances among latent mediators are not free by default. Therefore, they were not listed in the parameter table. (But they should).
Fixed now in the github version.