Interaction Term in SEM between Categorical Indicator x Latent Variable

478 views
Skip to first unread message

Yuthika Girme

unread,
Dec 11, 2020, 3:51:41 PM12/11/20
to lavaan

Hi there,

 

I am currently conducting a mediation SEM using lavaan in R. However, I’m conducting an integrative data analysis across multiple samples, and I am wanting to control for the main and interaction effects of sample (dummy coded variables). I’m running into trouble with creating interaction terms – it’s fine when creating an interaction term with my dummy coded sample indicator and another indicator variable in my model, but I can’t seem to create an interaction term with my dummy coded sample indicator and latent variables in my model.

 

I have tried to simply create the term in my model as with my indicator interaction terms (e.g., DC:Latent Variable) which doesn’t work, and I’ve tried to create this term outside my model by defining the interaction (e.g., DCLVX := DC*Latent Variable) and I get the following error:

 

Error in lav_data_full(data = data, group = group, cluster = cluster,  :

  lavaan ERROR: missing observed variables in dataset: EC1_SUP

 

I have had a browse of the other forum questions, and came across two solutions, that I’m not sure really get at what I am wanting:

 

1)      I know there is the multigroup model approach, but the point of my analyses is to run a meta-analytic model rather than run the model for individual samples within my dataset.

2)      I also read about the indProd function, but from my understanding this would create interaction terms between my dummy code variable(s) and ALL indicators of my latent variable(s)? I want to avoid this if possible because I have 20 indicators for my 5 latent variables, and 2 dummy coded variables, which would give me 100 interaction terms… I don’t think my model can handle all these over and above the rest of my model parameters. Is there a way to create an interaction term with the latent variable itself rather than the indicators?

 

Kind Regards,

Yuthika Girme

Patrick (Malone Quantitative)

unread,
Dec 11, 2020, 4:23:25 PM12/11/20
to lav...@googlegroups.com
Yuthika,

Using the multiple-group approach, you can constrain or release structural paths between groups. Fully constraining them to equality is the no-interaction model. Releasing a given path across groups lets you test sample as a moderator of that path.

Hope that helps,
Pat

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/cc2db2de-8224-449e-ae3e-52475b4cd659n%40googlegroups.com.


--
Patrick S. Malone, Ph.D., Malone Quantitative
NEW Service Models: http://malonequantitative.com

He/Him/His

Yuthika Girme

unread,
Dec 11, 2020, 6:17:46 PM12/11/20
to lavaan

Thank you, Pat! That seems to work great!

 

fit1<-sem(model,data=IDASem, group = "Dataset", group.equal = c("intercepts", "loadings", "means", "residuals", "lv.variances", "lv.covariances", "residual.covariances", "regressions"))

 

One last question – the output is all identical now across models. I do ask for indirect effect pathways, but I only get the output once at the end of the output rather than separately for each group. Is it fair to assume that these are the indirect effects across all samples/would be identical across groups too?

 

Yuthika

Patrick (Malone Quantitative)

unread,
Dec 12, 2020, 9:40:37 AM12/12/20
to lav...@googlegroups.com
Yuthika,

To best answer that, we'd need to see your model syntax. But first question: Did the fully constrained model fit the data? If so, the a and b paths are identical between groups and you're done. If not, there's some probing to do.

Pat

Yuthika Girme

unread,
Dec 15, 2020, 12:58:26 PM12/15/20
to lavaan
Hi Pat,

Yea, so the fully constrained model was not as good as the default multigroup model that didn't have any constraints, but it wasn't terrible. Keep in mind, I'm trying to conduct a meta-analysis across datasets and so I'm not interested in group differences, but simply want to ensure I'm controlling for dataset source. 

Multigroup Analysis without any constraints: CFI = .931, RMSEA = .058
Multigroup Analysis with all constraints: CFI = .876, RMSEA = .071

My syntax for the multigroup analysis with constraints looks like this (below) and it's the bit in bold that appears at the end of my output rather than individually for each group like the rest of the SEM output.

model2 <- '
  #measurement model
  WB =~ lifesat1+lifesat2+lifesat3+lifesat4+lifesat5
  SUP =~ supav1+supav2+supav3+supav4+supav5+supav6+supav7+supav8
  AH =~ AH1+AH2+AH3
  PH =~ PH1+PH2+PH3
  AF =~ AF1+AF2+AF3
  PF =~ PF1+PF2+PF3

  #regressions
  WB ~ c*REL.STATUS + b1*SUP + b2*AH + b3*PH + b4*AF + b5*PF + gender + age_c
  SUP ~ a1*REL.STATUS + gender + age_c
  AH ~ a2*REL.STATUS + gender + age_c
  PH ~ a3*REL.STATUS + gender + age_c
  AF ~ a4*REL.STATUS + gender + age_c
  PF ~ a5*REL.STATUS + gender + age_c
  #stigma to support regressions
  SUP ~ d2*AH + d3*PH + d4*AF + d5*PF
  #residual covariances
  AH ~~ PH + AF + PF
  PH ~~ AF + PF
  AF ~~ PF
  
  #define direct and indirect pathways
  indirect_sup := a1*b1
  indirect_ah  := a2*b2
  indirect_ph  := a3*b3
  indirect_af  := a4*b4
  indirect_pf := a5*b5
  indirect_ah_sup := a2*d2*b1
  indirect_ph_sup := a3*d3*b1
  indirect_af_sup := a4*d4*b1
  indirect_pf_sup := a5*d5*b1
  direct := c
  total := c + (a1*b1) + (a2*b2) + (a3*b3) + (a4*b4) + (a5*b5) + (a2*d2*b1) + (a3*d3*b1)+ (a4*d4*b1)+ (a5*d5*b1)'

fit1<-sem(model2,data=IDASem, group = "Dataset", group.equal = c("intercepts", "loadings", "means", "residuals", "lv.variances", "lv.covariances", "residual.covariances", "regressions"))
summary(fit1, standardized = TRUE, fit.measures = TRUE, rsq = TRUE)

Patrick (Malone Quantitative)

unread,
Dec 15, 2020, 1:18:28 PM12/15/20
to lav...@googlegroups.com
Yuthika,

The multiple-group model, whether constrained or unconstrained, is probably the best way to "control" for dataset source.

If the constrained model does not fit, it indicates heterogeneity by dataset source, which is important to note in a meta-analysis.

However, allowing heterogeneity in the means and intercepts of a path analysis still controls for dataset source, in the sense of applying it as a covariate. If a model with means and intercepts freed fits well, you can still interpret the constrained path coefficients (and therefore the indirect effects) as being homogenous across studies. So I suggest checking that next.

The reason you're only getting one set of indirect effects is that the label constraints are applied across groups. So for indirect_sup, a1 is the a path for all groups because of the way you constrained it in the ~ regression part of the formula--with only one label--and similar for b1. You'd have to have different labels for the paths in different groups to get varying indirect effects, and manage the constraints to equality separately.

Hope that helps,
Pat

Yuthika Girme

unread,
Dec 15, 2020, 1:48:40 PM12/15/20
to lavaan
Gotcha! That all makes sense. Thank you SO much for your help, Pat! :) 
Reply all
Reply to author
Forward
0 new messages