Announcement

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

  • using xtdpdml to perform SEM on panel data

    I have a panel of 46 countries and 4 time periods. My main outcome variable is the number of investments into a country, and I have around 10-12 (depending on the model) predictor variables that are all time-variant. I would like to run a structural equation model to understand causal pathways among variables. I ran a typical GSEM pooling all observations (I have copied the command and output at the bottom of this message), but that GSEM doesn't account for the panel data structure (each country is in the dataset 4 times with varying values on the country-level variables).

    I am trying to use xtdpdml in Stata 14.2 to account for the panel structure. When I use the xtdpdml command the model hasn't converged (so far) but there aren't errors. To do this, I use the following command:

    Code:
    xtdpdml numInvstm ysIMFFinMktDepth ysIMFFinMktAccess ysIMFinMktEfficient ysGrowthGDP yspcGDP ysGDP ysCosttoEnforceCtrctDBI ysPropRights ysCorruptGCI ysShareLawsuitsDBI ysJudicialStrong ysCrime , fiml semf(xtdpdml, r)
    However, this command does not specify the various paths I would like to constrain in the model, which is the main reason I'd like to use SEM.


    I tried simply copying the GSEM sytax into the xtdpdml command, but I get an error message, "invalid name" r(198)

    Code:
    xtset hostCountryNum yearSpanNum 
           panel variable:  hostCountryNum (unbalanced)
            time variable:  yearSpanNum, 1 to 4
                    delta:  1 unit
    
    
    xtdpdml (ysIMFFinMktDepth -> numInvstm, ) (ysIMFFinMktDepth -> ysGrowthGDP, ) ( zYSIMFFinMktAccess -> numInvstm, ) (yspcGDP -> numInvstm, ) (ysIMFinMktEfficient -> numInvstm, ) (ysGDP -> numInvstm, ) (ysGrowthGDP -> numInvstm, ) (ysControlCorruptionWGI -> numInvstm, ) (ysControlCorruptionWGI -> ysIMFFinMktDepth, ) (ysControlCorruptionWGI -> yspcGDP, ) (ysControlCorruptionWGI -> ysGettingCreditDBI, ) (ysControlCorruptionWGI -> ysCosttoEnforceCtrctDBI, ) (ysControlCorruptionWGI -> ysPropRights , ) (ysGettingCreditDBI -> numInvstm, ) (ysGettingCreditDBI -> ysIMFFinMktAccess , ) (ysCosttoEnforceCtrctDBI -> numInvstm, ) (ysShareLawsuitsDBI -> numInvstm, ) (ysJudicialStrong -> ysIMFinMktEfficient, ) (ysJudicialStrong -> ysCosttoEnforceCtrctDBI, ) (ysJudicialStrong -> ysPropRights , ) ( ysPropRights -> numInvstm, ) ( ysPropRights -> yspcGDP, ) ( ysPropRights -> ysGettingCreditDBI, ) ( ysPropRights -> ysCosttoEnforceCtrctDBI, )

    Is there a way to specify paths using the xtdpdml and if so, what is the syntax?

    If there is not, then can you recommend a different way of accounting for panel structure using a GSEM?


    -------------------------------------------------------------------------------------------------

    My command/results from a GSEM using pooled data are as follows:


    Code:
    gsem (ysIMFFinMktDepth -> numInvstm, ) (ysIMFFinMktDepth -> ysGrowthGDP, ) ( zYSIMFFinMktAccess -> numInvstm, ) (yspcGDP -> numInvstm, ) (ysIMFinMktEfficient -> numInvstm, ) (ysGDP -> numInvstm, ) (ysGrowthGDP -> numInvstm, ) (ysControlCorruptionWGI -> numInvstm, ) (ysControlCorruptionWGI -> ysIMFFinMktDepth, ) (ysControlCorruptionWGI -> yspcGDP, ) (ysControlCorruptionWGI -> ysGettingCreditDBI, ) (ysControlCorruptionWGI -> ysCosttoEnforceCtrctDBI, ) (ysControlCorruptionWGI -> ysPropRights , ) (ysGettingCreditDBI -> numInvstm, ) (ysGettingCreditDBI -> ysIMFFinMktAccess , ) (ysCosttoEnforceCtrctDBI -> numInvstm, ) (ysShareLawsuitsDBI -> numInvstm, ) (ysJudicialStrong -> ysIMFinMktEfficient, ) (ysJudicialStrong -> ysCosttoEnforceCtrctDBI, ) (ysJudicialStrong -> ysPropRights , ) ( ysPropRights -> numInvstm, ) ( ysPropRights -> yspcGDP, ) ( ysPropRights -> ysGettingCreditDBI, ) ( ysPropRights -> ysCosttoEnforceCtrctDBI, ), difficult iterate(5000)  nocapslatent

    Code:
    Generalized structural equation model    Number of    obs    =    184
    
    Response       : numInvstm    Number of    obs    =    174
    Family         : Gaussian
    Link           : identity
    
    Response       : ysGrowthGDP    Number of    obs    =    184
    Family         : Gaussian
    Link           : identity
    
    Response       : ysIMFFinMktDepth    Number of    obs    =    184
    Family         : Gaussian
    Link           : identity
    
    Response       : yspcGDP    Number of    obs    =    184
    Family         : Gaussian
    Link           : identity
    
    Response       : ysGettingCreditDBI    Number of    obs    =    184
    Family         : Gaussian
    Link           : identity
    
    Response       : ysCosttoEnforceCtr~I    Number of    obs    =    177
    Family         : Gaussian
    Link           : identity
    
    Response       : ysPropRights    Number of    obs    =    184
    Family         : Gaussian
    Link           : identity
    
    Response       : ysIMFFinMktAccess    Number of    obs    =    184
    Family         : Gaussian
    Link           : identity
    
    Response       : ysIMFinMktEfficient    Number of    obs    =    184
    Family         : Gaussian
    Link           : identity
    
    Log likelihood = -4432.3728 
    Coef. Std. Err. z P>z [95% Conf. Interval]
    numInvstm <-
    ysGrowthGDP -544.5438 390.142 -1.40 0.163 -1309.208 220.1204
    ysIMFFinMktDepth 158.0025 239.8043 0.66 0.510 -312.0052 628.0103
    yspcGDP -.0241747 .0108955 -2.22 0.027 -.0455294 -.00282
    ysGettingCreditDBI -.8636417 2.021269 -0.43 0.669 -4.825256 3.097973
    ysCosttoEnforceCtrctDBI -3.686959 2.724383 -1.35 0.176 -9.026652 1.652733
    ysPropRights - 56.15982 69.96886 -0.80 0.422 -193.2963 80.97663
    ysIMFinMktEfficient -375.6699 139.4893 -2.69 0.007 -649.0639 -102.276
    zYSIMFFinMktAccess -30.47716 41.72698 -0.73 0.465 -112.2605 51.30622
    ysGDP .5888149 .0322119 18.28 0.000 .5256806 .6519491
    ysControlCorruptionWGI 184.8379 110.4447 1.67 0.094 -31.62974 401.3055
    ysShareLawsuitsDBI 2.970568 1.747723 1.70 0.089 -.4549067 6.396043
    _cons 527.9779 376.123 1.40 0.160 -209.2097 1265.165
    ysGrowthGDP <-
    ysIMFFinMktDepth -.0057494 .0336923 -0.17 0.865 -.071785 .0602862
    _cons .0885477 .0103453 8.56 0.000 .0682712 .1088242
    ysIMFFinMktDepth <-
    ysControlCorruptionWGI .0881752 .0313986 2.81 0.005 .0266351 .1497153
    _cons .2719619 .0196398 13.85 0.000 .2334686 .3104552
    yspcGDP <-
    ysPropRights -1034.483 458.2239 -2.26 0.024 -1932.585 -136.3808
    ysControlCorruptionWGI 3464.177 715.1258 4.84 0.000 2062.557 4865.798
    _cons 10573.29 1966.944 5.38 0.000 6718.15 14428.43
    ysGettingCreditDBI <-
    ysPropRights -1.524463 2.689148 -0.57 0.571 -6.795096 3.746171
    ysControlCorruptionWGI 10.75614 4.084933 2.63 0.008 2.74982 18.76246
    _cons 67.12487 11.52756 5.82 0.000 44.53127 89.71848
    ysCosttoEnforceCtr~I <-
    ysPropRights -1.847554 2.509315 -0.74 0.462 -6.76572 3.070613
    ysControlCorruptionWGI 7.643785 2.767113 2.76 0.006 2.220343 13.06723
    ysJudicialStrong 1.10415 2.05058 0.54 0.590 -2.914914 5.123214
    _cons 73.69556 7.321003 10.07 0.000 59.34665 88.04446
    ysPropRights <-
    ysControlCorruptionWGI .35701 .0761227 4.69 0.000 .2078123 .5062077
    ysJudicialStrong .5886083 .0408296 14.42 0.000 .5085837 .6686328
    _cons 1.874249 .1676438 11.18 0.000 1.545673 2.202825
    ysIMFFinMktAccess <-
    ysGettingCreditDBI -0002657 .0009793 -0.27 0.786 -.0021851 .0016536
    _cons .2421832 .0583001 4.15 0.000 .127917 .3564493
    ysIMFinMktEfficient <-
    ysJudicialStrong .0744381 .0249939 2.98 0.003 .025451 .1234253
    _cons -.0128845 .0903314 -0.14 0.887 -.1899308 .1641617
    var(e.numInvstm) 170360.2 . . .
    var(e.ysGrowthGDP) .0082315 .0008582 .0067102 .0100977
    var(e.ysIMFFinMktDepth) .0377896 .0039398 .0308055 .0463571
    var(e.yspcGDP) 1.11e+07 . . .
    var(e.ysGettingCredit~I) 345.8314 . . .
    var(e.ysCosttoEnforce~I) 153.3717 . . .
    var(e.ysPropRights) .1387054 .0144616 .1130696 .1701536
    var(e.ysIMFFinMktAccess) .0571513 .0059584 .0465889 .0701084
    var(e.ysIMFinMktEffic~t) .0832336 .0086777 .0678508 .102104
    Warning: convergence notachieved
    (Although this particular model didn't achieve convergence, I've played around with it in the past and it has converged...)

  • #2
    If you haven't already, take a look at

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

    It includes convergence tips. The entire support page is

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

    With only 46 countries you may be pushing it with 12 independent variables. Consider simplifying the model and building back up. (That is my generic advice for almost any convergence problem. You may be able to identify a variable that is causing you grief, and then figure out what to do about it. Don't try to estimate the entire monster model all at once. For example, a time-varying variable that actually varies very little across time may cause xtdpdml problems,)

    xtdpdml can generate the Stata code. You can then possibly hand tweak to do things xtdpdml can't do easily. It can also generate code for Mplus and R's lavaan, which may or may not be able to handle the problem better.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

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

    Comment


    • #3
      Given that the 46 countries is a small N for the complexity of the model, I'm hoping to take advantage of the data panel structure (about 200 observations across the 4 time periods). I'm wondering-- would it be valid (helpful) to run the SEM with groups=time periods and with structural coefficients constrained to be the same across all groups? (Rather than using the panel data structure?)

      Comment


      • #4
        It would be simpler to use the group structure. I don't know if it would be better since the groups aren't independent and you are ignoring all the cross-time correlations. But you could try it.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

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

        Comment


        • #5
          Thanks for your help! One more question. Since the final outcome variable is a count of the number of investments into a country (within a given time period, it ranges from zero investments into some countries to about 9000 into others, and is right skewed; all other variables are continuous), I have been trying to run models as GSEM. However, when I run as SEM, they converge very quickly. Also, SEM has some features GSEM doesn't have such as constraining coefficients across groups. How inaccurate is it to use SEM rather than GSEM in this context. I'm thinking I can at least use SEM for intermediate models to see what variables may be causing grief, for instance, and to get starting values for GSEM) but I'm wondering how far off the SEM results are from what I would get in GSEM.

          Thanks again for all of your help with this!

          Comment


          • #6
            If you need to use a count model that further complicates things. Sometimes linear models work fine with count variables.As μ increases, the Poisson distribution approximates a normal distribution. So SEM might be ok.

            You are trying to do pretty complicated things here. You may just have to settle for what works, while acknowledging the limitations, e.g. either the stat theory isn't clear or the software and hardware aren't up to the task.

            You might try doable approximations first and then let you computer estimate the final model while you are away for a month on winter break!
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

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

            Comment

            Working...
            X