Dear Lavaan Group
I would like to test Mediation Effects described in the following MIMIC Model Structure (see attachement). As illustrated by the diagram, the Mediator is a Latent Variable (I omitted its ordinal indicators to keep the diagram simple). Notice that most of the exogenous variables/covariates are binary.
As I learned in a SEM introduction course, I first would like to fit the Measurement Part of my Model, which in my case is the single Mediator Latent Variable and its corresponding indicators. I have done this using the cfa() command in lavaan and the WLSMV estimator.
Now, I would like to fit the Structural Part of the model, meaning the MIMIC Model itself in order to assess associations between the Latent Variables and covariates (Mediation). To do so, I used the sem() command in lavaan and again the WLSMV estimator. Is this correct up to this point?
In a last step, I would like to explore group differences in my fitted MIMIC Model for the two groups for aetiology: traumatic vs. non-traumatic, dummy coded in variable sci_cause (I tried to follow this article: https://www.frontiersin.org/articles/10.3389/fpsyg.2018.00740/full). Therefore, I first tested my Measurement Model for Measurement Invariance (MI) in the aetiology variable. I used the commands:
config_eti <- cfa(cfa_se, estimator = "WLSMV", data=data_imputed, group="sci_cause", parameterization = "theta")
weak_eti <- cfa(cfa_se, estimator = "WLSMV", data=data_imputed, group="sci_cause", group.equal=c("loadings"), parameterization = "theta")
lavTestLRT(config_eti, weak_eti, method="satorra.2000")
strong_ eti <- cfa(cfa_se, estimator = "WLSMV", data=data_imputed, group=" sci_cause", group.equal=c("loadings","thresholds"), parameterization = "theta")
lavTestLRT(weak_eti, strong_ eti, method="satorra.2000")
In my Model, MI holds on the level of factor loadings. I am now allowed to asses Group Differences in the MIMIC Model by: 0) Fitting again the MIMIC Model without any constrains on regression parameters by the sem() command, and 1) Fitting the MIMIC Model separately for both groups and setting the regression parameters equal across groups by using the command sem(…, group = "sci_cause"). Difference in Model Fit for the Models 0 and 1 can now be assessed by the command:
lavTestLRT(sem_fit_mod_se_eti_0, sem_fit_mod_se_eti_1, method="satorra.2000")
(significant chi-squared difference would indicate group differences in my MIMIC Model on the level of this Fit Index)
Are this proceeding and the corresponding lavaan commands correct/reasonable so far? I am unsure about the MI test: should I do it for the Measurement Model only, or also for the MIMIC Model?
Thanks for any recommendations and comments!
Best regards, isabel
I used the sem() command in lavaan and again the WLSMV estimator. Is this correct up to this point?
In a last step, I would like to explore group differences in my fitted MIMIC Model for the two groups for aetiology: traumatic vs. non-traumatic, dummy coded in variable sci_cause
I am now allowed to asses Group Differences in the MIMIC Model by: 0) Fitting again the MIMIC Model without any constrains on regression parameters by the sem() command, and 1) Fitting the MIMIC Model separately for both groups and setting the regression parameters equal across groups by using the command sem(…, group = "sci_cause"). Difference in Model Fit for the Models 0 and 1 can now be assessed by the command:
lavTestLRT(sem_fit_mod_se_eti_0, sem_fit_mod_se_eti_1, method="satorra.2000")
(significant chi-squared difference would indicate group differences in my MIMIC Model on the level of this Fit Index)
Are this proceeding and the corresponding lavaan commands correct/reasonable so far?
I am unsure about the MI test: should I do it for the Measurement Model only, or also for the MIMIC Model?
Thank you for your critical reading and for the clarification of some points!
Please find in the attachment another picture in which I wanted to show what I meant by Measurement Model and MIMIC Model and which analyses I planned to do with which part of the model . (Should be consistent with the description in my first post)
In a last step, I would like to explore group differences in my fitted MIMIC Model for the two groups for aetiology: traumatic vs. non-traumatic, dummy coded in variable sci_cause
This is confusing, because it makes it sound like you want to use sci_cause as a predictor (cause) in your model. But you are not. Instead, you are fitting a multigroup model, which does not explicitly use sci_cause as a predictor, but merely allows (some or all) parameter estimates to differ between sci_cause groups. This is still a "MIMIC model" in the sense that you have exogenous observed predictors of the latent mediator. But the MIMIC quality just seems like a distraction from your actual questions, which are about testing invariance of the measurement parameters across sci_cause groups. (Also, the article you referenced does not mention anything about MIMIC models.)
Yes, you are right, the MIMIC Quality is distracting from the question of Measurement Invariance Testing.
My idea was the following:
I would like to assess Measurement Invariance for sci_cause in my Measurement Model (the Mediator Construct only) using Multiple Group CFA:
cfa_se <- "SE =~ item1 + item2 + item3 + item4 + item5 + item6"
config_eti <- cfa(cfa_se, estimator = "WLSMV", data=data_imputed, group="sci_cause", parameterization = "theta")
weak_eti <- cfa(cfa_se, estimator = "WLSMV", data=data_imputed, group="sci_cause", group.equal=c("loadings"), parameterization = "theta")
lavTestLRT(config_eti, weak_eti, method="satorra.2000")
And then I would be able to test Group Differences for sci_cause in the bigger Structural Model (the MIMIC Model) by doing:
sem_mod_se_eti_0 <- "
# Latent constructs
SE =~ item1 + item2 + item3 + item4 + item5 + item6
# Regression
# Direct effect
scim_location ~ decubitus + urin_infection + pulmonary + cardiac_function + bowel_care + pain + sex + age_sci_group + partet + compl
# Mediation
SE ~ decubitus + urin_infection + pulmonary + cardiac_function + bowel_care + pain + partet + compl
scim_location ~ SE
"
sem_fit_mod_se_eti_0 <- sem(sem_mod_se_eti_0, estimator = "WLSMV", data = data_imputed, group = "sci_cause")
sem_mod_se_eti_1 <- "
# Latent constructs
SE =~ item1 + item2 + item3 + item4 + item5 + item6
# Regression
# Direct effect
scim_location ~ c(a,a)*decubitus + c(b,b)*urin_infection + c(c,c)*pulmonary + c(d,d)*cardiac_function + c(e,e)*bowel_care + c(f,f)*pain + c(g,g)*sex + c(h,h)*age_sci_group + c(i,i)*partet + c(j,j)*compl
# Mediation
SE ~ c(z,z)*decubitus + c(y,y)*urin_infection + c(x,x)*pulmonary + c(w,w)*cardiac_function + c(v,v)*bowel_care + c(u,u)*pain + c(t,t)*partet + c(s,s)*compl
scim_location ~ c(q,q)*SE
"
sem_fit_mod_se_eti_1 <- sem(sem_mod_se_eti_1, estimator = "WLSMV", data = data_imputed, group = "sci_cause")
lavTestLRT(sem_fit_mod_se_eti_0, sem_fit_mod_se_eti_1, method="satorra.2000")
I hope this is now a better description of what I would like to do. Do you think this proceeding is correct?
I am unsure about the MI test: should I do it for the Measurement Model only, or also for the MIMIC Model?
The whole model is a mimic model, so please refer to specific parameters you are curious about. Testing measurement invariance only involves the equality of the mediator's factor loadings across sci_cause groups. (You do not need to establish strong invariance because your questions are all about covariance structure, not means/intercepts.) Given that you have weak invariance, you can next constrain slopes pointing to and from the mediator to equality across groups, and compare that model to the weak-invariance model to see if those effects are moderated by sci_cause.
I am not sure if I understood this part correctly. Two questions:
1. What do you mean by “weak-invariance model”: In the code above, would this correspond to the model sem_mod_se_eti_0?
2. As far as I planned, I test the whole Structural Model as such for Group Differences only, meaning in a first step I don’t impose any constrains regarding the regression parameters of my Model and in the second step I constrain all corresponding regression parameters to be the same across the two Models for the two groups of sci_cause (see code above). Regarding your command, it seems that I also could test each Mediation Path separately for Group Differences, is this correct?
Do you think this proceeding is correct?
1. What do you mean by “weak-invariance model”:
In the code above, would this correspond to the model sem_mod_se_eti_0?
2. As far as I planned, I test the whole Structural Model as such for Group Differences only, meaning in a first step I don’t impose any constrains regarding the regression parameters of my Model and in the second step I constrain all corresponding regression parameters to be the same across the two Models for the two groups of sci_cause (see code above). Regarding your command, it seems that I also could test each Mediation Path separately for Group Differences, is this correct?
via_decubitus_1 := z1*q1
via_decubitus_2 := z2*q2
via_decubitus_diff := via_decubitus_1 - via_decubitus_2
Error in lav_data_full(data = data, group = group, cluster = cluster, :
lavaan ERROR: unordered factor(s) detected; make them numeric or ordered: t4_decubitus t4_urin_infection t4_pulmonary t4_cardiac_function t4_bowel_care t4_pain age_sci_group sex t4_partet t4_compl
lavaan ERROR: unordered factor(s) detected; make them numeric or ordered: t4_decubitus t4_urin_infection t4_pulmonary t4_cardiac_function t4_bowel_care t4_pain age_sci_group sex t4_partet t4_complAs you can see in the picture of my model which I posted some weeks ago, I am using also binary varibles for the analysis. I guess the command lavCor() is not able to calculate tetrachoric correlations?
Is there another option to get the correlation matrix?
lavInspect(fit, "cor.ov")
Is there another option to get the correlation matrix?Yes, it is already available from a fitted model.
lavInspect(fit, "cor.ov")
lavInspect(fit, "sampstat")
Warning message: In lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: exogenous variable(s) declared as ordered in data: t4_decubitus t4_urin_infection t4_pulmonary t4_cardiac_function t4_bowel_care t4_pain age_sci_group sex t4_partet t4_compl
lavaan WARNING: exogenous variable(s) declared as ordered in data: t4_decubitus t4_urin_infection t4_pulmonary t4_cardiac_function t4_bowel_care t4_pain age_sci_group sex t4_partet t4_complDo you know what is the issue here?
Did lavaan automatically treat them as numerics?