Announcement

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

  • Mediation in generalized differnce-in-difference.

    Dear All,

    I want to estimate the impact of a state policy, adopted by different states at different times, on population standardized rates of poisonings. I have data from the 50 US states for 26 quarters. I have created a variable *post* that is an interaction of if the state is treated (ever adopted said policy) and its the quarters following treatement (post=treatMA*time_after_treat). My data looks as follows:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(narc_nocod2 post) byte treatMA float(qavg_pct_lf_unemp pct_lhs pct_hs perc_black perc_nonwhite pctmale pctover65 state_share_rural_2010 md_100000 pa_100000 rn_100000 poly_all2)
     2.769937 0 1  7.566667  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395  2.769937
    1.2464718 0 1  7.566667  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395  .9694781
     .9694781 0 1  7.733333  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395  .9694781
    3.7394154 0 1       7.5  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395  3.323925
     2.769937 0 1  7.733333  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395 2.4929435
    2.4929435 0 1  7.466667  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395 2.4929435
    1.1079749 0 1       7.5  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395 1.1079749
     1.938956 0 1  7.466667  7.7 27.7  4.545096 28.878407 .52014977 .08111796 .3398058 272.16888 70.290695  915.4395  1.938956
     3.148964 0 1  7.166667  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514  3.012052
     .8214688 0 1  7.166667  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514  .6845573
     2.053672 0 1  7.333333  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514 1.9167606
    .54764587 0 1  7.033333  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514 .54764587
    2.4644065 0 1         7  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514 2.1905835
     .6845573 0 1         7  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514  .6845573
     1.779849 0 1  7.033333  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514 1.6429377
     1.506026 0 1  7.333333  7.7 27.7 4.6983337  29.19467  .5209735  .0854725 .3398058  269.0507  69.48538  904.9514  1.506026
     2.442185 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408 2.1708307
    1.3567692 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408 1.3567692
    2.1708307 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408 2.1708307
     .8140616 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408  .8140616
     2.442185 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408  2.442185
    1.3567692 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408 1.3567692
    1.2210923 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408 1.2210923
    .27135384 0 1         7  7.7 27.7  4.786403   29.4967  .5228226 .08950587 .3398058 266.93665  68.93941  897.8408 .27135384
     .6790646 0 1         7  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528  .6790646
    2.1730065 0 1         7  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528 1.9013808
    2.1730065 0 1       6.6  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528 1.9013808
    2.4446325 0 1  6.866667  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528 2.3088195
    1.2223163 0 1       6.6  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528 1.0865033
     .9506904 0 1         7  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528  .9506904
    1.0865033 0 1         7  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528 1.0865033
     .8148775 0 1  6.866667  7.7 27.7  4.795406    29.827  .5233248 .09415574 .3398058  266.9997  68.95569  898.0528  .6790646
    2.7116916 0 1  6.633333  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306 2.7116916
      .949092 0 1       6.5  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306  .8135075
     .8135075 0 1       6.5  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306  .8135075
    3.1184454 0 1       6.5  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306 3.1184454
     .8135075 0 1       6.5  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306  .8135075
    2.0337687 0 1       6.5  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306  1.898184
     1.627015 0 1       6.5  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306 1.4914304
    .40675375 0 1  6.633333  7.7 27.7  4.818702  30.10442  .5234001 .09878014 .3398058  266.6363  68.86184  896.8306 .40675375
    1.0788883 0 1  6.866667  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716 1.0788883
    1.4834714 0 1         7  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716  .9440272
    1.6183325 0 1  6.766667  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716 1.4834714
      2.56236 0 1  6.766667  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716  2.427499
     2.966943 0 1         7  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716  2.697221
    1.2137494 0 1         7  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716 1.2137494
    1.3486104 0 1  6.866667  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716 1.2137494
     .6743052 0 1         7  7.7 27.7  4.911483  30.41499  .5231637 .10406608 .3398058  265.1322   68.4734  891.7716  .6743052
    1.4869165 0 1  7.133333  7.7 27.7         .         .         .         . .3398058  265.8877  68.66851  894.3127 1.4869165
    1.3517423 0 1  7.033333  7.7 27.7         .         .         .         . .3398058  265.8877  68.66851  894.3127  1.216568
    2.1627877 0 1  7.033333  7.7 27.7         .         .         .         . .3398058  265.8877  68.66851  894.3127 2.0276134
    2.7034845 0 1  7.133333  7.7 27.7         .         .         .         . .3398058  265.8877  68.66851  894.3127 2.7034845
    1.2919805 0 0  9.666667 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926  1.271142
    2.2713852 0 0  8.633333 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926 2.0213244
     1.312819 0 0        10 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926  1.271142
    1.3336573 0 0 10.166667 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926  1.208627
     2.646476 0 0 10.166667 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926  2.313062
    2.5006075 0 0        10 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926 2.1255164
    1.0835966 0 0  8.633333 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926  .9585662
    2.2922235 0 0  9.666667 15.2   31 26.847376   28.9922  .4852006 .14009614 .4096304  209.7536 29.958845 1025.8926 2.1671932
      1.34979 0 0       8.2 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753  1.308258
      1.55745 0 0  8.066667 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753  1.495152
      2.18043 0 0         8 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753  1.910472
     2.554218 0 0  7.666667 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753  2.138898
     1.515918 0 0  7.666667 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753  1.474386
     1.370556 0 0         8 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753  1.225194
     2.761878 0 0       8.2 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753  2.305026
     2.637282 0 0  8.066667 15.2   31 26.951054  29.14335  .4851257 .14522338 .4096304  209.0549  29.85905 1022.4753 2.3465579
    1.3249255 0 0       7.1 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131 1.2628196
      2.21511 0 0  7.133333 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131 1.9459845
    1.3456275 0 0       7.4 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131 1.2214158
    1.2835217 0 0  7.133333 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131 1.2214158
     2.649851 0 0       7.4 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131  2.173706
    1.9252825 0 0  7.233333 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131  1.573349
    2.1530042 0 0       7.1 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131 1.9459845
     1.594051 0 0  7.233333 15.2   31 27.068136 29.300863  .4850109 .14920263 .4096304  208.4697  29.77547 1019.6131  1.573349
    1.7965997 0 0  7.233333 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216 1.4042388
    1.6520457 0 0  6.233333 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216 1.3629377
     2.127009 0 0       6.6 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216 2.0031054
     1.548793 0 0       6.6 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216 1.5281423
    1.7139975 0 0         7 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216 1.5074917
    1.5074917 0 0  7.233333 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216 1.4248894
    1.5694435 0 0         7 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216 1.5281423
    1.3422872 0 0  6.233333 15.2   31  27.15205 29.434875  .4848089 .15354267 .4096304  207.8785 29.691027 1016.7216  1.300986
    1.6072003 0 0         6 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884  1.421754
    1.3187284 0 0       6.1 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884 1.1332822
    1.0714668 0 0       6.1 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884 1.0714668
    1.6072003 0 0       6.1 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884 1.4835695
     .9684412 0 0  6.166667 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884  .9066258
     1.730831 0 0  6.166667 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884  1.586595
     1.236308 0 0       6.1 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884 1.2157028
     1.256913 0 0         6 15.2   31  27.26294  29.60861   .484659  .1574272 .4096304  207.4219 29.625814 1014.4884 1.2157028
    1.1100273 0 0  5.833333 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223 1.0689152
    1.6033728 0 0  5.833333 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223 1.4594804
    1.0278031 0 0  5.966667 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223   .986691
    1.8089335 0 0  5.966667 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223  1.623929
    1.0072471 0 0       5.8 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223  .9661349
    1.4389243 0 0  5.833333 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223 1.2744758
    1.7472652 0 0       5.8 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223 1.5417047
     1.377256 0 0  5.833333 15.2   31  27.34045 29.740936  .4843596  .1613207 .4096304 207.01993   29.5684 1012.5223  1.336144
    end
    I ran a generalized diff-in-diff as follows:

    Code:
    reghdfe narc_nocod2 post treatMA qavg_pct_lf_unemp pct_lhs  pct_hs perc_black  perc_non
    > white pctmale pctover65  /// 
    > state_share_rural_2010 md_100000 pa_100000 rn_100000 [weight=popestimate] if outcome==2
    > , absorb(i.qtr i.stateFIPS i.stateFIPS#(c.qtr c.qtrsq)) vce(cluster stateFIPS)
    (analytic weights assumed)
    weight popestimate can only contain strictly positive reals, but 1 missing values were fo
    > und (will be dropped)
    (converged in 9 iterations)
    note: treatMA omitted because of collinearity
    note: pct_lhs omitted because of collinearity
    note: pct_hs omitted because of collinearity
    note: state_share_rural_2010 omitted because of collinearity
    
    HDFE Linear regression                            Number of obs   =      1,128
    Absorbing 3 HDFE groups                           F(   9,     46) =       1.79
    Statistics robust to heteroskedasticity           Prob > F        =     0.0969
                                                      R-squared       =     1.0000
                                                      Adj R-squared   =     1.0000
                                                      Within R-sq.    =     0.0143
    Number of clusters (stateFIPS) =         47       Root MSE        =     0.1546
    
                                           (Std. Err. adjusted for 47 clusters in stateFIPS)
    ----------------------------------------------------------------------------------------
                           |               Robust
               narc_nocod2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -----------------------+----------------------------------------------------------------
                      post |   .0987154   .0343737     2.87   0.006     .0295247     .167906
                   treatMA |          0  (omitted)
         qavg_pct_lf_unemp |  -.0056164   .0205179    -0.27   0.786    -.0469167    .0356839
                   pct_lhs |          0  (omitted)
                    pct_hs |          0  (omitted)
                perc_black |  -.1040779   .3172873    -0.33   0.744    -.7427441    .5345884
             perc_nonwhite |   .0279966   .2423516     0.12   0.909    -.4598319    .5158251
                   pctmale |   101.4251   95.03542     1.07   0.291     -89.8713    292.7215
                 pctover65 |   49.40179   21.94308     2.25   0.029     5.232655    93.57092
    state_share_rural_2010 |          0  (omitted)
                 md_100000 |  -.0401727   .0841578    -0.48   0.635    -.2095736    .1292282
                 pa_100000 |   .0077521   .2196394     0.04   0.972     -.434359    .4498633
                 rn_100000 |   .0109752   .0256446     0.43   0.671    -.0406447    .0625951
    ----------------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -------------------------------------------------------------------------+
               Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     |
    -----------------------+-------------------------------------------------|
                       qtr |           24              24              0     |
                 stateFIPS |            0              47             47 *   |
           stateFIPS#c.qtr |           47              47              0 ?   |
         stateFIPS#c.qtrsq |           47              47              0 ?   |
    -------------------------------------------------------------------------+
    ? = number of redundant parameters may be higher
    * = fixed effect nested within cluster; treated as redundant for DoF computation
    Poisonings can be single substance or poly-drug poisonings. Population standardized rated of poly-drug poisonings [variable name poly_all2] is obviously highly correlated to all poisonings [variable name narc_nocod2] since poly-drug poisonings are a subset of all poisonings. To see the correlation i added poly-all2 as an additional predictor to get the following:

    Code:
    reghdfe narc_nocod2 post poly_all2 treatMA qavg_pct_lf_unemp pct_lhs  pct_hs perc_black
    >   perc_nonwhite pctmale pctover65  /// 
    > state_share_rural_2010 md_100000 pa_100000 rn_100000 [weight=popestimate] if outcome==2
    > , absorb(i.qtr i.stateFIPS i.stateFIPS#(c.qtr c.qtrsq)) vce(cluster stateFIPS)
    (analytic weights assumed)
    weight popestimate can only contain strictly positive reals, but 1 missing values were fo
    > und (will be dropped)
    (converged in 9 iterations)
    note: treatMA omitted because of collinearity
    note: pct_lhs omitted because of collinearity
    note: pct_hs omitted because of collinearity
    note: state_share_rural_2010 omitted because of collinearity
    
    HDFE Linear regression                            Number of obs   =      1,128
    Absorbing 3 HDFE groups                           F(  10,     46) =    1988.38
    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                      R-squared       =     1.0000
                                                      Adj R-squared   =     1.0000
                                                      Within R-sq.    =     0.9788
    Number of clusters (stateFIPS) =         47       Root MSE        =     0.0227
    
                                           (Std. Err. adjusted for 47 clusters in stateFIPS)
    ----------------------------------------------------------------------------------------
                           |               Robust
               narc_nocod2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -----------------------+----------------------------------------------------------------
                      post |   .0054146   .0054542     0.99   0.326    -.0055642    .0163933
                 poly_all2 |   1.013471   .0073252   138.35   0.000     .9987264    1.028216
                   treatMA |          0  (omitted)
         qavg_pct_lf_unemp |   .0035934   .0035235     1.02   0.313     -.003499    .0106859
                   pct_lhs |          0  (omitted)
                    pct_hs |          0  (omitted)
                perc_black |  -.0160729   .0531401    -0.30   0.764    -.1230383    .0908926
             perc_nonwhite |   .0011686   .0416198     0.03   0.978    -.0826076    .0849448
                   pctmale |   14.45668   11.13663     1.30   0.201    -7.960195    36.87355
                 pctover65 |   1.889488   3.229166     0.59   0.561    -4.610485    8.389461
    state_share_rural_2010 |          0  (omitted)
                 md_100000 |   .0083453   .0063331     1.32   0.194    -.0044026    .0210932
                 pa_100000 |   .0193383   .0219901     0.88   0.384    -.0249255    .0636022
                 rn_100000 |  -.0029487   .0016219    -1.82   0.076    -.0062134    .0003161
    ----------------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -------------------------------------------------------------------------+
               Absorbed FE |  Num. Coefs.  =   Categories  -   Redundant     |
    -----------------------+-------------------------------------------------|
                       qtr |           24              24              0     |
                 stateFIPS |            0              47             47 *   |
           stateFIPS#c.qtr |           47              47              0 ?   |
         stateFIPS#c.qtrsq |           47              47              0 ?   |
    -------------------------------------------------------------------------+
    ? = number of redundant parameters may be higher
    * = fixed effect nested within cluster; treated as redundant for DoF computation
    I want to check if the increase in poisonings is therefore mediated by an increase in poly-drug poisonings. My understanding is that the structural sem command can help me pin down any mediation effect? However, it is not clear to me what should the specification be? I tried the following:

    Code:
    sem (narc_nocod2 <- post poly_all2 treatMA  qavg_pct_lf_unemp pct_lhs pct_hs   perc_bl
    > ack perc_nonwhite  pctmale pctover65  ///  // perfect
    > state_share_rural_2010 md_100000 pa_100000 rn_100000  _IstateFIPs_* _IstaXqtrs_* qtrdum
    > * statedum*) (lnpoly_all2 <- post)
    (396 observations with missing values excluded)
    
    Endogenous variables
    
    Observed:  narc_nocod2 lnpoly_all2
    
    Exogenous variables
    
    Observed:  post poly_all2 treatMA qavg_pct_lf_unemp pct_lhs pct_hs perc_black
               perc_nonwhite pctmale pctover65 state_share_rural_2010 md_100000 pa_100000
               rn_100000 _IstateFIPs_2 _IstateFIPs_4 _IstateFIPs_5 _IstateFIPs_6
               _IstateFIPs_8 _IstateFIPs_9 _IstateFIPs_11 _IstateFIPs_12 _IstateFIPs_13
               _IstateFIPs_15 _IstateFIPs_16 _IstateFIPs_17 _IstateFIPs_18 _IstateFIPs_19
               _IstateFIPs_20 _IstateFIPs_21 _IstateFIPs_22 _IstateFIPs_23 _IstateFIPs_24
               _IstateFIPs_25 _IstateFIPs_26 _IstateFIPs_27 _IstateFIPs_28 _IstateFIPs_29
               _IstateFIPs_30 _IstateFIPs_31 _IstateFIPs_32 _IstateFIPs_33 _IstateFIPs_34
               _IstateFIPs_35 _IstateFIPs_36 _IstateFIPs_37 _IstateFIPs_38 _IstateFIPs_39
               _IstateFIPs_40 _IstateFIPs_41 _IstateFIPs_42 _IstateFIPs_44 _IstateFIPs_45
               _IstateFIPs_46 _IstateFIPs_47 _IstateFIPs_48 _IstateFIPs_49 _IstateFIPs_50
               _IstateFIPs_51 _IstateFIPs_53 _IstateFIPs_54 _IstateFIPs_55 _IstateFIPs_56
               _IstaXqtrs_2 _IstaXqtrs_4 _IstaXqtrs_5 _IstaXqtrs_6 _IstaXqtrs_8
               _IstaXqtrs_9 _IstaXqtrs_11 _IstaXqtrs_12 _IstaXqtrs_13 _IstaXqtrs_15
               _IstaXqtrs_16 _IstaXqtrs_17 _IstaXqtrs_18 _IstaXqtrs_19 _IstaXqtrs_20
               _IstaXqtrs_21 _IstaXqtrs_22 _IstaXqtrs_23 _IstaXqtrs_24 _IstaXqtrs_25
               _IstaXqtrs_26 _IstaXqtrs_27 _IstaXqtrs_28 _IstaXqtrs_29 _IstaXqtrs_30
               _IstaXqtrs_31 _IstaXqtrs_32 _IstaXqtrs_33 _IstaXqtrs_34 _IstaXqtrs_35
               _IstaXqtrs_36 _IstaXqtrs_37 _IstaXqtrs_38 _IstaXqtrs_39 _IstaXqtrs_40
               _IstaXqtrs_41 _IstaXqtrs_42 _IstaXqtrs_44 _IstaXqtrs_45 _IstaXqtrs_46
               _IstaXqtrs_47 _IstaXqtrs_48 _IstaXqtrs_49 _IstaXqtrs_50 _IstaXqtrs_51
               _IstaXqtrs_53 _IstaXqtrs_54 _IstaXqtrs_55 _IstaXqtrs_56 qtrdum1 qtrdum2
               qtrdum3 qtrdum4 qtrdum5 qtrdum6 qtrdum7 qtrdum8 qtrdum9 qtrdum10 qtrdum11
               qtrdum12 qtrdum13 qtrdum14 qtrdum15 qtrdum16 qtrdum17 qtrdum18 qtrdum19
               qtrdum20 qtrdum21 qtrdum22 qtrdum23 qtrdum24 qtrdum25 qtrdum26 statedum1
               statedum2 statedum3 statedum4 statedum5 statedum6 statedum7 statedum8
               statedum9 statedum10 statedum11 statedum12 statedum13 statedum14 statedum15
               statedum16 statedum17 statedum18 statedum19 statedum20 statedum21 statedum22
               statedum23 statedum24 statedum25 statedum26 statedum27 statedum28 statedum29
               statedum30 statedum31 statedum32 statedum33 statedum34 statedum35 statedum36
               statedum37 statedum38 statedum39 statedum40 statedum41 statedum42 statedum43
               statedum44 statedum45 statedum46 statedum47 statedum48 statedum49 statedum50
               statedum51
    
    Fitting target model:
    
    Iteration 0:   log likelihood = -487821.11  (not concave)
    Iteration 1:   log likelihood = -487821.11  (not concave)
    Iteration 2:   log likelihood = -487821.11  (not concave)
    Iteration 3:   log likelihood = -487821.11  (not concave)
    Iteration 4:   log likelihood = -487821.11  (not concave)
    Iteration 5:   log likelihood = -487821.11  (not concave)
    Iteration 6:   log likelihood = -487821.11  (not concave)
    Iteration 7:   log likelihood = -487821.11  (not concave)
    Iteration 8:   log likelihood = -487821.11  (not concave)
    Iteration 9:   log likelihood = -487821.11  (not concave)
    Iteration 10:  log likelihood = -487821.11  (not concave)
    Iteration 11:  log likelihood = -487821.11  (not concave)
    Iteration 12:  log likelihood = -487821.11  (not concave)
    Iteration 13:  log likelihood = -487821.11  (not concave)
    Iteration 14:  log likelihood = -487821.11  (not concave)
    Iteration 15:  log likelihood = -487821.11  (not concave)


    I tried a much simpler model:

    Code:
    sem (poly_all2 <- post)(narc_nocod2 <- poly_all2 post)
    (1 observations with missing values excluded)
    
    Endogenous variables
    
    Observed:  poly_all2 narc_nocod2
    
    Exogenous variables
    
    Observed:  post
    
    Fitting target model:
    
    Iteration 0:   log likelihood = -1772.9944 
    Iteration 1:   log likelihood = -1772.9944 
    
    Structural equation model                       Number of obs     =      2,651
    Estimation method  = ml
    Log likelihood     = -1772.9944
    
    -----------------------------------------------------------------------------------
                      |                 OIM
                      |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
    Structural        |
      poly_all2 <-    |
                 post |  -.2279079   .0423372    -5.38   0.000    -.3108872   -.1449286
                _cons |   1.550983   .0186604    83.12   0.000     1.514409    1.587556
      ----------------+----------------------------------------------------------------
      narc_nocod2 <-  |
            poly_all2 |    1.07609   .0018252   589.58   0.000     1.072513    1.079667
                 post |  -.0019335   .0040003    -0.48   0.629    -.0097739    .0059069
                _cons |  -.0177858     .00333    -5.34   0.000    -.0243124   -.0112592
    ------------------+----------------------------------------------------------------
      var(e.poly_all2)|   .7437761   .0204292                      .7047942     .784914
    var(e.narc_nocod2)|   .0065684   .0001804                      .0062241    .0069317
    -----------------------------------------------------------------------------------
    LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .


    Is this a correct specification? How should these results be interpreted in terms of mediation by poly_all2?

    Thank you in advance for your help.
    Sincerely,
    Sumedha.

  • #2
    Your simple -sem- model, at least disregarding whether other variables are needed, is appropriate. To interpret the findings, run -estat teffects- after it, and Stata will give you the direct, indirect, and total effects. Once you are comfortable with that, if you want to extend the -sem- to include those other variables, as you showed in #1, that, too, is fine. And, again, -estat teffects- following that model will give you direct and indirect effects. You will just have to read through more output to focus on the effects of interest.

    Comment


    • #3
      Thank you for helping me on all fronts, Prof. Schechter. I managed to extend the sem spec but cannot replicate the specification that I used in the linear gdid. The closest I got is as follows:

      Code:
      sem (poly_all2 <- post treatMA qavg_pct_lf_unemp pct_lhs pct_hs perc_black perc_nonwhit
      > e  pctmale pctover65  ///  // perfect
      > state_share_rural_2010 md_100000 pa_100000 rn_100000 qtr qtrsq)(narc_nocod2 <- poly_all
      > 2 post treatMA qavg_pct_lf_unemp pct_lhs pct_hs perc_black perc_nonwhite  pctmale pctov
      > er65  ///  // perfect
      > state_share_rural_2010 md_100000 pa_100000 rn_100000 qtr qtrsq)
      (198 observations with missing values excluded)
      
      Endogenous variables
      
      Observed:  poly_all2 narc_nocod2
      
      Exogenous variables
      
      Observed:  post treatMA qavg_pct_lf_unemp pct_lhs pct_hs perc_black perc_nonwhite
                 pctmale pctover65 state_share_rural_2010 md_100000 pa_100000 rn_100000 qtr
                 qtrsq
      
      Fitting target model:
      
      Iteration 0:   log likelihood =  -32358.33 
      Iteration 1:   log likelihood =  -32358.33 
      
      Structural equation model                       Number of obs     =      1,128
      Estimation method  = ml
      Log likelihood     =  -32358.33
      
      ----------------------------------------------------------------------------------------
                             |                 OIM
                             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -----------------------+----------------------------------------------------------------
      Structural             |
        poly_all2 <-         |
                        post |  -.0707247   .0404754    -1.75   0.081    -.1500551    .0086056
                     treatMA |   .1162158    .035925     3.23   0.001     .0458041    .1866275
           qavg_pct_lf_unemp |   .0120607   .0127307     0.95   0.343     -.012891    .0370125
                     pct_lhs |   .0074058   .0075034     0.99   0.324    -.0073006    .0221122
                      pct_hs |   .0033811   .0057335     0.59   0.555    -.0078563    .0146185
                  perc_black |  -.0216054   .0035103    -6.15   0.000    -.0284855   -.0147253
               perc_nonwhite |   .0007225   .0016806     0.43   0.667    -.0025715    .0040165
                     pctmale |  -23.57071   4.830302    -4.88   0.000    -33.03792   -14.10349
                   pctover65 |  -1.939624   1.367206    -1.42   0.156    -4.619298    .7400495
        state_share_rur~2010 |   .9324672   .1535129     6.07   0.000     .6315875    1.233347
                   md_100000 |  -.0008502   .0003761    -2.26   0.024    -.0015874    -.000113
                   pa_100000 |   .0057361   .0013718     4.18   0.000     .0030473    .0084248
                   rn_100000 |  -.0006581   .0001202    -5.47   0.000    -.0008938   -.0004225
                         qtr |  -.0113253   .0083851    -1.35   0.177    -.0277598    .0051092
                       qtrsq |   .0003786    .000294     1.29   0.198    -.0001976    .0009549
                       _cons |   13.31349   2.529058     5.26   0.000     8.356626    18.27035
        ---------------------+----------------------------------------------------------------
        narc_nocod2 <-       |
                   poly_all2 |   1.023986   .0024008   426.52   0.000      1.01928    1.028691
                        post |   .0003034    .003268     0.09   0.926    -.0061018    .0067087
                     treatMA |   .0085974   .0029101     2.95   0.003     .0028936    .0143011
           qavg_pct_lf_unemp |   .0004347   .0010269     0.42   0.672     -.001578    .0024474
                     pct_lhs |  -.0002593   .0006053    -0.43   0.668    -.0014457     .000927
                      pct_hs |  -.0012406   .0004624    -2.68   0.007    -.0021468   -.0003343
                  perc_black |   .0000265   .0002878     0.09   0.927    -.0005375    .0005905
               perc_nonwhite |   .0002253   .0001355     1.66   0.096    -.0000403    .0004909
                     pctmale |   .3199083   .3935682     0.81   0.416    -.4514712    1.091288
                   pctover65 |   .3493729   .1103393     3.17   0.002     .1331117     .565634
        state_share_rur~2010 |  -.0093318   .0125789    -0.74   0.458     -.033986    .0153224
                   md_100000 |  -.0001036   .0000304    -3.41   0.001    -.0001632    -.000044
                   pa_100000 |   .0000628   .0001115     0.56   0.573    -.0001557    .0002813
                   rn_100000 |  -.0000109   9.82e-06    -1.11   0.269    -.0000301    8.38e-06
                         qtr |   .0000396   .0006767     0.06   0.953    -.0012866    .0013659
                       qtrsq |  -.0000214   .0000237    -0.90   0.368    -.0000679    .0000251
                       _cons |  -.1289471   .2064137    -0.62   0.532    -.5335106    .2756163
      -----------------------+----------------------------------------------------------------
             var(e.poly_all2)|   .1766196    .007437                      .1626286    .1918143
           var(e.narc_nocod2)|   .0011483   .0000484                      .0010573    .0012471
      ----------------------------------------------------------------------------------------
      LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .
      
      . estat teffects
      
      
      Direct effects
      ----------------------------------------------------------------------------------------
                             |                 OIM
                             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -----------------------+----------------------------------------------------------------
      Structural             |
        poly_all2 <-         |
                        post |  -.0707247   .0404754    -1.75   0.081    -.1500551    .0086056
                     treatMA |   .1162158    .035925     3.23   0.001     .0458041    .1866275
           qavg_pct_lf_unemp |   .0120607   .0127307     0.95   0.343     -.012891    .0370125
                     pct_lhs |   .0074058   .0075034     0.99   0.324    -.0073006    .0221122
                      pct_hs |   .0033811   .0057335     0.59   0.555    -.0078563    .0146185
                  perc_black |  -.0216054   .0035103    -6.15   0.000    -.0284855   -.0147253
               perc_nonwhite |   .0007225   .0016806     0.43   0.667    -.0025715    .0040165
                     pctmale |  -23.57071   4.830302    -4.88   0.000    -33.03792   -14.10349
                   pctover65 |  -1.939624   1.367206    -1.42   0.156    -4.619298    .7400495
        state_share_rur~2010 |   .9324672   .1535129     6.07   0.000     .6315875    1.233347
                   md_100000 |  -.0008502   .0003761    -2.26   0.024    -.0015874    -.000113
                   pa_100000 |   .0057361   .0013718     4.18   0.000     .0030473    .0084248
                   rn_100000 |  -.0006581   .0001202    -5.47   0.000    -.0008938   -.0004225
                         qtr |  -.0113253   .0083851    -1.35   0.177    -.0277598    .0051092
                       qtrsq |   .0003786    .000294     1.29   0.198    -.0001976    .0009549
        ---------------------+----------------------------------------------------------------
        narc_nocod2 <-       |
                   poly_all2 |   1.023986   .0024008   426.52   0.000      1.01928    1.028691
                        post |   .0003034    .003268     0.09   0.926    -.0061018    .0067087
                     treatMA |   .0085974   .0029101     2.95   0.003     .0028936    .0143011
           qavg_pct_lf_unemp |   .0004347   .0010269     0.42   0.672     -.001578    .0024474
                     pct_lhs |  -.0002593   .0006053    -0.43   0.668    -.0014457     .000927
                      pct_hs |  -.0012406   .0004624    -2.68   0.007    -.0021468   -.0003343
                  perc_black |   .0000265   .0002878     0.09   0.927    -.0005375    .0005905
               perc_nonwhite |   .0002253   .0001355     1.66   0.096    -.0000403    .0004909
                     pctmale |   .3199083   .3935682     0.81   0.416    -.4514712    1.091288
                   pctover65 |   .3493729   .1103393     3.17   0.002     .1331117     .565634
        state_share_rur~2010 |  -.0093318   .0125789    -0.74   0.458     -.033986    .0153224
                   md_100000 |  -.0001036   .0000304    -3.41   0.001    -.0001632    -.000044
                   pa_100000 |   .0000628   .0001115     0.56   0.573    -.0001557    .0002813
                   rn_100000 |  -.0000109   9.82e-06    -1.11   0.269    -.0000301    8.38e-06
                         qtr |   .0000396   .0006767     0.06   0.953    -.0012866    .0013659
                       qtrsq |  -.0000214   .0000237    -0.90   0.368    -.0000679    .0000251
      ----------------------------------------------------------------------------------------
      
      
      Indirect effects
      ----------------------------------------------------------------------------------------
                             |                 OIM
                             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -----------------------+----------------------------------------------------------------
      Structural             |
        poly_all2 <-         |
                        post |          0  (no path)
                     treatMA |          0  (no path)
           qavg_pct_lf_unemp |          0  (no path)
                     pct_lhs |          0  (no path)
                      pct_hs |          0  (no path)
                  perc_black |          0  (no path)
               perc_nonwhite |          0  (no path)
                     pctmale |          0  (no path)
                   pctover65 |          0  (no path)
        state_share_rur~2010 |          0  (no path)
                   md_100000 |          0  (no path)
                   pa_100000 |          0  (no path)
                   rn_100000 |          0  (no path)
                         qtr |          0  (no path)
                       qtrsq |          0  (no path)
        ---------------------+----------------------------------------------------------------
        narc_nocod2 <-       |
                   poly_all2 |          0  (no path)
                        post |  -.0724211   .0414466    -1.75   0.081    -.1536549    .0088127
                     treatMA |   .1190033   .0367877     3.23   0.001     .0469006    .1911059
           qavg_pct_lf_unemp |     .01235   .0130361     0.95   0.343    -.0132003    .0379003
                     pct_lhs |   .0075834   .0076834     0.99   0.324    -.0074758    .0226426
                      pct_hs |   .0034622    .005871     0.59   0.555    -.0080447    .0149692
                  perc_black |  -.0221236   .0035949    -6.15   0.000    -.0291695   -.0150778
               perc_nonwhite |   .0007398    .001721     0.43   0.667    -.0026332    .0041128
                     pctmale |  -24.13607   4.946485    -4.88   0.000      -33.831   -14.44113
                   pctover65 |  -1.986148   1.400007    -1.42   0.156    -4.730111    .7578153
        state_share_rur~2010 |   .9548331   .1572109     6.07   0.000     .6467054    1.262961
                   md_100000 |  -.0008706   .0003852    -2.26   0.024    -.0016255   -.0001157
                   pa_100000 |   .0058736   .0014048     4.18   0.000     .0031203     .008627
                   rn_100000 |  -.0006739   .0001231    -5.47   0.000    -.0009152   -.0004326
                         qtr |  -.0115969   .0085863    -1.35   0.177    -.0284257    .0052318
                       qtrsq |   .0003877   .0003011     1.29   0.198    -.0002024    .0009778
      ----------------------------------------------------------------------------------------
      
      
      Total effects
      ----------------------------------------------------------------------------------------
                             |                 OIM
                             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -----------------------+----------------------------------------------------------------
      Structural             |
        poly_all2 <-         |
                        post |  -.0707247   .0404754    -1.75   0.081    -.1500551    .0086056
                     treatMA |   .1162158    .035925     3.23   0.001     .0458041    .1866275
           qavg_pct_lf_unemp |   .0120607   .0127307     0.95   0.343     -.012891    .0370125
                     pct_lhs |   .0074058   .0075034     0.99   0.324    -.0073006    .0221122
                      pct_hs |   .0033811   .0057335     0.59   0.555    -.0078563    .0146185
                  perc_black |  -.0216054   .0035103    -6.15   0.000    -.0284855   -.0147253
               perc_nonwhite |   .0007225   .0016806     0.43   0.667    -.0025715    .0040165
                     pctmale |  -23.57071   4.830302    -4.88   0.000    -33.03792   -14.10349
                   pctover65 |  -1.939624   1.367206    -1.42   0.156    -4.619298    .7400495
        state_share_rur~2010 |   .9324672   .1535129     6.07   0.000     .6315875    1.233347
                   md_100000 |  -.0008502   .0003761    -2.26   0.024    -.0015874    -.000113
                   pa_100000 |   .0057361   .0013718     4.18   0.000     .0030473    .0084248
                   rn_100000 |  -.0006581   .0001202    -5.47   0.000    -.0008938   -.0004225
                         qtr |  -.0113253   .0083851    -1.35   0.177    -.0277598    .0051092
                       qtrsq |   .0003786    .000294     1.29   0.198    -.0001976    .0009549
        ---------------------+----------------------------------------------------------------
        narc_nocod2 <-       |
                   poly_all2 |   1.023986   .0024008   426.52   0.000      1.01928    1.028691
                        post |  -.0721177   .0415745    -1.73   0.083    -.1536023    .0093669
                     treatMA |   .1276007   .0369006     3.46   0.001     .0552769    .1999244
           qavg_pct_lf_unemp |   .0127847   .0130764     0.98   0.328    -.0128446     .038414
                     pct_lhs |   .0073241   .0077072     0.95   0.342    -.0077817    .0224298
                      pct_hs |   .0022217   .0058892     0.38   0.706    -.0093209    .0137642
                  perc_black |  -.0220971   .0036056    -6.13   0.000     -.029164   -.0150302
               perc_nonwhite |   .0009651   .0017263     0.56   0.576    -.0024183    .0043486
                     pctmale |  -23.81616   4.961472    -4.80   0.000    -33.54046   -14.09185
                   pctover65 |  -1.636775   1.404333    -1.17   0.244    -4.389217    1.115667
        state_share_rur~2010 |   .9455013   .1576816     6.00   0.000     .6364511    1.254552
                   md_100000 |  -.0009742   .0003864    -2.52   0.012    -.0017315    -.000217
                   pa_100000 |   .0059364   .0014091     4.21   0.000     .0031747    .0086982
                   rn_100000 |  -.0006848   .0001235    -5.55   0.000    -.0009268   -.0004427
                         qtr |  -.0115573   .0086128    -1.34   0.180    -.0284381    .0053235
                       qtrsq |   .0003664    .000302     1.21   0.225    -.0002256    .0009583
      ----------------------------------------------------------------------------------------
      So it seems that the effect of the treatment is almost entirely mediated through the poly_all2? Is there a way to cluster at statelevel in sem? I am going through the help file but cannot seem to find it.

      Sincerely,
      Sumedha.

      Comment


      • #4
        Are you sure this is the model you want? You are setting up a model in which all of your predictors' effects might be mediated by poly_all2. I thought you were just interested in in the intervention effect being so moderated. Otherwise put, I think that your first equation in the -sem- should just be -(poly_all2 <- post)-.

        When you refer to clustering on stateFIPS, if you mean that you want cluster robust standard errors, yes, you can just specify the -vce(cluster stateFIPS)- option, as you would with most other estimation commands. If you mean can you get something equivalent to a fixed effects model form -sem- the answer is no, at least not directly. You can, however add the -group(stateFIPS) ginvariant(scoef serrvar)- options to the command. This will be fairly similar to a fixed-effects regression.

        Comment

        Working...
        X