Announcement

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

  • Synthetic Controls - String Variables

    I am trying to run the npsynth command (Abadie, Diamond, Hainmueller, 2009) with a database of gravity data. Each observation is a trade flow from a pair of countries (pairs). The group of control variables is composed uniquely by dummy and nummeric variables. There is no string variable on the control group.

    When I try to execute the command npsynth the following message pops up:


    "factor-variable and time-series operators not allowed"

    Command:


    global controles "contig comlang_off comlang_ethno comcol col45 distw pop_o ///
    gdpcap_o gdpcap_d tdiff heg_d conflict indepdate heg_o colony curcol gatt_o ///
    gatt_d rta gsp gsp_rec"
    npsynth tradeflow $controles t_0(1996) bandw(0.4) panel_var(tradeflow) time_var(year) trunit(ARBO) kern(biweight)

    The syntax is taken from https://www.stata.com/meeting/uk17/s...17_Cerulli.pdf
    __________________________________________________ __________________________________________________ __________________________________________________ ___


    I have already tried to maintain only dummy variables (such as colony) or only nummeric continuous variables (such as gdpcap_o) but the same message keeps coming up.

    My data is organized such as follows:


    Click image for larger version

Name:	problema.PNG
Views:	1
Size:	35.2 KB
ID:	1497249


    At a first glance I had the impression the problem resides on the variable pairs, since it is composed by nonnummeric values. Changing it to numbers did not help.


    Does someone has any idea why this keep happening ?


    Thanks in advance!

  • #2
    You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. Being able to replicate your problem helps us help you.

    With user-written programs, the level of assistance on this list serve often depends on whether one of the active folks uses the procedure. One thing I'd do is run it with "set trace on" and see precisely how Stata is interpreting your macros and code. If the documentation includes an example with the data source, run that to make sure the program is running as intended.

    Otherwise, you can either try to diagnose the problem by looking at the ado file code, or contact the authors.

    Comment


    • #3
      I've never used -npsynth-, but I took a look at the syntax diagram, and I see that like other Stata commands, it expects a comma (",") after the variable list and before the options. Try putting a comma before t_0(1996).

      Comment


      • #4
        Originally posted by Mike Lacy View Post
        I've never used -npsynth-, but I took a look at the syntax diagram, and I see that like other Stata commands, it expects a comma (",") after the variable list and before the options. Try putting a comma before t_0(1996).
        I tried that without sucess. Now I have given up about using npsynth and started to work with just synth. It did not work as welll. Now the problem resides on a conformability error. I even tried to run it with just one regressor in stead of all that I wanted. I checked for missing units and everything else.




        I ran the following code:


        tsset codigopar year
        set matsize 800, perm
        synth tradeflow gdp_o, trunit(541) trperiod(1996) figure xperiod(1988(1)1995)


        There are just strongly balanced units and no missing observations either for the dependent variable or for the independent one. codigopar is a variable I created in order to give numbers for the units. Each unit got a correspondent number.


        Here you guys can find a sample of my database such that you can try to run the code on your own: https://1drv.ms/u/s!AoCLaXLm8KbpyjrNDM1PSqZfZRWN





        Attached Files

        Comment

        Working...
        X