Multiple Treatments and Mediated Moderation in the same Model

155 views
Skip to first unread message

Chris

unread,
Jul 14, 2015, 12:00:41 PM7/14/15
to lav...@googlegroups.com
Hello

Sorry if this question mirrors some earlier questions, but I have not had any luck combining the various answers to the previous questions.  I am still learning Lavaan, so I may well be missing something very obvious. 

I am trying to analyze the results of a 3x2 factorial experiment, where the outcome of interest should be influenced by the interaction between one of the treatments and a mediated variable that is driven by the second treatment)

Specifically , I have treatment 

Exogenous Treatments
X1 (Information)  (two levels)
X2 (Frame)   (three levels)

Mediator
M (Mood)  , influenced by X2

Outcome 
Y(Evaluation) 

The hypothesis I am trying to test is that Y is the result of the interaction between X1 and M, which is in turn driven by X2, so 

Y~X1*M

M~X2

But I am not sure how to properly estimate this model using Lavaan

I have tried to estimate this model in two ways:

a) Use X1 as a grouping factor. This is problematic though, because it doesn't really let me give a good estimator of the marginal effect of moving between the two groups moderated by M

b) Specify an Interaction Term X1*M in advance. But here I am not sure how to code it in such a way that the interaction also captures the fact that X2 has an impact on M

I am probably missing something very obvious, but I would appreciate a pointer on how to best go about fixing this model. 

Thanks!
Chris


Yves Rosseel

unread,
Jul 16, 2015, 5:31:18 AM7/16/15
to lav...@googlegroups.com
On 07/14/2015 06:00 PM, Chris wrote:
> Y~X1*M

Unlike functions like lm(), lavaan does not use the '*' operator for
specifying interactions.

Since X1 seems to be binary, you can compute the product term 'X1 * M',
and add it to your data.frame (say, myData):

myData$X1M <- myData$X1 * myData$M

Then, you have a new variable 'X1M' in your data, representing the
interaction, and you can write in the lavaan syntax

Y ~ X1 + M + X1M
M ~ X2

Yves.

Chris

unread,
Jul 17, 2015, 5:31:05 AM7/17/15
to lav...@googlegroups.com
Hi Yves

Thank you for the response. Just to clarify though: By specifying the interaction in advance, how can I ensure that the path model accounts for the effect of the second treatment on the "main effect " and on the interaction. 

So in your example, do I need to specify both 

M~X2 (the effect of the treatment on the main effect) 

and 

X1M~X2 ? 

Thank you,
Chris

Terrence Jorgensen

unread,
Jul 17, 2015, 7:38:56 AM7/17/15
to lav...@googlegroups.com
I have tried to estimate this model in two ways:

a) Use X1 as a grouping factor. This is problematic though, because it doesn't really let me give a good estimator of the marginal effect of moving between the two groups moderated by M


Wouldn't the marginal effect of M on Y be estimated by a model with equality constraints on the effect of M on Y across groups (X1)?

Y ~ c(b, b)*M

That model would be nested within the model without the equality constraint, and the chi-squared difference test would be a test of the H0 that interaction == 0.  Assuming you have large enough sample sizes in each group, another advantage of the multiple-groups approach would be that the marginal effect of M on Y from the constrained model could be estimated without assuming homogeneity of error variances across groups, which the use of a dummy variable would have to assume. 

Terry

Yves Rosseel

unread,
Jul 20, 2015, 8:08:29 AM7/20/15
to lav...@googlegroups.com
On 07/17/2015 11:31 AM, Chris wrote:
> Thank you for the response. Just to clarify though: By specifying the
> interaction in advance, how can I ensure that the path model accounts
> for the effect of the second treatment on the "main effect " and on the
> interaction.
>
> So in your example, do I need to specify both
>
> M~X2 (the effect of the treatment on the main effect)
>
> and
>
> X1M~X2

Hm. The second one is optional, and depends on your theory. Two
alternatives are:

- regress X2 out before you construct the product term X1M
- use a multiple group approach (as Terry suggested).

Yves.


Chris

unread,
Jul 27, 2015, 6:23:48 AM7/27/15
to lavaan, yros...@gmail.com
Hi Yves, Hi Terrence

Thank you for your replies. The Multigroup approach worked out well, so thank you for the pointer. A follow up question, though I am not sure if this is the right place to post it since it is more concerned with the semPlot package than with lavaan. 

Anyways, when I try to build a path diagram of the results using multigroups and constrained coefficients, semPaths breaks down and simply gives me the error message 

"Error in data.frame(label = pars$label, lhs = ifelse(pars$op == "~" |  : 
  arguments imply differing number of rows: 36, 1, 38"

If I do not constraint coefficients across groups, semPaths works fine. I have contacted the author of the package but have not heard back from him , so I am wondering if anyone else has had similar issues? 

Alternatively, are there any other options for automatically generating path diagrams from lavaan models?

Thank you,
Chris

Marcos Angelini

unread,
Nov 2, 2015, 5:57:50 AM11/2/15
to lavaan
Hi everybody.

I have this model:

model <- '
# measurement model
tb.Ar =~ 1*tb.A
sat.Ar =~ 1*sat.A
btr =~ 1*bt
oc.Ar =~ 1*oc.A
thick.Ar =~ 1*thick.A
esp.Br =~ 1*esp.B
esp.Ar =~ 1*esp.A

# structural model
tb.Ar ~     evim + evisd + lstm + lstsd + dem + wdist + mrvbf + vdchn + twi + river +
            oc.Ar + btr
sat.Ar ~    evim + evisd + lstm + lstsd + dem + wdist + mrvbf + vdchn +  twi + river +
            tb.Ar + oc.Ar                           
btr ~       lstm +  lstsd + wdist + vdchn + twi + dem + river + mrvbf +
            b*esp.Br + b*esp.Ar
oc.Ar ~     lstm +  lstsd + evim + evisd + dem + wdist + mrvbf + vdchn + twi +
            a*esp.Br + a*esp.Ar + btr + thick.Ar
esp.Ar ~    lstm +  lstsd + dem + wdist + mrvbf + vdchn + twi + river + evisd +
            esp.Br
esp.Br ~    lstm +  lstsd + dem + wdist + mrvbf + vdchn + twi + river + evisd
           
thick.Ar ~  dem + wdist + mrvbf + vdchn + twi + river + slope + maxc + evim + evisd


# measurement error
thick.A ~~  0.25*thick.A
tb.A ~~     0.20*tb.A
sat.A ~~    0.20*sat.A
bt  ~~      0.25*bt
oc.A ~~     0.20*oc.A
esp.B ~~    0.10*esp.B
esp.A ~~    0.20*esp.A
'
The model converge well, but when I run the function summary(model, standardized=F, modindices = T, fit.measures=F), I get this error
Modification Indices:

Error in data.frame(lhs = c("tb.Ar", "sat.Ar", "btr", "oc.Ar", "thick.Ar",  :
  arguments imply differing number of rows: 177, 175

If I not constrain the coefficients, the function works well. Same happens with package semPlot:

Error in data.frame(label = pars$label, lhs = ifelse(pars$op == "~" |  :
  arguments imply differing number of rows: 173, 1, 175

Any suggestion?

Thanks,
Marcos
Reply all
Reply to author
Forward
0 new messages