Announcement

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

  • sem/gsem extremely slow

    Hello

    I wonder... is there any way to increase the speed in Stata's SEM or gSEM analyses? Every time I try -sem- og -gsem- I give up due to speed issues. Admittedly, I don't do many simple SEM analyses.

    For instance: a multilevel CFA (one latent factor with three indicators across 28 groups, but mind you: N = 50,000) takes forever and I give up, cancel the estimation and see no point in developing the model further. For comparison: Mplus takes less than 3 seconds to estimate the same model!

    Code:
    gsem (Factor M1[country] -> q1 q2 q3)


  • #2
    PS. I guess I could in general use starting values to reduce the time necessary to achieve convergence. However, I don't think that should be necessary in such a strait-forward model. The three indicators are positively correlated, so no need to start one with a negative loading.

    Comment


    • #3
      This is my biggest complaint too. I love sem but it can be painfully slow compared to mplus. I've heard that gsem may be even worse. Dramatically speeding up sem/gsem is definitely on my wish list for the future.

      You might try playing around with the -technique- option, e.g. technique(nr 25 bhhh 25) . I've found that changing the techniques used sometimes makes dramatic differences. You can also try adding the -difficult- option.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      Stata Version: 17.0 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        Thanks a lot, a very helpful answer! So it's not me entering the wrong code, instead Stata seems to have problems with SEM. I will have a look at -technique- and -difficult-.

        Comment


        • #5
          It is always possible that your coding is sub-optimal. But I have replicated models that mPlus ran in minutes or even seconds that took several hours with Stata (if they ran at all). I don't think it is just me (or you) as I have heard others say the same thing. If you can get it to run though, Stata is great. You may just need to be patient and/or try out different maximization options. Sometimes Stata gets stuck when using one technique but then gets unstuck when it switches to another. There are some other Stata routines that are basically shells for SEM and I understand they can sometimes have the same problems. If Stata can ever match mPlus's speed it will be spectacular (but I've also heard that SAS can be pretty slow too compared to mPlus -- the authors of mPlus must have put a lot of effort into developing efficient algorithms.)
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          Stata Version: 17.0 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://www3.nd.edu/~rwilliam

          Comment


          • #6
            ... and Mplus offers much more in the context of latent variables and Bayes...
            I'm vary happy to have Stata as a basis, even for running Mplus. I think the limitations in Stata and Mplus are quite different, so the two apps supplement each other. I would still like to import graph files from Mplus to Stata. Cannot do that, we need to use R to complement Mplus when developing plots.

            For your wish list for Stata:

            - Speed, yes!!
            - Bayes for more advanced models (e.g. SEM and multilevel SEM)?
            - SEM diagrams as output rather than as input?

            Comment

            Working...
            X