Announcement

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

  • Structural equation modeling: xtdpdml versus gsem in the case of joint estimation

    Dear colleagues,

    I would like to jointly estimate the two questions below, can xtdpdml be used to do so given that my data is panel and that I am interested in estimating a fixed effects model?

    Y = b1X1 + b2X2 + b3X3 + b4Z + a(i)
    X3 = c1X1 + c5X5 + c4Z + a(i)

    I am familiar with xtdpdml through the discussion links below. As far as I understand, it estimates one equation at a time. Is this correct? And if so, is gsem more appropriate to jointly estimate the two equations?

    https://www3.nd.edu/~rwilliam/dynamic/index.html
    https://www.statalist.org/forums/for...on-models-2009

    Any help would be appreciated. Thanks!

    Best regards,
    Amira

  • #2
    xtdpdml can output its generated code to a file, which you can hand tweak. It may be hard to get the code right though, as it is easy to make mistakes, which is why xtdpdml was written in the first place.

    I wonder if you need to though. You aren't showing any reciprocal causation between X3 and Y. What would be so bad about estimating the equations separately?

    Usually, xtdpdml includes lagged Y, but that isn't mandatory. However, "With a strongly balanced panel, no missing data and no effect of lagged y, xtdpdml produces results that are almost identical to xtreg." See pps. 312-313 of https://journals.sagepub.com/doi/pdf...867X1801800201. So, you might just be able to use xtreg.

    In short, I wonder if you need to make things as complicated as you do. But if you do, I suspect you should have xtdpdlm write out the code separately for both models, and then figure out how to combine the two. This may not be easy, but trying to write all the code from scratch in gsem could be a real nightmare.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 18.5 MP (2 processor)

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

    Comment


    • #3
      Thank you Richard Williams. The challenge is that my two outcome variables are binary/categorical. I would also like to include a latent variable to attenuate omitted variable bias. I did so before using gsem but my data was cross-sectional then.

      Can I use xtdpdml to run the gsem command below but with fixed effects? Or can gsem itself be used with fixed effects? Any advice is highly appreciated.

      Code:
      gsem (Y <- i.worry_c i.worry_e i.gender i.marital age i.income_quartile i.income_change i.food_change i.unemp_all i.educ i.urban L@1, family(ordinal) link(logit))///
          (W <- i.worry_c i.Y W_peer i.gender i.marital age i.income_quartile i.educ i.urban L, family(bernoulli) link(logit)),///
          vce(robust) latent(L) var(L@1) nocapslatent difficult

      Comment


      • #4
        Hi Amira. Those are major modifications to your original question. xtdpdml is for continuous dependent variables, not binary or categorical. I imagine you can code what you want in gsem, but it won't be easy to do. Good luck with it.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 18.5 MP (2 processor)

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

        Comment


        • #5
          Hi Amira. Here are some slides that you might find useful. They're from my short course on Longitudinal Data Analysis Using SEM.

          LDA-SEM-Dichotomous.pdf

          Paul Allison
          Statistical Horizons
          www.statisticalhorizons.com

          Comment


          • #6
            Paul Allison Many thanks for sharing this material with me. This is very useful. I have probed deeper into the codes and did many trials for jointly estimating the two equations below with fixed effects.

            y = wc1 + m + y_peer + controls_set1 + a(i)
            m = wc1 + we1 + controls_set2 + a(i)

            I could estimate each equation separately with fixed effects, but not jointly. Please see codes below. Any clue how I can jointly estimate the two equations? As it appears, the variable M appears twice (I do not consider the effects as reciprocal though).

            Code:
                gsem ///
                (y1 <- wc1@a m1@b y_peer1@c gender@d marital@e age@f income_quartile@g educ@h urban@i Alpha@1, logit) ///
                (y2 <- wc2@a m2@b y_peer2@c gender@d marital@e age@f income_quartile@g educ@h urban@i Alpha@1, logit) ///
                (y3 <- wc3@a m3@b y_peer3@c gender@d marital@e age@f income_quartile@g educ@h urban@i Alpha@1, logit) ///
                (y4 <- wc4@a m4@b y_peer4@c gender@d marital@e age@f income_quartile@g educ@h urban@i Alpha@1, logit) ///
                (Alpha <- wc* m* y_peer*)
                
                gsem ///
                (m1 <- wc1@j we1@k gender@l marital@m age@n income_quartile@o income_change1@p food_change1@q unemp_all1@r educ@s urban@t Alpha@1, ologit) ///
                (m2 <- wc2@j we2@k gender@l marital@m age@n income_quartile@o income_change2@p food_change2@q unemp_all2@r educ@s urban@t Alpha@1, ologit) ///
                (m3 <- wc3@j we3@k gender@l marital@m age@n income_quartile@o income_change3@p food_change3@q unemp_all3@r educ@s urban@t Alpha@1, ologit) ///
                (m4 <- wc4@j we4@k gender@l marital@m age@n income_quartile@o income_change4@p food_change4@q unemp_all4@r educ@s urban@t Alpha@1, ologit) ///
                (Alpha <- wc* we* income_change* food_change* unemp_all*)
            I am trying to estimate a system similar to the one in the attached figure.

            gsem.png

            Comment


            • #7
              Thank you Richard Williams. Apologies, my equations were not clear enough at the beginning. I have re-written the equations and the proposed gsem code in my previous post. Hope it works! And please let me know if you have any thoughts.

              Comment


              • #8
                Dear colleagues. A follow-up question, please: does the gsem code below correspond to a panel fixed-effects model? My data is extracted from three waves (three time points). Please note that m appears twice in the equations system. Or should I have to transfer my data to wide format and use a separate gsem line for each wave (time point) (see gsem code in my previous post)? Your advice is much appreciated.

                Code:
                gsem (y <- m x1 x2 i.t L[id]@1, logit) ///
                    (m <- x1 x3 x4 x5 i.t M[id]@1), ///
                    vsquish nolog nonrtolerance

                Comment

                Working...
                X