Announcement

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

  • " Error estimating treatment effect for unit "trunit" " using synth_runner package

    Hi,
    I am having issues with the synth_runner code. I really need you help urgently.

    I am doing the synthetic control methodology with the synth_runner command because I have multiple treatments.

    My dataset looks something like the following:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year byte qtr str5 id_mun str2 cve_ent float(salary_mean edad_mean rangosm_mean) double(asegurados_sum ta_sal_sum) str41 nom_mun int(cod_mun Dummy)
    2010 2 "01011" "01" 252.64156 2.1247087   3.61655   858   858 "San Francisco de los Romo"      1011 0
    2005 2 "04004" "04" 161.39404 2.0064795  2.987041   926   926 "Champotón"                     4004 0
    2010 2 "07062" "07"  463.0519 2.1322315  6.561984   123   123 "Ostuacán"                      7062 0
    2005 3 "08013" "08"  141.0505 1.9166666 2.3666666    60    60 "Casas Grandes"                  8013 0
    2000 1 "11022" "11" 116.37976  2.595238  2.642857    42    42 "Ocampo"                        11022 0
    2011 3 "12039" "12"  195.0068  2.698113  2.509434    53    53 "Juan R. Escudero"              12039 0
    2010 3 "13029" "13"   217.788 1.9580153  3.080153   262   262 "Huichapan"                     13029 0
    2015 3 "13077" "13" 243.96738 2.3341095  2.845169  1718  1718 "Tulancingo de Bravo"           13077 0
    2003 3 "15107" "15"  99.11429 2.4285715         2     7     7 "Tonatico"                      15107 0
    2014 1 "15113" "15" 222.44333 2.1132076  2.874214   159   159 "Villa Guerrero"                15113 0
    2006 1 "17020" "17" 115.55677 2.1259842 1.8740157   127   127 "Tepoztlán"                    17020 0
    2013 1 "19029" "19" 138.49792 2.3962264 1.5377358   106   106 "Hualahuises"                   19029 0
    2005 1 "19039" "19" 211.83983 2.0348904  3.630663 43995 43995 "Monterrey"                     19039 0
    2008 1 "20350" "20" 192.87474 2.0384614  3.346154    78    78 "San Sebastián Tutla"          20350 0
    2009 3 "21115" "21" 170.56396  2.086207  2.224138    58    58 "Quecholac"                     21115 0
    2015 2 "27016" "27" 199.61304 1.6248757 2.3024876  1005  1005 "Teapa"                         27016 0
    2005 1 "28004" "28" 67.862045  2.636364 1.2727273    44    44 "Antiguo Morelos"               28004 0
    2007 3 "29021" "29"  97.51054  2.637681 1.0869565   207   207 "Nanacamilpa de Mariano Arista" 29021 0
    2014 1 "30143" "30" 161.21014 2.1369863 1.9726027    73    73 "Santiago Tuxtla"               30143 0
    2015 2 "30201" "30" 224.22197 1.5168067   2.60084   238   238 "Zongolica"                     30201 0
    end
    I create the Dummy for multiple treatments in the following way:
    Code:
    recode cod_mun (14039    14070    14097    14098    14101    14120    19006    19019    19021    19026    ///
    19039    19046    19048    26004    26016    26017    26018    26025    26026    26029    ///
    26030    26033    26036    26042    26047    26058    26071    28002    28003    28004    ///
    28009    28011    28012    28021            28029    28038    28043    30040    30131    ///
    30189 = 1)(else = 0) if (date>210), gen(Dummy) // dummy de los tratamientos
    replace Dummy=0 if Dummy==.

    I get the following error:
    Code:
    . synth_runner salary_mean edad_mean rangosm_mean ta_sal_prop, d(Dummy)
    Estimating the treatment effects
    Error estimating treatment effect for unit 140039
    invalid syntax
    I continued as a suggestion to eliminate the treatments that do not run, but every time I elect, I am asked to continue eliminating and I can not continue to delete because otherwise I would only use one treatment, I need to use all my treatments.

    Like mentioning that I have my database strictly balanced and I do not have any missing in the covariates, as in the controls and treatments.

    Please suggest!
    Alexis Rodas




  • #2
    Hi,

    Have you been able to resolve this issue? I have been having the same problem, more specifically: my synth_runner will run if it's the first time with the code, but will not run a second time. I've tried clearing temp files and tried it writing the code to different do files in different computers, the issue is the same. It makes me think that there is something stuck in Stata's memory somewhere but I am not very familiar with these things.

    My panel is strongly balanced with no missing values.

    The error message is: Error estimating treatment effect for unit 240
    Re-running last -synth- command with output/errors un-captured


    Code:
    * declare panel
    tsset unit_no2 year 
    
    * generate treatment dummy
    
    #delimit ;
    
    gen byte D =(unit_no2==240 & year>=2011) | (unit_no2==251 & year>=2011) | (unit_no2==261 & year>=2011) | (unit_no2=    =271 & year>=2011) |  
                (unit_no2==241 & year>=2011) | (unit_no2==252 & year>=2011) | (unit_no2==262 & year>=2011) | (unit_no2==272 & year>=2011) | 
                (unit_no2==242 & year>=2011) | (unit_no2==253 & year>=2011) | (unit_no2==263 & year>=2011) | (unit_no2==273 & year>=2011) | 
                (unit_no2==243 & year>=2011) | (unit_no2==254 & year>=2011) | (unit_no2==264 & year>=2011) | (unit_no2==274 & year>=2011) | 
                (unit_no2==244 & year>=2011) | (unit_no2==255 & year>=2011) | (unit_no2==265 & year>=2011) | (unit_no2==275 & year>=2011) | 
                (unit_no2==245 & year>=2011) | (unit_no2==256 & year>=2011) | (unit_no2==266 & year>=2011) | (unit_no2==276 & year>=2011) | 
                (unit_no2==246 & year>=2011) | (unit_no2==257 & year>=2011) | (unit_no2==267 & year>=2011) | (unit_no2==277 & year>=2011) | 
                (unit_no2==247 & year>=2011) | (unit_no2==258 & year>=2011) | (unit_no2==268 & year>=2011) | (unit_no2==286 & year>=2011) | 
                (unit_no2==248 & year>=2011) | (unit_no2==259 & year>=2011) | (unit_no2==269 & year>=2011) | (unit_no2==287 & year>=2011) | 
                (unit_no2==249 & year>=2011) | (unit_no2==260 & year>=2011) | (unit_no2==270 & year>=2011) | (unit_no2==288 & year>=2011) | 
                (unit_no2==250 & year>=2011);
                
    #delimit cr 
        
    * synth_runner
    synth_runner rate_total edu_total, d(D) trends
    Any help appreciated! Thank you.

    Comment

    Working...
    X