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 moderator (mean of discrete 1 to 5 items)

Y is a continuous outcome (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 template to the following syntax:

# # This model specification was automatically generated by Onyx # require("OpenMx"); modelData <- read.table(DATAFILENAME, header = TRUE) manifests<-c("X","M","Y","V","M_V") latents<-c() model <- mxModel("Unnamed_Model", type="RAM", manifestVars = manifests, latentVars = latents, mxPath(from="X",to=c("M","Y"), free=c(FALSE,FALSE), value=c(1.0,1.0) , arrows=1, label=c("X__M","X__Y") ), mxPath(from="M",to=c("Y"), free=c(FALSE), value=c(1.0) , arrows=1, label=c("M__Y") ), mxPath(from="V",to=c("Y"), free=c(FALSE), value=c(1.0) , arrows=1, label=c("V__Y") ), mxPath(from="M_V",to=c("Y"), free=c(FALSE), value=c(1.0) , arrows=1, label=c("M_V__Y") ), mxPath(from="X",to=c("X"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_X") ), mxPath(from="M",to=c("M"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_M") ), mxPath(from="Y",to=c("Y"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_Y") ), mxPath(from="V",to=c("V"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_V") ), mxPath(from="M_V",to=c("M_V"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_M_V") ), mxPath(from="one",to=c("X","M","Y","V","M_V"), free=F, value=0, arrows=1), mxData(modelData, type = "raw") ); result <- mxRun(model) summary(result)

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 an OpenMx syntax for such simulation, where conditional indirect effects are hypothesized, and sample size is estimated based on previous research data. For example:

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

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)

Based on those values I want to show what would be the sample size required to observe similar effects (ab3, lo, hi) with a power of .8.

Is OpenMx capable of running such thing?

BTW> for what is worth I don't need to use mean aggregates for exogenous variables, as I could construct them from raw item scores as latent variables - if that's of any value...

If only I could make myself clearer or explain anything that might need explaining please let me know. I'm still stuck with this task and honestly don't know how to proceed or re-phrase my google searches to get any closer.

Best regards

How is this different than your earlier question, https://openmx.ssri.psu.edu/node/4450 ?

Good morning,

The difference here is, that (from what ive been told) I need to simulate X and V as exogenous variables, then simulate M as an endogenous variable predicted by X (and whose residuals are correlated with V).

In the earlier example no interactions where involved.

Basically the models I started working on recently are what Andrew Hayes calls model 1 and 3 (moderation, that I can handle as lm(Y~X

WZ), model 4 (simple mediation - as in my earlier question that used latent variables) and model 7 and 14 - moderated mediations.This case is model 14 - like described here: http://offbeat.group.shef.ac.uk/FIO/model14.htm

(I actually bought myself an Mplus licence hoping I can make more sense from their syntax, but failed as well).

To sum up, given what I wrote question is:

How can I run a sample size simulation for a moderated mediation where conditional indirect effects are hypothesized?

Looks like that model has a latent interaction (MV). These kind of models tend to be easier and quicker to estimate in a Bayesian framework like Stan. OpenMx doesn't have good support for latent interactions.

Oh my...

To make sure:

Basically, when analyzing data i simply multiplied M by V, store it as a new variable and used that for model specification. When thinking of simulation this MV becomes a latent variable?

Oh, if you multiply MV and use that as data then you should be okay. It's just a matter of specifying the model in OpenMx. The rest is the same as your prior simulation question.

I don't think any of the variables involved are latent.

I'm still not sure where you are getting stuck. To create an exogenous predictor, you set up a definition variables in a latent variable's mean and set that variable's variance to zero.

Now I'm sort of confused - speaking software irrelevant - what do you think would be the best approach to calculate simulation based sample size for discovering a conditional mediation effect in a model depicted like this one:

http://www.offbeat.group.shef.ac.uk/FIO/images/model14pathdiagram.gif

Following other recommendations (not related to OpenMx) I learned that this can't be done from a single equation for

`y`

since numerically the interaction effect is the product of`M`

and`V`

and I have to account for the fact, that`M`

is explained by`X`

.I admit that I have no prior knowledge or experience with simulations plus I consider myself a newbie modeller (if any). This means, i'm looking everywhere, ask questions (often times phrasing them incorrectly) and try to make the most of what I get in return.

I'm not running a simulational study per se - I just want to feed my experiment with a sample size estimate that can be trusted and explained.

Last but not least - I'm really thankful for all your advices and time spent on understanding "what the hell does he want"?

> Following other recommendations (not related to OpenMx) I learned that this can't be done from a single equation for y since numerically the interaction effect is the product of M and V and I have to account for the fact, that M is explained by X.

I don't see what makes this model any different from any other model. You would assume some distribution for unknowns, simulate possible values, find the power curve, and repeat until you get a distribution of power curves.