# Sample size simulation, based on previous studies results - moderated mediation

72 views

### Błażej Mroziński

Feb 20, 2019, 8:00:32 AM2/20/19
to lavaan
Greetings,

I'm trying to find a (hopefully citable) method of estimating a minimal sample size to discover a conditional indirect effect at power .80.

I was hoping anyone could help me out with this.

For instance: I have results (lavaan object) from a study where moderated mediation was hypothesized and tested (https://groups.google.com/d/topic/lavaan/YWOGI4uH2bQ/discussion). The original X was a between subject experimental condition with two levels.

First of all I'd like to compute the observed power of observing an effect in the data I have.
I was trying to play with simsem library for this but failed with it's syntax.

Than, based on the model paramters I'd like to estimate the sample size to discover an effect of a given magnitude in future study, where I'll slightly change my experimental conditions and assume conservatively smaller effect.

Is there any easy to use way, to take a lavaan fitted object and run sample size simulations from it?

### Terrence Jorgensen

Feb 21, 2019, 3:30:48 PM2/21/19
to lavaan
Is there any easy to use way, to take a lavaan fitted object and run sample size simulations from it?

example(cfa)
simulateData
(model = parTable(fit), sample.nobs = 5)

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

### Błażej Mroziński

Feb 21, 2019, 4:04:03 PM2/21/19
to lavaan
As I'm the one bothering you on simsem github - I'll add that one of the variables in this model
is a product term from other two computed before running the model.

### Terrence Jorgensen

Feb 21, 2019, 4:09:11 PM2/21/19
to lavaan
As I'm the one bothering you on simsem github - I'll add that one of the variables in this model
is a product term from other two computed before running the model.

Thanks for linking to the many threads you have here and there.  I'll add this link, where I explain that this is not easy in the case of moderation.  Because SEM is built to be linear, you need to generate data sequentially to properly include interaction effects in your population model.