Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • simulation, sem and fit indices

    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:

    Code:
    * Set up of the steps to be repeated for the simulation in a program
    program 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
    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

  • #2
    Your program does not return r(rmsea) and r(srmr). Those are returned by -sem- itself. Your program captures them and then returns them as r(RMSEA) and r(SRMR), respectively. These references are case sensitive. Your -simulate- command cannot reach down to what -sem- returns: it can only pick up what myprogram returns. So you have to change your simulate command to:

    Code:
    simulate y_by_x1 = [y]_b[x1] y_by_x2 = [y]_b[x2] RMSEA = r(RMSEA) SRMR = r(SRMR), reps(100) nodots: myprogram
    If you do that, you will now get your RMSEA and SRMR results.

    But, of course, since you are running -sem- on a fairly large sample of a very simple model using simulated data generated by the exact process that your -sem- models, all of these RMSEA and SRMR values are going to be extremely close to zero.

    Comment


    • #3
      Thank you very much for taking the time.
      I wish the RMSEA and SRMR values were close to zero for my real model

      Comment

      Working...
      X