philchalmers / SimDesign

Structure for organizing Monte Carlo simulations in R
http://philchalmers.github.io/SimDesign/
61 stars 18 forks source link

Help: moderated mediation sample size calculation #12

Closed b1azk0 closed 5 years ago

b1azk0 commented 5 years ago

Good morning, I was wondering if anyone could help me out in setting up code for a simulation based sample size estimation?

I'm working with a moderated mediation model (Model 14 as per A.Hayes PROCESS templates), where: X is a dichotomous experimental condition (0 and 1) M is a continuous mediator (mean of discrete 1 to 5 items) V is a continuous mediator (mean of discrete 1 to 5 items) Y is a continuous mediator (mean of discrete 1 to 5 items)

When I was analyzing pilot data I mean centered X, M and V, computed the product of M*V by hand and set the analysis syntax in for example lavaan.

I already learned that I can't run a simulation for sample size using lavaan model syntax in simsem - due to the fact, that I'm introducing a variable being a product of other two variables.

I was wondering if you could help me out in working out syntax for such simulation, where conditional indirect effects are hypothesized, and sample size is estimated based on previous research data. For example:


      lhs op          est mult             rhs
        M  ~  1.202004232    *               X
        Y  ~  0.575722530    *               M
        Y  ~ -0.006049529    *               V
        Y  ~  0.069165295    *             MxV
        Y  ~ -0.030178110    *               X
        M ~~  0.615693995    *               M
        Y ~~  0.361699422    *               Y
        X ~~  0.249909489    *               X
        X ~~  0.028958249    *               V
        X ~~ -0.164863026    *             MxV
        V ~~  2.527681615    *               V
        V ~~ -0.102325584    *             MxV
      MxV ~~  2.918988907    *             MxV
 indirect :=  0.692020918    *            a*b1
   direct := -0.030178110    *               c
      ab3 :=  0.083136978    *            a*b3
       lo :=  0.532131320    * a*(b1+ab3*-1.6)
       av :=  0.692020918    *    a*(b1+ab3*0)
       hi :=  0.851910516    *  a*(b1+ab3*1.6)

These where the model estimates of a pilot study (analyzed with lavaan)

philchalmers commented 5 years ago

This isn't really an issue related to the package, but a request for help. Hence, I'm closing this as off topic.

I'd be happy to help you with this through email, but the first thing I'd recommend is figuring out the required equations that you'd need to generate the data. If you can construct a single example of how to do this with code then a Monte Carlo simulation is just a quick generalization of this base example.