Announcement

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

  • Can SEM be used with survey longitudinal panel data?

    Hi folks, I am new to SEM and I am thinking of using SEM on a survey panel data. But I am not sure whether it makes sense to do so. So the data I have is a longitudinal one with three waves. I basically have four major questions here:

    1. Whether SEM could be used with survey panel data? If yes, how could I account for the longitudinal structure of the data? For instance, I have an DV which is student's reading outcome and I have IVs such as teacher race and family SES. The mediator I have is teacher evaluated student behavior. Since all of those variables i mentioned are changing across waves except for race, how could SEM handle this?
    2. What format of data should I prepare in order to use SEM? Long or wide format?
    3. How to use sampling weight? I noticed an option in SEM builder and it seems I can add whatever sampling weight I have there.
    4. Where can I add indirect effect using SEM builder? I didn't find any options from the left bar that allows me to add indirect effect. Is there a way for me to achieve this using SEM builder?

    Thanks!

  • #2
    You may want to look at xtdpdml, available on SSC. Even if it isn't quite what you want it may give you ideas on how to proceed. The support page is at

    https://www3.nd.edu/~rwilliam/dynamic/index.html

    You don't have to read everything on that page, but you may want to look at the examples in sections 2.3 and 4 of

    https://www3.nd.edu/~rwilliam/dynamic/SJPaper.pdf

    xtdpdml has undocumented beta code for using svyset data. If somebody actually wanted to use it I could break down and work on it more.

    Here is the abstract for the paper:

    "Panel data make it possible both to control for unobserved confounders and to include lagged, endogenous regressors. Trying to do both at the same time, however, leads to serious estimation difficulties. In the econometric literature, these problems have been addressed by using lagged instrumental variables together with the generalized method of moments (GMM), while in sociology the same problems have been dealt with via maximum likelihood estimation and structural equation modeling. While both approaches have merit, we show that the ML (SEM) method is substantially more efficient than the GMM method when the normality assumption is met, and it also suffers less from finite sample biases. We introduce a command named xtdpdml with syntax similar to other Stata commands for linear dynamic panel-data estimation. xtdpdml greatly simplifies the SEM model specification process; makes it possible to test and relax many of the constraints that are typically embodied in dynamic panel models; allows for the inclusion of time-invariant variables in the model, unlike most related methods; and takes advantage of Stata's ability to use full information maximum likelihood for dealing with missing data. The strengths and advantages of xtdpdml are illustrated via examples from both economics and sociology."

    Remember too that the me commands can estimate many of the same models the xt commands can, and can include weights. My very brief and under-developed discussion of this is at

    https://www3.nd.edu/~rwilliam/stats3/Multilevel.pdf

    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

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

    Comment


    • #3
      Hi Rich, thanks for your reply. I will look into the command you wrote. At this moment, could you please help take a look at an error message I got from Stata when fitting a sem model? My syntax is as follows:

      Code:
      . svy: sem (lw1 <- I@1 S@1 _cons@0) ///
      >                  (lw2 <- I@1 S@2 _cons@0) ///
      >                  (lw3 <- I@1 S@3 _cons@0), ///
      >                  var(e.lw1@var e.lw2@var e.lw3@var) ///
      >                  means(I S)
      (running sem on estimation sample)
      
      BRR replications (32)
      ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
      ................................
      
      Survey: Structural equation model               Number of obs      =      2493
                                                      Population size    = 1962331.7
                                                      Replications       =        32
                                                      Design df          =        31
      
       ( 1)  [lw1]I = 1
       ( 2)  [lw1]S = 1
       ( 3)  [lw2]I = 1
       ( 4)  [lw2]S = 2
       ( 5)  [lw3]I = 1
       ( 6)  [lw3]S = 3
       ( 7)  [var(e.lw1)]_cons - [var(e.lw3)]_cons = 0
       ( 8)  [var(e.lw2)]_cons - [var(e.lw3)]_cons = 0
       ( 9)  [lw1]_cons = 0
       (10)  [lw2]_cons = 0
       (11)  [lw3]_cons = 0
      ------------------------------------------------------------------------------
                   |                BRR *
                   |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      Measurement  |
        lw1 <-     |
                 I |          1   8.88e-16  1.1e+15   0.000            1           1
                 S |          1   2.22e-16  4.5e+15   0.000            1           1
             _cons |          0  (constrained)
        -----------+----------------------------------------------------------------
        lw2 <-     |
                 I |          1   1.33e-15  7.5e+14   0.000            1           1
                 S |          2  (constrained)
             _cons |          0  (constrained)
        -----------+----------------------------------------------------------------
        lw3 <-     |
                 I |          1  (constrained)
                 S |          3  (constrained)
             _cons |          0  (constrained)
      -------------+----------------------------------------------------------------
            mean(I)|   463.2201    3.19975   144.77   0.000     456.6941     469.746
            mean(S)|   12.17015   .7721601    15.76   0.000     10.59532    13.74498
      -------------+----------------------------------------------------------------
         var(e.lw1)|   115.3131   20.26957                      80.57178    165.0344
         var(e.lw2)|   115.3131   20.26957                      80.57178    165.0344
         var(e.lw3)|   115.3131   20.26957                      80.57178    165.0344
             var(I)|   1311.705   173.2876                      1001.892     1717.32
             var(S)|   38.90967   14.27239                      18.41439    82.21627
      -------------+----------------------------------------------------------------
           cov(I,S)|  -103.3668   40.18819    -2.57   0.015    -185.3311   -21.40241
      ------------------------------------------------------------------------------
      
      .                  
      . mat b = e(b)
      
      . 
      . svy: sem (lw1 <- I@1 S@1 _treated1@b1 _cons@0) ///
      >                  (lw2 <- I@1 S@2 _treated2@b1 _cons@0) ///
      >                  (lw3 <- I@1 S@3 _treated3@b1 _cons@0), ///
      >                  var(e.lw1@var e.lw2@var e.lw3@var) ///
      >                  means(I S) covar(_treated1*I@0 _treated2*I@0 _treated3*I@0) ///
      >                  covar(_treated1*S@0 _treated2*S@0 _treated3*S@0) ///
      >                  from(b) iterate(100)
      (running sem on estimation sample)
      
      BRR replications (32)
      ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
      ...............x................
      
      Survey: Structural equation model               Number of obs      =        13
                                                      Population size    =   8849.24
                                                      Replications       =        28
                                                      Design df          =        27
      
       ( 1)  [lw1]_treated1 - [lw3]_treated3 = 0
       ( 2)  [lw1]I = 1
       ( 3)  [lw1]S = 1
       ( 4)  [lw2]_treated2 - [lw3]_treated3 = 0
       ( 5)  [lw2]I = 1
       ( 6)  [lw2]S = 2
       ( 7)  [lw3]I = 1
       ( 8)  [lw3]S = 3
       ( 9)  [var(e.lw1)]_cons - [var(e.lw3)]_cons = 0
       (10)  [var(e.lw2)]_cons - [var(e.lw3)]_cons = 0
       (11)  [lw1]_cons = 0
       (12)  [lw2]_cons = 0
       (13)  [lw3]_cons = 0
      ------------------------------------------------------------------------------
                   |                BRR *
                   |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      Structural   |
        lw1 <-     |
         _treated1 |   54.85578   72.37401     0.76   0.455    -93.64343     203.355
                 I |   .7861651   1.67e-08  4.7e+07   0.000     .7861651    .7861652
                 S |          1   4.44e-16  2.3e+15   0.000            1           1
             _cons |          0  (constrained)
        -----------+----------------------------------------------------------------
        lw2 <-     |
         _treated2 |   54.30569   72.37401     0.75   0.460    -94.19352    202.8049
                 I |          1  (constrained)
                 S |          2  (constrained)
             _cons |          0  (constrained)
        -----------+----------------------------------------------------------------
        lw3 <-     |
         _treated3 |   54.48905   72.37401     0.75   0.458    -94.01015    202.9883
                 I |          1  (constrained)
                 S |          3  (constrained)
             _cons |          0  (constrained)
      -------------+----------------------------------------------------------------
            mean(I)|   530.2289   1.70e+30     0.00   1.000    -3.50e+30    3.50e+30
            mean(S)|  -19.04594   7.33e+29    -0.00   1.000    -1.50e+30    1.50e+30
      -------------+----------------------------------------------------------------
         var(e.lw1)|   156.1881   622.6446                      .0437804    557207.1
         var(e.lw2)|   156.1881   622.6446                      .0437804    557207.1
         var(e.lw3)|   156.1881   622.6446                      .0437804    557207.1
             var(I)|   810.8809   994.0654                      65.54688    10031.41
             var(S)|   1.03e-13   13.69389                             .           .
      -------------+----------------------------------------------------------------
           cov(I,S)|  -79.99356   269.8298    -0.30   0.769    -633.6385    473.6514
      ------------------------------------------------------------------------------
      Note: One or more parameters could not be estimated in 4 BRR replicates;
            standard-error estimates include only complete replications.
      Warning: convergence not achieved
      
      . 
      . mat b = e(b)
      
      . mat list b
      
      b[1,20]
                  lw1:         lw1:         lw1:         lw1:         lw2:         lw2:         lw2:         lw2:
            _treated1            I            S        _cons    _treated2            I            S        _cons
      y1    54.855777    .78616513            1            0    54.305689            1            2            0
      
                  lw3:         lw3:         lw3:         lw3:     mean(I):     mean(S):  var(e.lw1):  var(e.lw2):
            _treated3            I            S        _cons        _cons        _cons        _cons        _cons
      y1    54.489052            1            3            0    530.22892   -19.045936    156.18812    156.18812
      
           var(e.lw3):      var(I):      var(S):    cov(I,S):
                _cons        _cons        _cons        _cons
      y1    156.18812    810.88088    1.031e-13   -79.993562
      
      . mat b[1,20]= -200
      
      . 
      . svy: sem (lw1 <- I@1 S@1 _treated1@b1 _cons@0) ///
      >                  (lw2 <- I@1 S@2 _treated2@b1 _cons@0) ///
      >                  (lw3 <- I@1 S@3 _treated3@b1 _cons@0), ///
      >                  var(e.lw1@var e.lw2@var e.lw3@var) ///
      >                  means(I S) covar(_treated1*I@0 _treated2*I@0 _treated3*I@0) ///
      >                  covar(_treated1*S@0 _treated2*S@0 _treated3*S@0) ///
      >                  from(b)
      (running sem on estimation sample)
      initial values not feasible
      an error occurred when svy executed sem
      an error occurred when brr executed sem
      r(1400);
      
      end of do-file
      I tried to modify the value in one of the parameters but still the model fails to run. The variable _treated is a time-varying variable.

      Comment


      • #4
        Does the model run ok if you don't use svy? I would make sure you were ok on that front before I got too fancy.

        why are you constraining constants to be zero? That seems odd.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

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

        Comment


        • #5
          Hi Rich, thanks for your reply. I have to have the -svy- prefix because the I am working on a panel data. In terms of why I'm constraining constants to 0, I'm basically following an example found on IDRE website here: https://stats.idre.ucla.edu/stata/fa...tmixed-vs-sem/ The website provides very good examples in that it compares the -mixed- and -sem- model.

          Comment


          • #6
            You need to have the svy: prefix eventually, but that doesn't mean you can't drop it while you are trying to debug your program. If it runs without svy, you'll know there is some problem related to the use of svy. If it still doesn't run even without svy, you'll know there is some problem with your model setup.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            Stata Version: 17.0 MP (2 processor)

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

            Comment


            • #7
              Besides Richard's advice, have you considered Stata's -gsem- (Generalized Structural Equation) command? You can fit random intercept/coefficient model for nested data structure and test the non-linear paths using gsem. gsem also allows weights. See help gsem
              Roman

              Comment


              • #8
                Hi folks, I tried the model without -svy- and it still can't converge. Like Rich said, it may because it's a bad model. How could I adjust the model? To make my questions easier to understand, I would want to fit a -mixed- model like the following:

                Code:
                mixed lw c.age##c.age _treated || StudentID: age age2, pweight(wt_sa1)
                Code:
                mixed lw c.age##c.age _treated gender race || StudentID: age age2, pweight(wt_sa1)
                But for some reasons, I have to use SEM to do a latent growth model. In the link I provided in #5, they provided examples on how to switch between -mixed- and -sem-, but my case is a little bit more complicated in that I have to add some other predictors together in one model instead of adding one at a time. Also a noteworthy point is here all of my predictors are either binary or categorical and i am not sure whether -sem- will be impacted by that. Basically, I want to know how to switch my 2nd mixed model to -sem- model? And if model convergence cannot be achieved, where are the places I should adjust in the -sem- model to make it work?
                Last edited by Man Yang; 01 Oct 2017, 19:47.

                Comment


                • #9
                  Hi all,
                  I am interested to know if I could solve the model so attached using sem. I have a panel data with 80 cross sections and 17-year durations. Can xtdpdml help in coding the attached path diagram using sem. Please let me know your views also advise if there exists any other method that could help me.

                  Click image for larger version

Name:	1.JPG
Views:	1
Size:	13.9 KB
ID:	1469876

                  Comment

                  Working...
                  X