MonteCarlo simulation for moderated mediation sample size

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
Best regards
Log in or register to post comments
In reply to If only I could make myself by blazej
what's the question?
Log in or register to post comments
In reply to what's the question? by jpritikin
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*W*Z), 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?
Log in or register to post comments
In reply to Good morning, by blazej
MV
Log in or register to post comments
In reply to MV by jpritikin
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?
Log in or register to post comments
In reply to Oh my... by blazej
moderation
Log in or register to post comments
In reply to MV by jpritikin
I don't think any of the
Log in or register to post comments
Are you confused about exogenous predictors?
Log in or register to post comments
Now I'm sort of confused -
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"?
Log in or register to post comments
In reply to Now I'm sort of confused - by blazej
power sim
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.
Log in or register to post comments