Announcement

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

  • Why can't SEM or GSEM produce fixed effects regressions?

    Hi all,

    I have been experimenting with structural equation modelling, and particularly GSEM in longitudinal panel data, and can get it to reproduce standard random effects regressions (i.e. xtreg , re), but not fixed effects regressions (xtreg, fe). I was wondering if there was a theoretical reason for this, or if it just hasn't been implemented yet in Stata? https://www.stata.com/manuals/sem.pdf

    Very best,

    John

  • #2
    Any estimator that can estimate a linear regression model can also estimate a linear fixed effects model. The reason is because the within transformation is equivalent to including \(N-1\) firm dummies (the Frisch-Waugh-theorem).

    Code:
    webuse grunfeld, clear
    xtreg invest mvalue kstock, fe
    gsem (invest <- mvalue kstock i.company)
    Res.:

    Code:
    . xtreg invest mvalue kstock, fe
    
    Fixed-effects (within) regression               Number of obs     =        200
    Group variable: company                         Number of groups  =         10
    
    R-sq:                                           Obs per group:
         within  = 0.7668                                         min =         20
         between = 0.8194                                         avg =       20.0
         overall = 0.8060                                         max =         20
    
                                                    F(2,188)          =     309.01
    corr(u_i, Xb)  = -0.1517                        Prob > F          =     0.0000
    
    ------------------------------------------------------------------------------
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1101238   .0118567     9.29   0.000     .0867345    .1335131
          kstock |   .3100653   .0173545    17.87   0.000     .2758308    .3442999
           _cons |  -58.74393   12.45369    -4.72   0.000    -83.31086     -34.177
    -------------+----------------------------------------------------------------
         sigma_u |  85.732501
         sigma_e |  52.767964
             rho |  .72525012   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(9, 188) = 49.18                     Prob > F = 0.0000
    
    . 
    . gsem (invest <- mvalue kstock i.company)
    
    Iteration 0:   log likelihood =  -1070.781  
    Iteration 1:   log likelihood =  -1070.781  
    
    Generalized structural equation model           Number of obs     =        200
    Response       : invest
    Family         : Gaussian
    Link           : identity
    Log likelihood =  -1070.781
    
    -------------------------------------------------------------------------------
                  |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
    invest        |
           mvalue |   .1101238   .0114955     9.58   0.000      .087593    .1326545
           kstock |   .3100653   .0168258    18.43   0.000     .2770874    .3430433
                  |
          company |
               2  |   172.2025   30.21196     5.70   0.000     112.9882    231.4169
               3  |  -165.2751   30.80755    -5.36   0.000    -225.6568   -104.8935
               4  |    42.4874    42.5722     1.00   0.318    -40.95259    125.9274
               5  |  -44.32013   48.95406    -0.91   0.365    -140.2683    51.62806
               6  |   47.13539   45.38464     1.04   0.299    -41.81687    136.0877
               7  |   3.743212   49.02452     0.08   0.939    -92.34307     99.8295
               8  |   12.75103    42.7106     0.30   0.765    -70.96021    96.46228
               9  |  -16.92558   46.97718    -0.36   0.719    -108.9992      75.148
              10  |   63.72884   48.79697     1.31   0.192    -31.91146    159.3691
                  |
            _cons |  -70.29669   48.19365    -1.46   0.145    -164.7545    24.16114
    --------------+----------------------------------------------------------------
     var(e.invest)|   2617.391   261.7391                      2151.535    3184.115
    -------------------------------------------------------------------------------
    
    .

    Comment


    • #3
      Hi Andrew,

      That's an excellent point, and well taken, but in large sample panel data on individuals sampled repeatedly over several waves, although one could include panel indicators as i.id, when sample sizes approach 10,000 and data is measured over several waves this is computationally too complex to be feasible in GSEM, which is already quite a computationally demanding estimator. Is there a less computationally complex approach that can be taken in GSEM?

      Thanks for your insight,

      John

      Comment


      • #4
        John Adler how is your outcome measured. You can do fixed effects regression in sem, but it will depend on how your outcome is measured. For a continuous outcome, you can use the xtdpdml command: https://www3.nd.edu/~rwilliam/dynamic/. For other outcomes, you can use gsem with an Alpha term. For example:

        Code:
        gsem (y_t <- X1@a  X2@b X3@c Alpha@1, logit)
                  (y_t+1 <- X1@a X2@b X3@c Alpha@1, logit)
                  ......
                  (Alpha <- X3*)     */ correlate Alpha with time-varying covariates) /*

        Comment


        • #5
          Originally posted by John Adler View Post
          Hi Andrew,

          That's an excellent point, and well taken, but in large sample panel data on individuals sampled repeatedly over several waves, although one could include panel indicators as i.id, when sample sizes approach 10,000 and data is measured over several waves this is computationally too complex to be feasible in GSEM, which is already quite a computationally demanding estimator. Is there a less computationally complex approach that can be taken in GSEM?

          Thanks for your insight,

          John
          Stata makes this easier for you by having a command that can do the within transformation on your behalf. See

          Code:
          help xtdata
          Example:

          Code:
          webuse grunfeld, clear
          xtset company year
          xtreg invest mvalue kstock, fe
          xtdata, fe
          gsem (invest <- mvalue kstock)
          Res.:

          Code:
          . xtreg invest mvalue kstock, fe
          
          Fixed-effects (within) regression               Number of obs     =        200
          Group variable: company                         Number of groups  =         10
          
          R-sq:                                           Obs per group:
               within  = 0.7668                                         min =         20
               between = 0.8194                                         avg =       20.0
               overall = 0.8060                                         max =         20
          
                                                          F(2,188)          =     309.01
          corr(u_i, Xb)  = -0.1517                        Prob > F          =     0.0000
          
          ------------------------------------------------------------------------------
                invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                mvalue |   .1101238   .0118567     9.29   0.000     .0867345    .1335131
                kstock |   .3100653   .0173545    17.87   0.000     .2758308    .3442999
                 _cons |  -58.74393   12.45369    -4.72   0.000    -83.31086     -34.177
          -------------+----------------------------------------------------------------
               sigma_u |  85.732501
               sigma_e |  52.767964
                   rho |  .72525012   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(9, 188) = 49.18                     Prob > F = 0.0000
          
          . 
          . xtdata, fe
          
          . 
          . gsem (invest <- mvalue kstock)
          
          Iteration 0:   log likelihood =  -1070.781  
          Iteration 1:   log likelihood =  -1070.781  
          
          Generalized structural equation model           Number of obs     =        200
          Response       : invest
          Family         : Gaussian
          Link           : identity
          Log likelihood =  -1070.781
          
          -------------------------------------------------------------------------------
                        |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          --------------+----------------------------------------------------------------
          invest        |
                 mvalue |   .1101238   .0114955     9.58   0.000      .087593    .1326545
                 kstock |   .3100653   .0168258    18.43   0.000     .2770874    .3430433
                  _cons |  -58.74393    12.0743    -4.87   0.000    -82.40913   -35.07874
          --------------+----------------------------------------------------------------
           var(e.invest)|   2617.391   261.7391                      2151.535    3184.115
          -------------------------------------------------------------------------------

          Comment


          • #6
            Hi Andrew Musau,

            Good advice on the within transformation with xtdata. I wonder if this may be unsuitable in unbalanced panel data over more than two waves? I provide an example below from my own data where I can show that the coefficient of the primary predictor (O_bineparhealthV1_y) is significantly different in an xtreg, fe in comparison to xtreg following xtdata:

            Code:
            . xtreg O_SDQemotional_y O_bineparhealthV1_y i.C_althouseholdage_y i.C_housemarstatus_y i.C_SIMPLhouseeduc_y i.S_Numsibshome_y i.C_region_
            > y i.year, cluster (id) fe 
            
            Fixed-effects (within) regression               Number of obs     =     26,275
            Group variable: id                              Number of groups  =     10,083
            
            R-sq:                                           Obs per group:
                 within  = 0.0565                                         min =          1
                 between = 0.0118                                         avg =        2.6
                 overall = 0.0288                                         max =          3
            
                                                            F(17,10082)       =      46.22
            corr(u_i, Xb)  = -0.0048                        Prob > F          =     0.0000
            
                                                                          (Std. Err. adjusted for 10,083 clusters in id)
            ------------------------------------------------------------------------------------------------------------
                                                       |               Robust
                                      O_SDQemotional_y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------------------------------------+----------------------------------------------------------------
                                   O_bineparhealthV1_y |   .1553333   .0460297     3.37   0.001     .0651059    .2455606
                                                       |
                                   C_althouseholdage_y |
                                                   30  |   .1795427   .0706476     2.54   0.011     .0410593    .3180261
                                                   40  |   .1387427   .0827023     1.68   0.093    -.0233703    .3008556
                                                       |
                                    C_housemarstatus_y |
            Married and separated from husband / wife  |   .2539261   .1058295     2.40   0.016     .0464793     .461373
                                   Divorced / Widowed  |   .1437085   .1299528     1.11   0.269    -.1110248    .3984419
                                        Never married  |     .11411   .0735216     1.55   0.121     -.030007     .258227
                                           Don't know  |   .2822796   .4328823     0.65   0.514     -.566256    1.130815
                                                       |
                                    C_SIMPLhouseeduc_y |
                    Leaving Certificate to Non Degree  |  -.1286056     .12079    -1.06   0.287     -.365378    .1081669
                            Primary Degree or greater  |  -.1024729   .1309655    -0.78   0.434    -.3591914    .1542455
                                                       |
                                       S_Numsibshome_y |
                                                    1  |   .1404648   .0583387     2.41   0.016     .0261094    .2548203
                                                    2  |   .1736009   .0714815     2.43   0.015      .033483    .3137188
                                                    3  |   .1052649   .0927875     1.13   0.257    -.0766172    .2871469
                                                    4  |  -.2091732   .1357373    -1.54   0.123    -.4752454     .056899
                                                    5  |  -.0977357   .4057356    -0.24   0.810    -.8930584     .697587
                                                       |
                                            C_region_y |
                                                Urban  |   .1137303   .0457007     2.49   0.013     .0241478    .2033127
                                                       |
                                                  year |
                                                    2  |   .1860172   .0200433     9.28   0.000     .1467284     .225306
                                                    4  |   .6179212   .0305622    20.22   0.000     .5580131    .6778292
                                                       |
                                                 _cons |   1.074107   .1433333     7.49   0.000      .793145    1.355069
            -------------------------------------------+----------------------------------------------------------------
                                               sigma_u |  1.3095607
                                               sigma_e |  1.3288856
                                                   rho |  .49267602   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------------------------------------
            Applying xtdata as suggested:

            Code:
            . xtdata O_SDQemotional_y O_SDQconduct_y O_SDQhyper_y O_SDQpeerprobs_y O_SDQprosocial_y O_SDQtotaldiffs_y id O_bineparhealthV1_y O_binmoth
            > rhealthV1_y O_binfathrhealthV1_y C_althouseholdage_y C_housemarstatus_y C_SIMPLhouseeduc_y S_Numsibshome_y C_region_y year S_Numsocwelfp
            > aymnts_y X_equivincDeciles_y X_nodepritems_y X_prntsherhrswkdADD_y X_howmuchrentmrtgsupp_y X_prntsstress_y X_PiantaPrntsPostv_y X_Pianta
            > PrntsConflict_y X_Prntswarmth_y X_Prntshostility_y X_Prntsconsistency_y C_parntsunitbeertotal_y C_parntsunitwinetotal_y C_parntsunitsalc
            > total_y O_epdrinkfrq_y O_parentsbmi_y C_eitherprntsmoked_y atleast2SDQmeasures, clear fe
            The subsequent xtreg fe:

            Code:
            . xtreg O_SDQemotional_y O_bineparhealthV1_y C_althouseholdage_y C_housemarstatus_y C_SIMPLhouseeduc_y S_Numsibshome_y C_region_y year, cl
            > uster (id)
            
            Random-effects GLS regression                   Number of obs     =     13,288
            Group variable: id                              Number of groups  =      7,796
            
            R-sq:                                           Obs per group:
                 within  = 0.0000                                         min =          1
                 between = 0.0000                                         avg =        1.7
                 overall = 0.0160                                         max =          2
            
                                                            Wald chi2(7)      =      86.62
            corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
            
                                                    (Std. Err. adjusted for 7,796 clusters in id)
            -------------------------------------------------------------------------------------
                                |               Robust
               O_SDQemotional_y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            --------------------+----------------------------------------------------------------
            O_bineparhealthV1_y |   .0793548   .0728013     1.09   0.276    -.0633331    .2220426
            C_althouseholdage_y |  -.0066254   .0053421    -1.24   0.215    -.0170957     .003845
             C_housemarstatus_y |   .0685176   .0379009     1.81   0.071    -.0057668    .1428019
             C_SIMPLhouseeduc_y |  -.0948536   .0895806    -1.06   0.290    -.2704283    .0807211
                S_Numsibshome_y |   .1515958    .045732     3.31   0.001     .0619626    .2412289
                     C_region_y |    .127083   .0781766     1.63   0.104    -.0261403    .2803063
                           year |   .1643596   .0271438     6.06   0.000     .1111588    .2175604
                          _cons |   1.199092   .2941076     4.08   0.000     .6226519    1.775533
            --------------------+----------------------------------------------------------------
                        sigma_u |          0
                        sigma_e |  1.1474573
                            rho |          0   (fraction of variance due to u_i)
            -------------------------------------------------------------------------------------
            and GSEM:

            Code:
            . gsem (O_bineparhealthV1_y -> O_SDQemotional_y, ) (C_althouseholdage_y -> O_SDQemotional_y, ) (C_housemarstatus_y -> O_SDQemotional_y, ) 
            > (C_SIMPLhouseeduc_y -> O_SDQemotional_y, ) (S_Numsibshome_y -> O_SDQemotional_y, ) (C_region_y -> O_SDQemotional_y, ) (year -> O_SDQemot
            > ional_y, ) (M1[id] -> O_SDQemotional_y, ), covstruct(_lexogenous, diagonal) vce(cluster id) latent(M1 ) nocapslatent
            
            Fitting fixed-effects model:
            
            Iteration 0:   log likelihood = -14803.694  
            Iteration 1:   log likelihood = -14803.694  
            
            Refining starting values:
            
            Grid node 0:   log likelihood = -14803.694
            
            Fitting full model:
            
            Iteration 0:   log pseudolikelihood = -14803.694  
            Iteration 1:   log pseudolikelihood = -14803.694  
            
            Generalized structural equation model           Number of obs     =     13,288
            Response       : O_SDQemotional_y
            Family         : Gaussian
            Link           : identity
            Log pseudolikelihood = -14803.694
            
             ( 1)  [O_SDQemotional_y]M1[id] = 1
                                                        (Std. Err. adjusted for 7,796 clusters in id)
            -----------------------------------------------------------------------------------------
                                    |               Robust
                                    |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            ------------------------+----------------------------------------------------------------
            O_SDQemotional_y        |
                O_bineparhealthV1_y |   .0793548   .0727821     1.09   0.276    -.0632955     .222005
                C_althouseholdage_y |  -.0066254   .0053407    -1.24   0.215     -.017093    .0038423
                 C_housemarstatus_y |   .0685176   .0378909     1.81   0.071    -.0057472    .1427824
                 C_SIMPLhouseeduc_y |  -.0948536    .089557    -1.06   0.290     -.270382    .0806748
                    S_Numsibshome_y |   .1515958     .04572     3.32   0.001     .0619863    .2412053
                         C_region_y |    .127083    .078156     1.63   0.104    -.0260999    .2802659
                               year |   .1643596   .0271366     6.06   0.000     .1111728    .2175464
                                    |
                             M1[id] |          1  (constrained)
                                    |
                              _cons |   1.199092   .2940302     4.08   0.000     .6228038    1.775381
            ------------------------+----------------------------------------------------------------
                         var(M1[id])|   1.38e-33   4.00e-34                      7.81e-34    2.43e-33
            ------------------------+----------------------------------------------------------------
             var(e.O_SDQemotional_y)|   .5434882   .0145034                      .5157926    .5726708
            -----------------------------------------------------------------------------------------
            Grateful for any insight you might have,

            All the best,

            John


            Comment


            • #7
              Tom Scott

              Thanks for your feedback, Richard Williams xtdpdml is a fantastic command, but as I study panel data of the same individual over time I'm not sure it would be appropriate here as it acts like a SEM shell, and thus does not call GSEM which is needed for multilevel, or repeated panel data. I think the same issue I mention to Andrew above may also apply to gsem with an Alpha term, if this approach is similar to post 3 by Richard Williams here: https://www.statalist.org/forums/for...on-models-2009 then it seems to give the same, decreased number of observations that xtdata did above. Although I could be entirely incorrect?

              Thanks, and all the best,

              John

              Comment


              • #8
                One approach with unbalanced panels is to use iterative demeaning. See the Stata Journal article by Fernando Rios: https://journals.sagepub.com/doi/pdf...867X1501500318. For example code, see https://www.statalist.org/forums/for...-time-variable

                ADDED IN EDIT:

                Good advice on the within transformation with xtdata. I wonder if this may be unsuitable in unbalanced panel data over more than two waves? I provide an example below from my own data where I can show that the coefficient of the primary predictor (O_bineparhealthV1_y) is significantly different in an xtreg, fe in comparison to xtreg following xtdata:
                Re-reading your post, I am not sure why you run a random effects model after xtdata. Fixed effects is OLS on the demeaned variables, so to get the same coefficients, you run regress or maximum likelihood estimation using gsem after xtdata. If the coefficients do not exactly match, apply iterative demeaning in place of xtdata as explained in the links above.
                Last edited by Andrew Musau; 22 Nov 2020, 06:37.

                Comment


                • #9
                  xtdpdml was designed for repeated measures (panel) data:see https://www3.nd.edu/~rwilliam/dynamic/SJPaper.pdf and/or https://www3.nd.edu/~rwilliam/dynami...Benito2017.pdf

                  Comment


                  • #10
                    Hi Tom Scott

                    I have read the papers on xtdpdml, but there does not seem to be an option to cluster, so I went back to your earlier suggestion and combined it with advice given by Richard Williams here: https://www.statalist.org/forums/for...on-models-2009 and it seems to give comparable results to the xtreg fixed effects approach I shared earlier. However, exactly what it's doing is somewhat of a mystery to me.

                    I understand that in each wave (here I have _y1, _y2 and _y4) it estimates a linear regression in the wide format, but as to what follows next I am lost...

                    Why are independent variables assigned @c1-6? Likewise what is happening in:
                    Code:
                    >     covstruct(_lexogenous,diagonal) cov(_lexogenous*_oexogenous@0) latent(A ) nocapslatent ///
                    >     cov( e.O_SDQemotional_y1@e1 e.O_SDQemotional_y2@e1 e.O_SDQemotional_y4@e1 ///
                    >     A*(O_bineparhealthV1_y1 C_althouseholdage_y1 O_bineparhealthV1_y2 C_althouseholdage_y2 O_bineparhealthV1_y4 C_althouseholdage_y4 C_
                    > housemarstatus_y1 C_SIMPLhouseeduc_y1 C_housemarstatus_y2 C_SIMPLhouseeduc_y2 C_housemarstatus_y4 C_SIMPLhouseeduc_y4 S_Numsibshome_y1 
                    > C_region_y1 S_Numsibshome_y2 C_region_y2 S_Numsibshome_y4 C_region_y4) )
                    I understand this produces a fixed effects model, but what I don't understand is how!

                    I would be so grateful if you could shine some light on this!

                    Kindest regards,

                    John

                    Code:
                    . sem (O_SDQemotional_y1 <- O_bineparhealthV1_y1@c1 C_althouseholdage_y1@c2 C_housemarstatus_y1@c3 C_SIMPLhouseeduc_y1@c4 S_Numsibshome_y
                    > 1@c5 C_region_y1@c6  A@1) ///
                    >     (O_SDQemotional_y2 <- O_bineparhealthV1_y2@c1 C_althouseholdage_y2@c2 C_housemarstatus_y2@c3 C_SIMPLhouseeduc_y2@c4 S_Numsibshome_y
                    > 2@c5 C_region_y2@c6  A@1) ///
                    >     (O_SDQemotional_y4 <- O_bineparhealthV1_y4@c1 C_althouseholdage_y4@c2 C_housemarstatus_y4@c3 C_SIMPLhouseeduc_y4@c4 S_Numsibshome_y
                    > 4@c5 C_region_y4@c6  A@1), ///
                    >     covstruct(_lexogenous,diagonal) cov(_lexogenous*_oexogenous@0) latent(A ) nocapslatent ///
                    >     cov( e.O_SDQemotional_y1@e1 e.O_SDQemotional_y2@e1 e.O_SDQemotional_y4@e1 ///
                    >     A*(O_bineparhealthV1_y1 C_althouseholdage_y1 O_bineparhealthV1_y2 C_althouseholdage_y2 O_bineparhealthV1_y4 C_althouseholdage_y4 C_
                    > housemarstatus_y1 C_SIMPLhouseeduc_y1 C_housemarstatus_y2 C_SIMPLhouseeduc_y2 C_housemarstatus_y4 C_SIMPLhouseeduc_y4 S_Numsibshome_y1 
                    > C_region_y1 S_Numsibshome_y2 C_region_y2 S_Numsibshome_y4 C_region_y4) )
                    (3959 observations with missing values excluded)
                    
                    Endogenous variables
                    
                    Observed:  O_SDQemotional_y1 O_SDQemotional_y2 O_SDQemotional_y4
                    
                    Exogenous variables
                    
                    Observed:  O_bineparhealthV1_y1 C_althouseholdage_y1 C_housemarstatus_y1 C_SIMPLhouseeduc_y1 S_Numsibshome_y1 C_region_y1
                               O_bineparhealthV1_y2 C_althouseholdage_y2 C_housemarstatus_y2 C_SIMPLhouseeduc_y2 S_Numsibshome_y2 C_region_y2
                               O_bineparhealthV1_y4 C_althouseholdage_y4 C_housemarstatus_y4 C_SIMPLhouseeduc_y4 S_Numsibshome_y4 C_region_y4
                    Latent:    A
                    
                    Fitting target model:
                    
                    Iteration 0:   log likelihood = -162625.43  (not concave)
                    Iteration 1:   log likelihood = -161456.48  
                    Iteration 2:   log likelihood = -161321.45  
                    Iteration 3:   log likelihood = -161317.88  
                    Iteration 4:   log likelihood = -161317.86  
                    
                    Structural equation model                       Number of obs     =      7,175
                    Estimation method  = ml
                    Log likelihood     = -161317.86
                    
                     ( 1)  [O_SDQemotional_y1]O_bineparhealthV1_y1 - [O_SDQemotional_y4]O_bineparhealthV1_y4 = 0
                     ( 2)  [O_SDQemotional_y1]C_althouseholdage_y1 - [O_SDQemotional_y4]C_althouseholdage_y4 = 0
                     ( 3)  [O_SDQemotional_y1]C_housemarstatus_y1 - [O_SDQemotional_y4]C_housemarstatus_y4 = 0
                     ( 4)  [O_SDQemotional_y1]C_SIMPLhouseeduc_y1 - [O_SDQemotional_y4]C_SIMPLhouseeduc_y4 = 0
                     ( 5)  [O_SDQemotional_y1]S_Numsibshome_y1 - [O_SDQemotional_y4]S_Numsibshome_y4 = 0
                     ( 6)  [O_SDQemotional_y1]C_region_y1 - [O_SDQemotional_y4]C_region_y4 = 0
                     ( 7)  [O_SDQemotional_y1]A = 1
                     ( 8)  [O_SDQemotional_y2]O_bineparhealthV1_y2 - [O_SDQemotional_y4]O_bineparhealthV1_y4 = 0
                     ( 9)  [O_SDQemotional_y2]C_althouseholdage_y2 - [O_SDQemotional_y4]C_althouseholdage_y4 = 0
                     (10)  [O_SDQemotional_y2]C_housemarstatus_y2 - [O_SDQemotional_y4]C_housemarstatus_y4 = 0
                     (11)  [O_SDQemotional_y2]C_SIMPLhouseeduc_y2 - [O_SDQemotional_y4]C_SIMPLhouseeduc_y4 = 0
                     (12)  [O_SDQemotional_y2]S_Numsibshome_y2 - [O_SDQemotional_y4]S_Numsibshome_y4 = 0
                     (13)  [O_SDQemotional_y2]C_region_y2 - [O_SDQemotional_y4]C_region_y4 = 0
                     (14)  [O_SDQemotional_y2]A = 1
                     (15)  [O_SDQemotional_y4]A = 1
                     (16)  [/]var(e.O_SDQemotional_y1) - [/]var(e.O_SDQemotional_y4) = 0
                     (17)  [/]var(e.O_SDQemotional_y2) - [/]var(e.O_SDQemotional_y4) = 0
                    --------------------------------------------------------------------------------------------
                                               |                 OIM
                                               |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                    ---------------------------+----------------------------------------------------------------
                    Structural                 |
                      O_SDQemotional_y1        |
                          O_bineparhealthV1_y1 |   .1924663   .0446248     4.31   0.000     .1050033    .2799293
                          C_althouseholdage_y1 |  -.0001786   .0033792    -0.05   0.958    -.0068017    .0064446
                           C_housemarstatus_y1 |   .0328578   .0232932     1.41   0.158     -.012796    .0785117
                           C_SIMPLhouseeduc_y1 |   .0213651   .0507198     0.42   0.674    -.0780439     .120774
                              S_Numsibshome_y1 |   .0102002   .0277682     0.37   0.713    -.0442245    .0646248
                                   C_region_y1 |    .160215   .0483206     3.32   0.001     .0655083    .2549217
                                             A |          1   2.35e-17  4.2e+16   0.000            1           1
                                         _cons |    1.10361   .1757899     6.28   0.000     .7590686    1.448152
                      -------------------------+----------------------------------------------------------------
                      O_SDQemotional_y2        |
                          O_bineparhealthV1_y2 |   .1924663   .0446248     4.31   0.000     .1050033    .2799293
                          C_althouseholdage_y2 |  -.0001786   .0033792    -0.05   0.958    -.0068017    .0064446
                           C_housemarstatus_y2 |   .0328578   .0232932     1.41   0.158     -.012796    .0785117
                           C_SIMPLhouseeduc_y2 |   .0213651   .0507198     0.42   0.674    -.0780439     .120774
                              S_Numsibshome_y2 |   .0102002   .0277682     0.37   0.713    -.0442245    .0646248
                                   C_region_y2 |    .160215   .0483206     3.32   0.001     .0655083    .2549217
                                             A |          1   6.50e-17  1.5e+16   0.000            1           1
                                         _cons |   1.300241   .1805867     7.20   0.000     .9462972    1.654184
                      -------------------------+----------------------------------------------------------------
                      O_SDQemotional_y4        |
                          O_bineparhealthV1_y4 |   .1924663   .0446248     4.31   0.000     .1050033    .2799293
                          C_althouseholdage_y4 |  -.0001786   .0033792    -0.05   0.958    -.0068017    .0064446
                           C_housemarstatus_y4 |   .0328578   .0232932     1.41   0.158     -.012796    .0785117
                           C_SIMPLhouseeduc_y4 |   .0213651   .0507198     0.42   0.674    -.0780439     .120774
                              S_Numsibshome_y4 |   .0102002   .0277682     0.37   0.713    -.0442245    .0646248
                                   C_region_y4 |    .160215   .0483206     3.32   0.001     .0655083    .2549217
                                             A |          1  (constrained)
                                         _cons |   1.728791   .1881954     9.19   0.000     1.359935    2.097647
                    ---------------------------+----------------------------------------------------------------
                       var(e.O_SDQemotional_y1)|   1.769849   .0208941                      1.729368    1.811278
                       var(e.O_SDQemotional_y2)|   1.769849   .0208941                      1.729368    1.811278
                       var(e.O_SDQemotional_y4)|   1.769849   .0208941                      1.729368    1.811278
                                         var(A)|   1.011245   .0298635                      .9543758    1.071504
                    ---------------------------+----------------------------------------------------------------
                    cov(O_bineparhealthV1_y1,A)|   .0237509   .0045902     5.17   0.000     .0147542    .0327475
                    cov(C_althouseholdage_y1,A)|  -.8292402   .1387241    -5.98   0.000    -1.101134   -.5573461
                     cov(C_housemarstatus_y1,A)|   .1201731   .0351732     3.42   0.001     .0512349    .1891113
                     cov(C_SIMPLhouseeduc_y1,A)|  -.0865194   .0178597    -4.84   0.000    -.1215238    -.051515
                        cov(S_Numsibshome_y1,A)|  -.0948707   .0275537    -3.44   0.001    -.1488751   -.0408664
                             cov(C_region_y1,A)|  -.0170987   .0123385    -1.39   0.166    -.0412817    .0070843
                    cov(O_bineparhealthV1_y2,A)|   .0157536   .0044462     3.54   0.000     .0070392     .024468
                    cov(C_althouseholdage_y2,A)|  -.8127367   .1385925    -5.86   0.000    -1.084373   -.5411003
                     cov(C_housemarstatus_y2,A)|   .1161725   .0336952     3.45   0.001     .0501311    .1822139
                     cov(C_SIMPLhouseeduc_y2,A)|  -.0814427   .0177595    -4.59   0.000    -.1162506   -.0466348
                        cov(S_Numsibshome_y2,A)|   -.073246   .0279521    -2.62   0.009    -.1280311    -.018461
                             cov(C_region_y2,A)|  -.0147682   .0123087    -1.20   0.230    -.0388928    .0093564
                    cov(O_bineparhealthV1_y4,A)|   .0263663   .0051018     5.17   0.000     .0163668    .0363657
                    cov(C_althouseholdage_y4,A)|  -.5487806   .0975156    -5.63   0.000    -.7399077   -.3576535
                     cov(C_housemarstatus_y4,A)|   .0937601   .0298503     3.14   0.002     .0352546    .1522656
                     cov(C_SIMPLhouseeduc_y4,A)|  -.0809895   .0175985    -4.60   0.000     -.115482    -.046497
                        cov(S_Numsibshome_y4,A)|  -.0540028   .0270366    -2.00   0.046    -.1069935    -.001012
                             cov(C_region_y4,A)|  -.0153045   .0122469    -1.25   0.211     -.039308     .008699
                    --------------------------------------------------------------------------------------------
                    LR test of model vs. saturated: chi2(34)  =   1407.85, Prob > chi2 = 0.0000

                    Comment


                    • #11
                      John Adler I'm not a statistician, but I will try to answer what I can. The choice of c1-c6 and later e1 is arbitrary. They are names for the parameters, and the parameters with the same name are constrained to be equal. So, the parameters for each X variable will not vary by time. Alpha or "A" is capitalized to indicate that it is a latent variable, and @1 means it is constrained to be 1 at each wave (you can modify this assumption). The cov code is constraining the covariances parameters to be the same at each wave (signified by name e1 for each variable), and again you can relax and test this assumption. The A* code is interacting Alpha with each time-varying covariate, which is essential for fe regression but also the default setting in sem (but not gsem), so I think it might be unnecessary to specify. I know covstruct stands for covariance structure but I'm not sure what that is doing.

                      As far as the estimation, I know it is using maximum likelihood to do something somewhat similar to the instrumental variable design used in xtabond. If you speak math, one of the articles I linked to should give you what you need. If you specify the regression these same way, it should give you the same results as using sem but with much less code.

                      Comment


                      • #12
                        Dear Tom Scott

                        Thank you so much for your explanation, and for the links you shared, using these I was able to replicate my original fixed effects regressions almost identically.

                        What I did was first conduct my analysis as informed by the articles on xtdpdml, then when results were analogous to my original xtreg, fe I used showcmd to show the sem command generated by xtdpdml. This helped me to "look under the hood" as to what exactly is going on.

                        Here's my (very last) question. I can see that a fixed effects structural equation can be estimated by restructuring the data into the wide format and repeating the analysis in each wave individually, but I'm not so clear on why this works. What magic is happening to allow me to produce the same fixed effects analysis that I estimated longitudinally in panel data before?

                        Of course I know it's not really magic, but it may as well be to my eyes, so I'm very eager to understand! Is there any chance you could explain this to me in simple terms? I'm afraid I don't speak math as well as many people on this list!

                        Thanks again and all the best,

                        John


                        Code:
                        . sem (O_SDQemotional_y1 <- O_bineparhealthV1_y1@b1 C_althouseholdage_y1@b2 C_housemarstatus_y1@b3 C_SIMPLhouseeduc_y1@b4 C_region_y1@b5 
                        > S_Numsibshome_y1@b6 Alpha@1 )(O_SDQemotional_y2 <- O_bineparhealthV1_y2@b1 C_althouseholdage_y2@b2 C_housemarstatus_y2@b3 C_SIMPLhousee
                        > duc_y2@b4 C_region_y2@b5 S_Numsibshome_y2@b6 Alpha@1 )(O_SDQemotional_y4 <- O_bineparhealthV1_y4@b1 C_althouseholdage_y4@b2 C_housemars
                        > tatus_y4@b3 C_SIMPLhouseeduc_y4@b4 C_region_y4@b5 S_Numsibshome_y4@b6 Alpha@1 ), var(Alpha) iterate(250) noxconditional vce(cluster id)
                        >  latent(Alpha) nocapslatent
                        (3959 observations with missing values excluded)
                        
                        Endogenous variables
                        
                        Observed:  O_SDQemotional_y1 O_SDQemotional_y2 O_SDQemotional_y4
                        
                        Exogenous variables
                        
                        Observed:  O_bineparhealthV1_y1 C_althouseholdage_y1 C_housemarstatus_y1 C_SIMPLhouseeduc_y1 C_region_y1 S_Numsibshome_y1
                                   O_bineparhealthV1_y2 C_althouseholdage_y2 C_housemarstatus_y2 C_SIMPLhouseeduc_y2 C_region_y2 S_Numsibshome_y2
                                   O_bineparhealthV1_y4 C_althouseholdage_y4 C_housemarstatus_y4 C_SIMPLhouseeduc_y4 C_region_y4 S_Numsibshome_y4
                        Latent:    Alpha
                        
                        Fitting conditional model:
                        
                        Iteration 0:   log pseudolikelihood = -162089.02  (not concave)
                        Iteration 1:   log pseudolikelihood =  -161131.7  
                        Iteration 2:   log pseudolikelihood = -160839.17  
                        Iteration 3:   log pseudolikelihood = -160791.94  
                        Iteration 4:   log pseudolikelihood = -160791.52  
                        Iteration 5:   log pseudolikelihood = -160791.52  
                        
                        Fitting target model:
                        
                        Iteration 0:   log pseudolikelihood = -160791.52  
                        Iteration 1:   log pseudolikelihood = -160791.52  
                        
                        Structural equation model                       Number of obs     =      7,175
                        Estimation method    = ml
                        Log pseudolikelihood = -160791.52
                        
                         ( 1)  [O_SDQemotional_y1]O_bineparhealthV1_y1 - [O_SDQemotional_y4]O_bineparhealthV1_y4 = 0
                         ( 2)  [O_SDQemotional_y1]C_althouseholdage_y1 - [O_SDQemotional_y4]C_althouseholdage_y4 = 0
                         ( 3)  [O_SDQemotional_y1]C_housemarstatus_y1 - [O_SDQemotional_y4]C_housemarstatus_y4 = 0
                         ( 4)  [O_SDQemotional_y1]C_SIMPLhouseeduc_y1 - [O_SDQemotional_y4]C_SIMPLhouseeduc_y4 = 0
                         ( 5)  [O_SDQemotional_y1]C_region_y1 - [O_SDQemotional_y4]C_region_y4 = 0
                         ( 6)  [O_SDQemotional_y1]S_Numsibshome_y1 - [O_SDQemotional_y4]S_Numsibshome_y4 = 0
                         ( 7)  [O_SDQemotional_y1]Alpha = 1
                         ( 8)  [O_SDQemotional_y2]O_bineparhealthV1_y2 - [O_SDQemotional_y4]O_bineparhealthV1_y4 = 0
                         ( 9)  [O_SDQemotional_y2]C_althouseholdage_y2 - [O_SDQemotional_y4]C_althouseholdage_y4 = 0
                         (10)  [O_SDQemotional_y2]C_housemarstatus_y2 - [O_SDQemotional_y4]C_housemarstatus_y4 = 0
                         (11)  [O_SDQemotional_y2]C_SIMPLhouseeduc_y2 - [O_SDQemotional_y4]C_SIMPLhouseeduc_y4 = 0
                         (12)  [O_SDQemotional_y2]C_region_y2 - [O_SDQemotional_y4]C_region_y4 = 0
                         (13)  [O_SDQemotional_y2]S_Numsibshome_y2 - [O_SDQemotional_y4]S_Numsibshome_y4 = 0
                         (14)  [O_SDQemotional_y2]Alpha = 1
                         (15)  [O_SDQemotional_y4]Alpha = 1
                                                                                          (Std. Err. adjusted for 7,175 clusters in id)
                        ---------------------------------------------------------------------------------------------------------------
                                                                      |               Robust
                                                                      |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                        ----------------------------------------------+----------------------------------------------------------------
                        Structural                                    |
                          O_SDQemotional_y1                           |
                                                 O_bineparhealthV1_y1 |    .166253   .0485838     3.42   0.001     .0710305    .2614754
                                                 C_althouseholdage_y1 |  -.0003344    .003414    -0.10   0.922    -.0070258    .0063569
                                                  C_housemarstatus_y1 |   .0349549   .0233183     1.50   0.134    -.0107481    .0806579
                                                  C_SIMPLhouseeduc_y1 |   .0043267   .0500406     0.09   0.931     -.093751    .1024043
                                                          C_region_y1 |   .1440199    .048707     2.96   0.003      .048556    .2394838
                                                     S_Numsibshome_y1 |   .0421672   .0284758     1.48   0.139    -.0136444    .0979788
                                                                Alpha |          1   2.55e-17  3.9e+16   0.000            1           1
                                                                _cons |   1.113113   .1724501     6.45   0.000     .7751169    1.451109
                          --------------------------------------------+----------------------------------------------------------------
                          O_SDQemotional_y2                           |
                                                 O_bineparhealthV1_y2 |    .166253   .0485838     3.42   0.001     .0710305    .2614754
                                                 C_althouseholdage_y2 |  -.0003344    .003414    -0.10   0.922    -.0070258    .0063569
                                                  C_housemarstatus_y2 |   .0349549   .0233183     1.50   0.134    -.0107481    .0806579
                                                  C_SIMPLhouseeduc_y2 |   .0043267   .0500406     0.09   0.931     -.093751    .1024043
                                                          C_region_y2 |   .1440199    .048707     2.96   0.003      .048556    .2394838
                                                     S_Numsibshome_y2 |   .0421672   .0284758     1.48   0.139    -.0136444    .0979788
                                                                Alpha |          1   6.37e-17  1.6e+16   0.000            1           1
                                                                _cons |   1.301963   .1768529     7.36   0.000     .9553374    1.648588
                          --------------------------------------------+----------------------------------------------------------------
                          O_SDQemotional_y4                           |
                                                 O_bineparhealthV1_y4 |    .166253   .0485838     3.42   0.001     .0710305    .2614754
                                                 C_althouseholdage_y4 |  -.0003344    .003414    -0.10   0.922    -.0070258    .0063569
                                                  C_housemarstatus_y4 |   .0349549   .0233183     1.50   0.134    -.0107481    .0806579
                                                  C_SIMPLhouseeduc_y4 |   .0043267   .0500406     0.09   0.931     -.093751    .1024043
                                                          C_region_y4 |   .1440199    .048707     2.96   0.003      .048556    .2394838
                                                     S_Numsibshome_y4 |   .0421672   .0284758     1.48   0.139    -.0136444    .0979788
                                                                Alpha |          1  (constrained)
                                                                _cons |   1.726718   .1856945     9.30   0.000     1.362764    2.090673
                        ----------------------------------------------+----------------------------------------------------------------
                                            mean(O_bineparhealthV1_y1)|   .0857143   .0033051    25.93   0.000     .0792364    .0921922
                                            mean(C_althouseholdage_y1)|   32.54077   .0723155   449.98   0.000     32.39903     32.6825
                                             mean(C_housemarstatus_y1)|   1.649617   .0142764   115.55   0.000     1.621635    1.677598
                                             mean(C_SIMPLhouseeduc_y1)|   2.466899   .0068735   358.90   0.000     2.453427    2.480371
                                                     mean(C_region_y1)|   .4108711   .0058087    70.73   0.000     .3994863    .4222559
                                                mean(S_Numsibshome_y1)|   1.346481   .0116338   115.74   0.000     1.323679    1.369283
                                            mean(O_bineparhealthV1_y2)|   .0823693   .0032459    25.38   0.000     .0760075    .0887312
                                            mean(C_althouseholdage_y2)|   34.56446   .0710733   486.32   0.000     34.42516    34.70376
                                             mean(C_housemarstatus_y2)|   1.567108   .0135204   115.91   0.000     1.540608    1.593608
                                             mean(C_SIMPLhouseeduc_y2)|   2.471359   .0066873   369.56   0.000     2.458252    2.484466
                                                     mean(C_region_y2)|   .3832753   .0057401    66.77   0.000     .3720248    .3945257
                                                mean(S_Numsibshome_y2)|   1.590801   .0114503   138.93   0.000     1.568359    1.613243
                                            mean(O_bineparhealthV1_y4)|   .1080139   .0036647    29.47   0.000     .1008313    .1151966
                                            mean(C_althouseholdage_y4)|   37.76725   .0509521   741.23   0.000     37.66738    37.86711
                                             mean(C_housemarstatus_y4)|   1.491986   .0125454   118.93   0.000     1.467397    1.516575
                                             mean(C_SIMPLhouseeduc_y4)|   2.478188   .0067573   366.74   0.000     2.464944    2.491432
                                                     mean(C_region_y4)|   .4005575   .0057853    69.24   0.000     .3892185    .4118965
                                                mean(S_Numsibshome_y4)|   1.763484    .011512   153.19   0.000     1.740921    1.786048
                        ----------------------------------------------+----------------------------------------------------------------
                                              var(e.O_SDQemotional_y1)|   1.043074   .0329815                      .9803938    1.109762
                                              var(e.O_SDQemotional_y2)|   1.565779   .0463625                      1.477496    1.659336
                                              var(e.O_SDQemotional_y4)|    2.82464   .0673561                      2.695662    2.959789
                                             var(O_bineparhealthV1_y1)|   .0783673   .0027385                      .0731796    .0839228
                                             var(C_althouseholdage_y1)|   37.51663   .5261052                      36.49953    38.56208
                                              var(C_housemarstatus_y1)|   1.462179   .0242134                      1.415484    1.510415
                                              var(C_SIMPLhouseeduc_y1)|   .3389392   .0046626                      .3299227     .348202
                                                      var(C_region_y1)|    .242056   .0010354                      .2400351     .244094
                                                 var(S_Numsibshome_y1)|   .9709615   .0170721                      .9380707    1.005006
                                             var(O_bineparhealthV1_y2)|   .0755846   .0027112                      .0704533    .0810897
                                             var(C_althouseholdage_y2)|   36.23888   .5136301                      35.24603    37.25969
                                              var(C_housemarstatus_y2)|    1.31142   .0252321                      1.262887    1.361818
                                              var(C_SIMPLhouseeduc_y2)|   .3208173   .0042095                      .3126721    .3291747
                                                      var(C_region_y2)|   .2363753     .00134                      .2337635    .2390164
                                                 var(S_Numsibshome_y2)|   .9405704   .0159216                      .9098767    .9722996
                                             var(O_bineparhealthV1_y4)|   .0963469    .002873                      .0908773    .1021458
                                             var(C_althouseholdage_y4)|   18.62457    .387542                      17.88028    19.39984
                                              var(C_housemarstatus_y4)|     1.1291    .025113                      1.080936    1.179409
                                              var(C_SIMPLhouseeduc_y4)|    .327573   .0044265                      .3190112    .3363646
                                                      var(C_region_y4)|   .2401112   .0011506                      .2378666     .242377
                                                 var(S_Numsibshome_y4)|   .9507502   .0153457                      .9211439    .9813081
                                                            var(Alpha)|   .9267015   .0333735                      .8635457    .9944762
                        ----------------------------------------------+----------------------------------------------------------------
                        cov(O_bineparhealthV1_y1,C_althouseholdage_y1)|  -.0352016   .0210739    -1.67   0.095    -.0765057    .0061025
                         cov(O_bineparhealthV1_y1,C_housemarstatus_y1)|   .0237611   .0045234     5.25   0.000     .0148954    .0326268
                         cov(O_bineparhealthV1_y1,C_SIMPLhouseeduc_y1)|  -.0173021   .0021224    -8.15   0.000    -.0214619   -.0131424
                                 cov(O_bineparhealthV1_y1,C_region_y1)|   .0011588   .0016334     0.71   0.478    -.0020425    .0043601
                            cov(O_bineparhealthV1_y1,S_Numsibshome_y1)|   .0023574   .0034331     0.69   0.492    -.0043713    .0090861
                        cov(O_bineparhealthV1_y1,O_bineparhealthV1_y2)|   .0226262   .0017138    13.20   0.000     .0192672    .0259851
                        cov(O_bineparhealthV1_y1,C_althouseholdage_y2)|  -.0302638   .0200472    -1.51   0.131    -.0695557    .0090281
                         cov(O_bineparhealthV1_y1,C_housemarstatus_y2)|   .0242827   .0043839     5.54   0.000     .0156904     .032875
                         cov(O_bineparhealthV1_y1,C_SIMPLhouseeduc_y2)|  -.0151757   .0020435    -7.43   0.000    -.0191809   -.0111705
                                 cov(O_bineparhealthV1_y1,C_region_y2)|   .0011548   .0016165     0.71   0.475    -.0020135    .0043231
                            cov(O_bineparhealthV1_y1,S_Numsibshome_y2)|  -.0029746    .003319    -0.90   0.370    -.0094797    .0035304
                        cov(O_bineparhealthV1_y1,O_bineparhealthV1_y4)|   .0191737   .0016545    11.59   0.000      .015931    .0224165
                        cov(O_bineparhealthV1_y1,C_althouseholdage_y4)|  -.0525236   .0156998    -3.35   0.001    -.0832946   -.0217527
                         cov(O_bineparhealthV1_y1,C_housemarstatus_y4)|     .02445   .0042064     5.81   0.000     .0162056    .0326943
                         cov(O_bineparhealthV1_y1,C_SIMPLhouseeduc_y4)|   -.015343   .0020981    -7.31   0.000    -.0194551   -.0112308
                                 cov(O_bineparhealthV1_y1,C_region_y4)|   .0019034   .0016328     1.17   0.244    -.0012969    .0051037
                            cov(O_bineparhealthV1_y1,S_Numsibshome_y4)|  -.0060687   .0033186    -1.83   0.067     -.012573    .0004356
                                       cov(O_bineparhealthV1_y1,Alpha)|   .0206286   .0053052     3.89   0.000     .0102307    .0310266
                         cov(C_althouseholdage_y1,C_housemarstatus_y1)|  -2.574566     .10583   -24.33   0.000    -2.781989   -2.367143
                         cov(C_althouseholdage_y1,C_SIMPLhouseeduc_y1)|   .6771334   .0453405    14.93   0.000     .5882677    .7659991
                                 cov(C_althouseholdage_y1,C_region_y1)|  -.1157045   .0357364    -3.24   0.001    -.1857466   -.0456624
                            cov(C_althouseholdage_y1,S_Numsibshome_y1)|   1.625596   .0741335    21.93   0.000     1.480298    1.770895
                        cov(C_althouseholdage_y1,O_bineparhealthV1_y2)|   .0234714    .019984     1.17   0.240    -.0156966    .0626393
                        cov(C_althouseholdage_y1,C_althouseholdage_y2)|   28.22159   .5052124    55.86   0.000     27.23139    29.21179
                         cov(C_althouseholdage_y1,C_housemarstatus_y2)|  -2.172596   .1022919   -21.24   0.000    -2.373085   -1.972108
                         cov(C_althouseholdage_y1,C_SIMPLhouseeduc_y2)|   .6072652   .0433881    14.00   0.000     .5222261    .6923043
                                 cov(C_althouseholdage_y1,C_region_y2)|  -.1138827   .0354624    -3.21   0.001    -.1833877   -.0443776
                            cov(C_althouseholdage_y1,S_Numsibshome_y2)|   1.144208    .075149    15.23   0.000     .9969183    1.291497
                        cov(C_althouseholdage_y1,O_bineparhealthV1_y4)|  -.0305358   .0236127    -1.29   0.196    -.0768157    .0157442
                        cov(C_althouseholdage_y1,C_althouseholdage_y4)|   15.09451    .381913    39.52   0.000     14.34597    15.84304
                         cov(C_althouseholdage_y1,C_housemarstatus_y4)|  -1.665353   .0952229   -17.49   0.000    -1.851986   -1.478719
                         cov(C_althouseholdage_y1,C_SIMPLhouseeduc_y4)|    .531377   .0441737    12.03   0.000     .4447982    .6179558
                                 cov(C_althouseholdage_y1,C_region_y4)|  -.1173746    .035664    -3.29   0.001    -.1872748   -.0474745
                            cov(C_althouseholdage_y1,S_Numsibshome_y4)|   .3180043   .0748359     4.25   0.000     .1713286      .46468
                                       cov(C_althouseholdage_y1,Alpha)|  -.7674998   .1543082    -4.97   0.000    -1.069938   -.4650612
                          cov(C_housemarstatus_y1,C_SIMPLhouseeduc_y1)|  -.2010057   .0090291   -22.26   0.000    -.2187024   -.1833091
                                  cov(C_housemarstatus_y1,C_region_y1)|   .0420808   .0071288     5.90   0.000     .0281086    .0560531
                             cov(C_housemarstatus_y1,S_Numsibshome_y1)|  -.2583899   .0143431   -18.01   0.000    -.2865017    -.230278
                         cov(C_housemarstatus_y1,O_bineparhealthV1_y2)|   .0033556   .0039968     0.84   0.401     -.004478    .0111892
                         cov(C_housemarstatus_y1,C_althouseholdage_y2)|   -2.66271   .1061462   -25.09   0.000    -2.870753   -2.454668
                          cov(C_housemarstatus_y1,C_housemarstatus_y2)|   1.220308   .0243835    50.05   0.000     1.172517    1.268099
                          cov(C_housemarstatus_y1,C_SIMPLhouseeduc_y2)|  -.1871782    .008642   -21.66   0.000    -.2041161   -.1702403
                                  cov(C_housemarstatus_y1,C_region_y2)|   .0379866   .0070714     5.37   0.000     .0241269    .0518464
                             cov(C_housemarstatus_y1,S_Numsibshome_y2)|  -.2657457   .0145518   -18.26   0.000    -.2942666   -.2372247
                         cov(C_housemarstatus_y1,O_bineparhealthV1_y4)|   .0271146   .0049389     5.49   0.000     .0174344    .0367947
                         cov(C_housemarstatus_y1,C_althouseholdage_y4)|  -2.245734   .0823422   -27.27   0.000    -2.407122   -2.084346
                          cov(C_housemarstatus_y1,C_housemarstatus_y4)|   .9693175   .0236052    41.06   0.000     .9230521    1.015583
                          cov(C_housemarstatus_y1,C_SIMPLhouseeduc_y4)|  -.1744718   .0087596   -19.92   0.000    -.1916402   -.1573033
                                  cov(C_housemarstatus_y1,C_region_y4)|   .0409758   .0071154     5.76   0.000       .02703    .0549217
                             cov(C_housemarstatus_y1,S_Numsibshome_y4)|  -.2014774   .0145212   -13.87   0.000    -.2299385   -.1730163
                                        cov(C_housemarstatus_y1,Alpha)|   .1024466   .0374165     2.74   0.006     .0291115    .1757816
                                  cov(C_SIMPLhouseeduc_y1,C_region_y1)|   .0219626   .0033846     6.49   0.000      .015329    .0285963
                             cov(C_SIMPLhouseeduc_y1,S_Numsibshome_y1)|  -.0381478   .0073008    -5.23   0.000    -.0524572   -.0238385
                         cov(C_SIMPLhouseeduc_y1,O_bineparhealthV1_y2)|  -.0076568   .0019927    -3.84   0.000    -.0115625   -.0037511
                         cov(C_SIMPLhouseeduc_y1,C_althouseholdage_y2)|   .6744333   .0440645    15.31   0.000     .5880686    .7607981
                          cov(C_SIMPLhouseeduc_y1,C_housemarstatus_y2)|  -.1860365    .008689   -21.41   0.000    -.2030666   -.1690064
                          cov(C_SIMPLhouseeduc_y1,C_SIMPLhouseeduc_y2)|   .2848708   .0044674    63.77   0.000     .2761149    .2936267
                                  cov(C_SIMPLhouseeduc_y1,C_region_y2)|   .0181224   .0033627     5.39   0.000     .0115315    .0247132
                             cov(C_SIMPLhouseeduc_y1,S_Numsibshome_y2)|  -.0227435   .0071624    -3.18   0.001    -.0367815   -.0087055
                         cov(C_SIMPLhouseeduc_y1,O_bineparhealthV1_y4)|  -.0186546   .0023123    -8.07   0.000    -.0231866   -.0141226
                         cov(C_SIMPLhouseeduc_y1,C_althouseholdage_y4)|    .585327   .0324466    18.04   0.000     .5217328    .6489212
                          cov(C_SIMPLhouseeduc_y1,C_housemarstatus_y4)|  -.1580701   .0083086   -19.02   0.000    -.1743546   -.1417856
                          cov(C_SIMPLhouseeduc_y1,C_SIMPLhouseeduc_y4)|   .2676055    .004545    58.88   0.000     .2586974    .2765136
                                  cov(C_SIMPLhouseeduc_y1,C_region_y4)|   .0160463    .003377     4.75   0.000     .0094275    .0226652
                             cov(C_SIMPLhouseeduc_y1,S_Numsibshome_y4)|   -.023369   .0071839    -3.25   0.001    -.0374491   -.0092889
                                        cov(C_SIMPLhouseeduc_y1,Alpha)|  -.0727109   .0182419    -3.99   0.000    -.1084643   -.0369574
                                     cov(C_region_y1,S_Numsibshome_y1)|  -.0386656   .0056927    -6.79   0.000    -.0498231   -.0275081
                                 cov(C_region_y1,O_bineparhealthV1_y2)|   .0042056   .0016233     2.59   0.010      .001024    .0073872
                                 cov(C_region_y1,C_althouseholdage_y2)|  -.0398645   .0351057    -1.14   0.256    -.1086703    .0289413
                                  cov(C_region_y1,C_housemarstatus_y2)|   .0323576   .0067538     4.79   0.000     .0191203    .0455948
                                  cov(C_region_y1,C_SIMPLhouseeduc_y2)|   .0245901   .0032904     7.47   0.000     .0181411    .0310391
                                          cov(C_region_y1,C_region_y2)|   .1915128   .0019935    96.07   0.000     .1876057    .1954199
                                     cov(C_region_y1,S_Numsibshome_y2)|  -.0393983   .0056022    -7.03   0.000    -.0503784   -.0284181
                                 cov(C_region_y1,O_bineparhealthV1_y4)|   .0014739   .0018109     0.81   0.416    -.0020754    .0050231
                                 cov(C_region_y1,C_althouseholdage_y4)|  -.0777485   .0252651    -3.08   0.002    -.1272672   -.0282298
                                  cov(C_region_y1,C_housemarstatus_y4)|    .032561   .0062904     5.18   0.000      .020232      .04489
                                  cov(C_region_y1,C_SIMPLhouseeduc_y4)|   .0244322   .0033201     7.36   0.000     .0179249    .0309396
                                          cov(C_region_y1,C_region_y4)|   .1800915   .0021144    85.17   0.000     .1759474    .1842356
                                     cov(C_region_y1,S_Numsibshome_y4)|   -.038711     .00563    -6.88   0.000    -.0497456   -.0276765
                                                cov(C_region_y1,Alpha)|  -.0117493   .0129231    -0.91   0.363     -.037078    .0135795
                            cov(S_Numsibshome_y1,O_bineparhealthV1_y2)|   .0010076   .0033184     0.30   0.761    -.0054964    .0075117
                            cov(S_Numsibshome_y1,C_althouseholdage_y2)|   1.629652   .0702022    23.21   0.000     1.492058    1.767246
                             cov(S_Numsibshome_y1,C_housemarstatus_y2)|  -.2171192    .013917   -15.60   0.000     -.244396   -.1898425
                             cov(S_Numsibshome_y1,C_SIMPLhouseeduc_y2)|  -.0410869    .007077    -5.81   0.000    -.0549575   -.0272162
                                     cov(S_Numsibshome_y1,C_region_y2)|  -.0392784   .0056129    -7.00   0.000    -.0502795   -.0282772
                                cov(S_Numsibshome_y1,S_Numsibshome_y2)|   .8422673   .0158854    53.02   0.000     .8111324    .8734021
                            cov(S_Numsibshome_y1,O_bineparhealthV1_y4)|   .0021571   .0037389     0.58   0.564    -.0051711    .0094853
                            cov(S_Numsibshome_y1,C_althouseholdage_y4)|   .9952088   .0502779    19.79   0.000      .896666    1.093752
                             cov(S_Numsibshome_y1,C_housemarstatus_y4)|  -.1555509   .0133551   -11.65   0.000    -.1817264   -.1293753
                             cov(S_Numsibshome_y1,C_SIMPLhouseeduc_y4)|  -.0459618   .0071663    -6.41   0.000    -.0600074   -.0319161
                                     cov(S_Numsibshome_y1,C_region_y4)|   -.041782   .0056418    -7.41   0.000    -.0528398   -.0307243
                                cov(S_Numsibshome_y1,S_Numsibshome_y4)|   .7099621   .0148679    47.75   0.000     .6808215    .7391027
                                           cov(S_Numsibshome_y1,Alpha)|  -.1070858   .0294706    -3.63   0.000    -.1648472   -.0493245
                        cov(O_bineparhealthV1_y2,C_althouseholdage_y2)|   .0198473   .0186765     1.06   0.288    -.0167579    .0564524
                         cov(O_bineparhealthV1_y2,C_housemarstatus_y2)|   .0055525   .0038552     1.44   0.150    -.0020035    .0131085
                         cov(O_bineparhealthV1_y2,C_SIMPLhouseeduc_y2)|  -.0073273   .0019255    -3.81   0.000    -.0111013   -.0035533
                                 cov(O_bineparhealthV1_y2,C_region_y2)|   .0057818   .0016257     3.56   0.000     .0025955    .0089681
                            cov(O_bineparhealthV1_y2,S_Numsibshome_y2)|  -.0014165   .0031961    -0.44   0.658    -.0076808    .0048478
                        cov(O_bineparhealthV1_y2,O_bineparhealthV1_y4)|   .0226012    .001734    13.03   0.000     .0192026    .0259999
                        cov(O_bineparhealthV1_y2,C_althouseholdage_y4)|  -.0000618   .0136827    -0.00   0.996    -.0268793    .0267558
                         cov(O_bineparhealthV1_y2,C_housemarstatus_y4)|   .0064441   .0036208     1.78   0.075    -.0006525    .0135406
                         cov(O_bineparhealthV1_y2,C_SIMPLhouseeduc_y4)|  -.0094229   .0019933    -4.73   0.000    -.0133296   -.0055161
                                 cov(O_bineparhealthV1_y2,C_region_y4)|   .0033827   .0016145     2.10   0.036     .0002183     .006547
                            cov(O_bineparhealthV1_y2,S_Numsibshome_y4)|   -.005048   .0032251    -1.57   0.118    -.0113691    .0012732
                                       cov(O_bineparhealthV1_y2,Alpha)|   .0136493   .0045379     3.01   0.003     .0047552    .0225433
                         cov(C_althouseholdage_y2,C_housemarstatus_y2)|  -2.318159   .1041072   -22.27   0.000    -2.522205   -2.114112
                         cov(C_althouseholdage_y2,C_SIMPLhouseeduc_y2)|   .6289891   .0424016    14.83   0.000     .5458835    .7120946
                                 cov(C_althouseholdage_y2,C_region_y2)|  -.0435212   .0347929    -1.25   0.211     -.111714    .0246716
                            cov(C_althouseholdage_y2,S_Numsibshome_y2)|   1.190419   .0721089    16.51   0.000     1.049088     1.33175

                        Comment


                        • #13
                          I can see that a fixed effects structural equation can be estimated by restructuring the data into the wide format and repeating the analysis in each wave individually, but I'm not so clear on why this works. What magic is happening to allow me to produce the same fixed effects analysis that I estimated longitudinally in panel data before?
                          I'm not sure why the data have to be formatted to wide for xtdpdml. If you don't get your answer here, you might have luck asking Paul Allison that same question, who is one of the authors of the command: https://statisticalhorizons.com/our-...s/paul-allison

                          Comment


                          • #14
                            Hi Tom,

                            That's a good idea, I'll reach out to Paul. You see to suggest a similar methodology though below to estimate fixed effects, and post 4 here also suggests https://www.statalist.org/forums/for...ith-panel-data looking at each outcome as y_t1, y_t2, y_t3 etc., and I wonder if that is how to achieve fixed effects in SEM? And why conducting an analysis almost cross-sectionally like this works?

                            All the best,

                            John

                            Originally posted by Tom Scott View Post
                            John Adler how is your outcome measured. You can do fixed effects regression in sem, but it will depend on how your outcome is measured. For a continuous outcome, you can use the xtdpdml command: https://www3.nd.edu/~rwilliam/dynamic/. For other outcomes, you can use gsem with an Alpha term. For example:

                            Code:
                            gsem (y_t <- X1@a X2@b X3@c Alpha@1, logit)
                            (y_t+1 <- X1@a X2@b X3@c Alpha@1, logit)
                            ......
                            (Alpha <- X3*) */ correlate Alpha with time-varying covariates) /*

                            Comment


                            • #15
                              I'm not sure John Adler. I just know that's how it works. It's definitely more of a sem/gsem question than it is specific to fixed effects regression, so it might be worth starting a new thread asking your question. I imagine somewhere in the sem manual it would describe why you specify the regressions this way.

                              Comment

                              Working...
                              X