Announcement

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

  • single_treatment_graphs can't find variable

    I am working on using synth to run a synthetic control method analysis using state-year data. I am using various predictor variables to predict a synthetic state's unemployment rate after a treatment. When using synth on the original data, everything works great and outputs the results as expected. However, all of the weight is placed on South Carolina as the predictor state. Naturally, I removed South Carolina and ran the exact same synth, synth_runner, and single_treatment_graphs commands on a donor pool of 19 states. For some reason, although it works fine with 20 states, once I drop SC, single_treatment_graphs is unable to find the "unemp" variable that it is predicting. It says it is ambiguously abbreviated, but using "set varabbrev off" to avoid abbreviation confusion results in it saying "variable unemp not found" rather than ambiguous abbreviation. I also had it tabulate unemp the line before single_treatment_graphs (after synth and synth_runner) and it returns a list of all unemp values and then immediately says "variable unemp not found". Any advice or suggestions would be greatly appreciated as I am very confused.

    I will show the whole code below this, the first section works perfectly fine and produces the treatment graph. It is only in the second section, after preserving and dropping SC that the error occurs. It also completes both synth and synth_runner without issue, it is the single_treatment_graphs that causes the error of "variable unemp not found" when abbreviations are off, and "unemp ambiguous abbreviation" when abbreviations are turned on.
    Exact code:
    clear all
    cd "*********************"


    //////////////////////////////////////////////////////////////////////

    // Install synth
    ssc install synth


    //Import data
    use synth_ca.dta

    //Ensure data is a time series
    sort state year
    tsset state year



    //Run synth
    synth unemp unemp(2000(1)2013) LFP poverty inc(2008,2013) college(2006,2013) ///
    ,trunit(2) trperiod(2014) fig


    //Return important information about treated and synthetic variables
    ereturn list
    matlist e(Y_synthetic)
    matlist e(Y_treated) - e(Y_synthetic)

    // Locate synth_runner
    findit synth_runner
    // help synth_runner


    //Run synth_runner
    synth_runner unemp LFP poverty inc(2008,2013) college(2006,2013) unemp(2000(1)2013), trunit(2) trperiod(2014) gen_vars


    //Generate treatment graph
    single_treatment_graphs


    //////////////Remove South Carolina and redo the synth////////////////////////

    clear all
    use synth_ca.dta
    set varabbrev off
    rename observation_date obs

    preserve
    drop if state==16

    //Run synth again
    synth unemp unemp(2000(1)2013) LFP poverty inc(2008,2013) college(2006,2013) ///
    ,trunit(2) trperiod(2014) fig


    //Return important information about treated and synthetic variables
    ereturn list
    matlist e(Y_synthetic)
    matlist e(Y_treated) - e(Y_synthetic)

    // Locate synth_runner
    findit synth_runner
    // help synth_runner


    //Run synth_runner
    synth_runner unemp LFP poverty inc(2008,2013) college(2006,2013) unemp(2000(1)2013), trunit(2) trperiod(2014) gen_vars

    tabulate unemp

    //Generate treatment graph
    single_treatment_graphs

    restore
    Last edited by Thomas Jendrejack; 15 May 2026, 11:27.

  • #2
    Code:
    use synth_ca.dta
    This dataset—synth_ca—is local to your machine. Either provide it using dataex or use the smoking dataset that is included with the command to illustrate the problem. As it stands, your example is not reproducible.

    Comment

    Working...
    X