Announcement

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

  • did_multiplegt_dyn error: didmgt_Var_all_XX not found

    Dear Statalist

    I am using did_multiplegt_dyn downloaded from the SSC (for estimating heterogeniety-robust DID; de Chaisemartin & D'Haultfoeuille, 2024, Difference-in-Differences Estimators of Intertemporal Treatment Effects) on Stata version 16.

    I am nominally working with a larger dataset (15 variables, 1.2*10^6 observations), but in practice I am using a smaller subsample for simplicity as I prepare my code. My data is longitudinal and unbalanced, for example:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(var_1 var_2 var_3 ID) long YEAR byte(treated_1 cluster)
    3850 285298.29921    202507 2370023009 2004 0 5
    4050 294390.08914    195963 2370023009 2005 0 5
    4000 505421.49687    404552 2370023009 2006 0 5
    3751 378618.47563    266869 2370023009 2007 0 5
    3645 425285.02748    289306 2370023009 2008 1 5
    3805 471000.74992    304888 2370023009 2009 1 5
    3283 570662.32445    405157 2370023009 2010 1 5
    4032 590190.63912    298629 2370023009 2011 1 5
    4314 724288.21162    408188 2370023009 2012 1 5
    4510 764617.21335    437068 2370023009 2013 1 5
    4510 839516.98757    475772 2370023009 2014 1 5
    4930 880242.63312 464767.08 2370023009 2015 1 5
    5442 719169.59029 406694.16 2370023009 2016 1 5
    6280 849119.11759 473080.37 2370023009 2017 1 5
    6567 111020.71734     27604 2370027009 2004 0 5
    6661 128064.03995     42766 2370027009 2005 0 5
    6754 140641.49231     66726 2370027009 2006 0 5
    5563  134937.5374     55661 2370027009 2007 0 5
    5814   133244.049     46556 2370027009 2008 0 5
    5581 120180.65224     48602 2370027009 2009 0 5
    5225 176240.74104     80450 2370027009 2010 0 5
    5129 160180.52531     51499 2370027009 2011 0 5
    5145  164450.5776     75849 2370027009 2012 0 5
    5174 180331.39929     61031 2370027009 2013 0 5
    5175  159211.5154     50907 2370027009 2014 0 5
    5135 158655.13822     63240 2370027009 2015 0 5
    5135 132289.24417  66011.71 2370027009 2016 0 5
    5135 153429.84534  39369.13 2370027009 2017 0 5
    5135 187312.69027  57855.03 2370027009 2018 0 5
    end
    I am running a loop with did_multiplegt_dyn as follows (note, I am also using event_plot from the SSC to graph the results):

    Code:
     local vars "var_1 var_2 var_3"
        forvalues k = 1(1)2 {
            foreach v of local vars {
                did_multiplegt_dyn `v' ID YEAR treated_`k', effects(12) placebo(12) cluster(cluster) only_never_switchers ci_level(99)
                event_plot e(estimates)#e(variances), default_look graph_opt(xtitle("Years relative to switch") ytitle("Average effect of switching") xlabel(-12(-1)12) title(`"dCDH `v' `k'"')) stub_lag(Effect_#) stub_lead(Placebo_#) together
                graph save, replace
                matrix dcdh_b_`v'_`k' = e(estimates)
                matrix dcdh_v_`v'_`k' = e(variances)
            }
        }
    As the loop runs the above did_multiplegt_dyn command I get the following output and corresponding error:

    Code:
    The number of placebos which can be estimated is at most 7.
    The command will therefore try to estimate 7 placebo(s).
    
    Effect_11 cannot be estimated.
    There is no switcher or no control
    for this effect.
    
    Effect_12 cannot be estimated.
    There is no switcher or no control
    for this effect.
    
    Placebo_7 cannot be estimated.
    There is no switcher or no control
    for this placebo.
    
    Some placebos/effects could not be estimated.
    Therefore, the command will not be compatible
    with the honestdid command.
    
    Some placebos could not be estimated.
    Therefore, the test of joint nullity of the placebos
    could not be computed.
    
    --------------------------------------------------------------------------------
                 Estimation of treatment effects: Event-study effects
    --------------------------------------------------------------------------------
    
                 |  Estimate         SE      LB CI      UB CI          N  Switchers
    -------------+------------------------------------------------------------------
        Effect_1 |  -55.4194   26.01407  -122.4272    11.5884       9478         16
        Effect_2 | -19.33951   63.40962  -182.6719   143.9928       8673         16
        Effect_3 |  313.8926   73.26235   125.1813   502.6039       6848         12
        Effect_4 |  418.1752   69.77149   238.4557   597.8946       5622         11
        Effect_5 |   328.411   30.65127   249.4586   407.3634       3844          5
        Effect_6 |  645.4331   37.15429     549.73   741.1362       2933          4
        Effect_7 |   1181.55   49.06057   1055.178   1307.922       2565          4
        Effect_8 |  926.4066   53.48948   788.6268   1064.186       1906          3
        Effect_9 |  1111.936   54.67205   971.1099   1252.762       1687          3
       Effect_10 |  2894.371   52.96381   2757.945   3030.797        551          1
       Effect_11 |         .          .          .          .          0          0
       Effect_12 |         .          .          .          .          0          0
    --------------------------------------------------------------------------------
    
    
    --------------------------------------------------------------------------------
                   Average cumulative (total) effect per treatment unit
    --------------------------------------------------------------------------------
    
                 |  Estimate         SE      LB CI      UB CI          N     Switch  x Periods
    -------------+-----------------------------------------------------------------------------
      Av_tot_eff |  353.9419   24.02224   292.0647   415.8191      11775         75            
    --------------------------------------------------------------------------------
    Average number of time periods over which a treatment's effect is accumulated = 4.6619718
    
    
    --------------------------------------------------------------------------------
              Testing the parallel trends and no anticipation assumptions
    --------------------------------------------------------------------------------
    
                 |  Estimate         SE      LB CI      UB CI          N  Switchers
    -------------+------------------------------------------------------------------
       Placebo_1 | -3.288138   42.84637  -113.6531   107.0768       8610         16
       Placebo_2 |  352.3659   165.6031  -74.19952   778.9313       7527         16
       Placebo_3 |  444.1805   215.8812  -111.8926   1000.254       4912         11
       Placebo_4 |  361.0978   394.4885  -655.0373   1377.233       2496          7
       Placebo_5 | -115.2562   40.31975   -219.113   -11.3994       1130          2
       Placebo_6 |  3679.696   42.39853   3570.484   3788.907        484          1
       Placebo_7 |         .          .          .          .          0          0
    --------------------------------------------------------------------------------
    didmgt_Var_all_XX not found
    r(111);
    I have not defined a variable called didmgt_Var_all_XX prior to running the loop - I suspect it is an output from did_multiplegt_dyn (though I cannot find it in the program's documentation). I have tried to find references to the specified error elsewhere but I cannot find any reference to this problem nor on how to solve it.

    I would greatly appreciate some help.

    Many thanks,

    Guy
    Last edited by Guy Low; 08 Jul 2024, 09:45.

  • #2
    Dear Statalist,

    I should have investigated further. I ran the same command but this time specifying the valid number of effects and placebos for my subsample: effects(10) placebo(6). The command ran successfully (in my larger dataset, I know that I have precisely 12 effects and 12 placebos, hence the original, erroneous mis-specification).

    However, I would still be curious to understand why the command did not work originally. Does it matter (it seems so) that the specified number of effects and placebos might be too many? Why does it lead to an error - why can't the program dismiss the fact that some of these cannot be estimated (in the case of the placebos, the console shows that the command attempts to estimate 7 placebos, overriding the 12 I had specified originally, and even then could not estimate Placebo_7)?

    Thanks again,

    Guy

    Comment

    Working...
    X