# Estimating error variance for simulated path analysis

I want to run a simulation using lavaan and simsem to determine the sample size to use in a study using path analysis. The conceptual model for my study is as below, with 2 independent variables, 1 mediator and 2 moderators.

From what I understand, the corresponding statistical model is as below:

I am following the reference book suggested in this answer for how to run the simulation (Latent Variable Modeling Using R: A Step-by-Step Guide by A. Alexander Beaujean). I would like to estimate the error variance of M and Y to use in the simulation. However, the book only provides a method for estimating error variance for a simple regression (i.e, 1-R^2, using path tracing rules). How can I calculate error variances in my case?

Var(error) = Var(Y)*(1 - R^2),

where Y is the dependent variable (M and Y in your model) in a given regression equation.

I would like to estimate the error variance of M and Y

You are running a simulation, so can specify whatever population values you want for the error variances. I assume you mean that you would like to determine what the residual variance would be in order to yield a population total variance = 1? (e.g., so that paths are interpreted as standardized in the population)

Not sure if you are using the matrix-style specification, but if so, you can use findFactorResidualVar() to determine the residual variance that yields whatever total variance you want. There is an example of its use in this tutorial article, which discusses only slightly simpler models than the one you are simulating:

https://doi.org/10.3758/s13428-022-01996-0

• Very useful function. Spent quite a bit of time agonizing over this problem the last two days. Thanks! Dec 14, 2023 at 14:34