Announcement

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

  • SEM equivalence between long and wide panel data

    Hi all,

    I'm trying to estimate a simple auto-regressive model with SEM command, using both long and wide data formats, but I can't seem to get it to be identical as I think it should be.

    Here's a simple code, where I use the web-data of nlswork, limiting it to only 3 years of data (1968 to 1970):
    Code:
    clear all
    webuse nlswork, clear
    keep idcode year ln_wage
    keep if year <= 70
    
    * SEM in long format
    sem (ln_wage <- l1.ln_wage)
    
    * SEM in wide format
    reshape wide ln_wage, i(idcode) j(year)
    sem (ln_wage68@lag _cons@cons -> ln_wage69, ) (ln_wage69@lag _cons@cons -> ln_wage70, ) , /// 
    var(e.ln_wage69@E e.ln_wage70@E) nocapslatent
    In the wide format I need to be more explicit in constraining some of the paramters to be equal (I think). For that I constrained the AR coefficients to be identical (lag), the intercepts to be identical (cons) and the error terms to be identical (E).

    Here's the output, very similar coefficients but not identical:

    long:
    Code:
    Endogenous variables
      Observed: ln_wage
    
    Exogenous variables
      Observed: L.ln_wage
    
    Fitting target model:
    Iteration 0:   log likelihood = -794.93331  
    Iteration 1:   log likelihood = -794.93331  
    
    Structural equation model                                Number of obs = 1,852
    Estimation method: ml
    
    Log likelihood = -794.93331
    
    -------------------------------------------------------------------------------
                  |                 OIM
                  | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    --------------+----------------------------------------------------------------
    Structural    |
      ln_wage     |
          ln_wage |
              L1. |   .7021511   .0160968    43.62   0.000      .670602    .7337002
            _cons |   .5145363   .0251871    20.43   0.000     .4651705    .5639021
    --------------+----------------------------------------------------------------
    var(e.ln_wage)|   .0623013   .0020473                      .0584151    .0664461
    -------------------------------------------------------------------------------
    LR test of model vs. saturated: chi2(0) = 0.00                  Prob > chi2 = .
    wide

    Code:
    (1513 observations with missing values excluded)
    
    Endogenous variables
      Observed: ln_wage69 ln_wage70
    
    Exogenous variables
      Observed: ln_wage68
    
    Fitting target model:
    Iteration 0:   log likelihood = -261.74268  
    Iteration 1:   log likelihood = -260.83664  
    Iteration 2:   log likelihood = -260.83456  
    Iteration 3:   log likelihood = -260.83456  
    
    Structural equation model                                  Number of obs = 719
    Estimation method: ml
    
    Log likelihood = -260.83456
    
     ( 1)  - [ln_wage69]ln_wage68 + [ln_wage70]ln_wage69 = 0
     ( 2)  [/]var(e.ln_wage69) - [/]var(e.ln_wage70) = 0
     ( 3)  [ln_wage69]_cons - [ln_wage70]_cons = 0
    ---------------------------------------------------------------------------------
                    |                 OIM
                    | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    ----------------+----------------------------------------------------------------
    Structural      |
      ln_wage69     |
          ln_wage68 |   .6771415   .0183876    36.83   0.000     .6411025    .7131806
              _cons |   .5610107   .0293061    19.14   0.000     .5035719    .6184496
      --------------+----------------------------------------------------------------
      ln_wage70     |
          ln_wage69 |   .6771415   .0183876    36.83   0.000     .6411025    .7131806
              _cons |   .5610107   .0293061    19.14   0.000     .5035719    .6184496
    ----------------+----------------------------------------------------------------
    var(e.ln_wage69)|   .0578137   .0021561                      .0537386    .0621979
    var(e.ln_wage70)|   .0578137   .0021561                      .0537386    .0621979
    ---------------------------------------------------------------------------------
    LR test of model vs. saturated: chi2(4) = 97.42              Prob > chi2 = 0.0000
    Any guidance would be greatly appreciated!

  • #2
    The panels in this dataset are not balanced.
    If you drop the panels with < 3 observations, the results will match.

    Comment


    • #3
      Thanks!

      Comment


      • #4
        Hi,

        I have a question regarding using mediation analysis in Stata, with panel data, in the format country year (128 countries for 16 years).


        Name of the variables ( Y - dependent variable; M- Mediator; X - Independent Variable)

        Y - v2x_polyarchy; M - l.v2xcs_ccsi; X - l.CSOdisbursementsSector150_pc

        sem (l.v2xcs_ccsi <- l.CSOdisbursementsSector150_pc l.CSOdisbAllSectorsexclgov_pc l.totaldisbursementsexclCSO_pc l.log_GDPpc l.v2clrspct l.conflict)(v2x_polyarchy <- l.v2xcs_ccsi l.CSOdisbursementsSector150_pc l.CSOdisbAllSectorsexclgov_pc l.totaldisbursementsexclCSO_pc l.log_GDPpc l.v2clrspct l.conflict), nocapslatent

        estat teffects


        Our question: Is it appropriate to use sem, with our panel data (country year? If not do you have any alternative options?


        However, we are getting weird results; we didnt expect that the direct effect is negative. Can you help us with interpretation?
        Mediator: Core Civil Society Index
        Total Effect Direct Effect Indirect Effect
        CSO democracy assistance p.c 0.005*

        (0.002)
        -0.005***

        (0.001)
        0.01***

        (0.002)[CHK1]

        Comment

        Working...
        X