Dear all,
I am using a simulation (using the command 'simulate') to obtain parameter estimates of a structural equation model (sem) based on a sample generated with the 'draw norm' command. Although it works for the model coefficients, I am struggling with the fit indices.
In order for you to see exactly what my problem is, I wrote a simplified version of my program that reproduces the problem:
As you can see in the output if you run that code, I am probably doing something wrong in the process of 'collecting' the fit indices (RMSEA and SRMR), but I cannot see what it is. Can anyone help me correct my code?
Thank you for your attention,
Christophe
I am using a simulation (using the command 'simulate') to obtain parameter estimates of a structural equation model (sem) based on a sample generated with the 'draw norm' command. Although it works for the model coefficients, I am struggling with the fit indices.
In order for you to see exactly what my problem is, I wrote a simplified version of my program that reproduces the problem:
Code:
* Set up of the steps to be repeated for the simulation in a programprogram myprogram, rclass * drop of all variables to create an empty dataset drop _all * creation of a vector that contains the equivalent of a lower triangular correlation matrix matrix c = (1, 0.381, 1, 0.259, 0.525, 1) * drawing of a sample of 1000 cases from a normal distribution with specified correlation structure drawnorm x1 x2 y, n(1000) corr(c) cstorage(lower) * model estimation sem (x1 x2 -> y), nocapslatent standardized return scalar y_by_x1 = [y]_b[x1] return scalar y_by_x2 = [y]_b[x2] * fit indices calculation estat gof, stats(all) return scalar RMSEA = r(rmsea) return scalar SRMR = r(srmr) end * use the simulate command to rerun myprogram 1000 times and collect the estimates/indices simulate y_by_x1 = [y]_b[x1] y_by_x2 = [y]_b[x2] RMSEA = r(rmsea) SRMR = r(srmr), reps(100) nodots: myprogram * print the estimates and the fit indices describe * summarize ci mean y_by_x1 y_by_x2 RMSEA SRMR
Thank you for your attention,
Christophe
Comment