Announcement

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

  • sem vs. mixed

    Hi, all

    I have a model using sem() that I'm interested (for pedestrian reasons) in implementing using mixed().

    The latent variable is hospital quality (L1), and I've got a series of indicators of the latent for each hospital:

    sem (indicatorScore1<-L1) (indicatorScore2<-L1) (indicatorScore3<-L1) (indicatorScore4<-L1) (indicatorScore5<-L1) (indicatorScore6<-L1) (indicatorScore7<-L1) (indicatorScore8<-L1), method(mlmv)

    After reshaping the data to long, I've tried a few approaches using mixed, including:

    mixed indicatorScore i.indicatorId || hospital_id:

    This is yielding results that are different and less plausible than the SEM implementation, so I'm wondering if anyone has thoughts on matching the SEM results with mixed().

    Thanks.





  • #2
    A replicable example would help. Just off the top of my head, I am guessing that
    • The sem model will take into acct the covariances of the indicators while the mixed model will not
    • mlmv will cause sem to do something about missing data while mixed will not
    p.206 of Acock discusses "Reconciling the sem command with the mixed command." Perhaps it would help. The sem manual also talks about the mixed command a bit.

    https://www.stata.com/bookstore/disc...g-using-stata/
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

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

    Comment


    • #3
      Richard,

      Thanks for the reply. Here's an example, using the U.S. National Longitudinal Study of Young Women 1988 extract. Let's say we're trying to measure a latent variable thought to be employment security, or something along those lines.

      webuse nlsw88.dta

      keep idcode wage hours ttl_exp tenure

      sem (wage<-L1) (hours<-L1) (ttl_exp<-L1) (tenure<-L1), method(mlmv)

      rename (wage hours ttl_exp tenure) indicatorScore#, addnumber

      reshape long indicatorScore, i(idcode) j(indicator)

      mixed indicatorScore i.indicator || idcode:

      After running this, it's apparent that the betas are not remotely similar.

      I should also add that I'd like to find a way using mixed to shape the error term so that it has the same variance across idcode within a given indicator, but different variance across indicators.

      Comment


      • #4
        Geoff,

        The random intercept model is identical to the SEM model where all the loadings are fixed to 1. If you change the the -sem- syntax to:

        Code:
        webuse nlsw88.dta
        keep idcode wage hours ttl_exp tenure
        sem (wage@1<-L1) (hours@1<-L1) (ttl_exp@1<-L1) (tenure@1<-L1), method(mlmv)
        Then change the -mixed- syntax to:

        Code:
        rename (wage hours ttl_exp tenure) indicatorScore#, addnumber
        reshape long indicatorScore, i(idcode) j(indicator)
        mixed indicatorScore ibn.indicator, nocons || idcode: , residuals(ind, by(indicator))
        You can constrain the residual variances from the -sem- model to be equal. If you do that, you don't need to use the residuals command in -mixed-.

        Best,
        Scott

        Comment


        • #5
          Hi, Scott. Thanks for this. Is there a way to do it without constraining the loadings? They are actually a key piece of the analytic question.

          Comment


          • #6
            The fit of the sem model is horrendous --

            LR test of model vs. saturated: chi2(5) = 205.95, Prob > chi2 = 0.0000

            If you drop the equality constraints,

            LR test of model vs. saturated: chi2(2) = 18.58, Prob > chi2 = 0.0001

            And, it makes no sense to me that the factor loadings would be equal when the variables are measured in such radically different ways. I don't use mixed, so maybe this all makes sense to someone who does, but it seems like a very peculiar model to me.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

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

            Comment


            • #7
              I use -mixed- frequently, though I never use it to simulate SEM. But just thinking about the modeling, it seems you could unconstrain the loadings in -mixed- by including random slopes for the indicators at the idcode: level. Since you can't use factor notation for the random-effects part of -mixed- syntax that means you would have to generate them, so something like this:

              Code:
              forvalues j = 2/4 {
                  gen indicator`j' = `j'.indicator
              }
              mixed indicatorScore indicator?, nocons || idcode: indicator?, residuals(ind, by(indicator))
              Again, I don't normally use -mixed- for this purpose, so I may be off base here, but it seems to represent the same underlying model as the -sem- based CFA.

              Comment


              • #8
                Oops! Not enough caffeine yet. I retract the last post. What I wrote is not at all equivalent to the -sem- model. In fact, what I wrote would be an unidentified model. Sorry.

                Comment


                • #9
                  Hi Geoff,

                  I'm not totally sure what you are asking. If you mean, can you fit the model in -mixed- without constraining the loadings, then no you can't. I think the key thing to keep in mind here is that the random intercept model is identical to a single factor model with loadings all equal to one. You said in a previous post that "it's apparent that the betas are not remotely similar." You didn't the same parameters in your -sem- and -mixed- models. In the -sem- model you fit factor loadings (regression of an observed variable onto a latent variable) and in the -mixed- model you regressed the observed variable onto an indicator variable (so you are getting mean differences between the indicators on the outcome). The factor loadings in the -mixed- model are implicit and equal to 1 and there is no way to relax them with -mixed- command. (I believe PROC MIXED in SAS has a factor analytic structure).

                  So I think the short answer is that if what you really want is factor loadings than use -sem- or -gsem-.

                  Scott

                  Comment


                  • #10
                    Hi, all. Thanks for the input on this. It seems like -sem- may be the more appropriate tool here, as I do need the factor loadings. The other key piece of the analysis is setting up the error term so that it has the same variance across idcode within a given indicator, but different variance across indicators. After reading the various ways to handle error variances in the manual, I'm not entirely clear on how to implement this.

                    Comment

                    Working...
                    X