Announcement

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

  • Tuples command

    Dear Statalisters,

    I am using the tuples command to generate groups of four and only four independent variables. Then I am using the synth command to generate all the synthetic controls possible, so I can choose the best one based on the RMSPE of each of them. That is why I'm exporting the RMSPE and V_matrix results to Excel.

    Here is my code

    Code:
    tuples  Longituddelineas Numerodeestaciones Pasosanivelcantidad Pasosvehiculares Sealamientoenkmdelinea Electrico calidad_deficitaria calidad_deficitaria_v2 conexiones_deficitarias conexiones_insuf hacinamiento tenencia_informal educ_j_superior, varlist min(4) max(4)
      
    forvalues i=1/715 {
                    synth Y1 Y1(75(1)87) Y1(37(1)48) `tuple`i'', trunit(7) xperiod(81(1)87) nested trperiod(88) keep(synth_Y1`tuple`i'') replace 
                    putexcel A1=matrix(e(RMSPE)) using RMSPE_VmatrixY1`tuple`i'', modify
                    putexcel B1=matrix(e(V_matrix)) using RMSPE_VmatrixY1`tuple`i'', modify
        }
    }
    The problem is that I get error 198 (invalid syntax), which says that one of the variables in the first tuple is invalid. Does anyone know how to solve this?

    Here is my log file, just in case
    Synthetic Control Method for Comparative Case Studies
    Code:
    ----------------------------------------------------------------------------------------------
    
    First Step: Data Setup
    ----------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------------------------
    Data Setup successful
    ----------------------------------------------------------------------------------------------
                    Treated Unit: CONLP
                   Control Units: BAGC, BAMCGB, CONEZ, CONGL, EZCAN, MERLOB, MORMERCE, PALAB,
                                  RETJLS, RETTIG, RetMIT, TEMHAE, URQ, VBALLZAR, VICCDS
    ----------------------------------------------------------------------------------------------
              Dependent Variable: Cumplimiento1
      MSPE minimized for periods: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
                                  25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
                                  46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
                                  67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
    Results obtained for periods: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
                                  25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
                                  46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
                                  67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
                                  88 99 100 101 102
    ----------------------------------------------------------------------------------------------
                      Predictors: Cumplimiento1(75(1)87) Cumplimiento1(37(1)48) conexiones_insuf
                                  hacinamiento tenencia_informal educ_j_superior
    ----------------------------------------------------------------------------------------------
    Unless period is specified
    predictors are averaged over: 81 82 83 84 85 86 87
    ----------------------------------------------------------------------------------------------
    
    Second Step: Run Optimization
    ----------------------------------------------------------------------------------------------
    Nested optimization requested
    Starting nested optimization module
    Optimization done
    ----------------------------------------------------------------------------------------------
    Optimization done
    ----------------------------------------------------------------------------------------------
    
    Third Step: Obtain Results
    ----------------------------------------------------------------------------------------------
    Loss: Root Mean Squared Prediction Error
    
    ---------------------
       RMSPE |  .0262334 
    ---------------------
    ----------------------------------------------------------------------------------------------
    Unit Weights:
    
    -----------------------
        Co_No | Unit_Weight
    ----------+------------
         BAGC |        .302
       BAMCGB |           0
        CONEZ |           0
        CONGL |         .43
        EZCAN |           0
       MERLOB |           0
     MORMERCE |           0
        PALAB |           0
       RETJLS |           0
       RETTIG |           0
       RetMIT |         .14
       TEMHAE |           0
          URQ |        .128
     VBALLZAR |           0
       VICCDS |           0
    -----------------------
    ----------------------------------------------------------------------------------------------
    Predictor Balance:
    
    ------------------------------------------------------
                                   |   Treated  Synthetic 
    -------------------------------+----------------------
            Cumplimiento1(75(1)87) |  .9426685   .9407001 
            Cumplimiento1(37(1)48) |   .958632   .9525271 
                  conexiones_insuf |   .108022   .2052907 
                      hacinamiento |  .0226488   .0248216 
                 tenencia_informal |  .1002226   .1012253 
                   educ_j_superior |  .3077788   .3077275 
    ------------------------------------------------------
    ----------------------------------------------------------------------------------------------
    invalid 'hacinamiento' 
    r(198);
    
    end of do-file
    
    r(198);

  • #2
    Matrices is your real name? If so, commiserations on lots of poor statistical jokes, like this one.

    I think your problem is with synth, not tuples.

    You are asked to explain where user-written programs you refer to come from. synth I take to be by Joseph Hilbe, who is not a member of Statalist, although he posted from time to time some years ago. If no one else answers, I would address your problem to him.

    st0186 from http://www.stata-journal.com/software/sj10-1
    SJ10-1 st0186. Creating synthetic discrete-response... / Creating
    synthetic discrete-response regression models / by Joseph M. Hilbe,
    Arizona State University and / Jet Propulsion Laboratory, CalTech /
    Support: [email protected]

    Comment


    • #3
      Note that both, tuples and synth are user-written programs and you are asked to explain where they come from. From your output it seems that tuples is not the issue here as it does what it is supposed to do and hacinamento gets passed thru to synth correctly. I have never used the latter and so have no idea what is going on.

      Try the following.

      1. If still possible change the title to be more informative about the problem (which is not tuples) making sure you mention the synth command.

      2. If possible try with a smaller/simpler example to see whether that error still occurs.

      3. You can also set trace on to see where exactly things are going wrong.

      4. If nothing else come up, perhaps you will have to contact the authors of synth for help.

      Best
      Daniel

      Comment


      • #4
        Hello all,

        I'm sorry for not saying who were the authors of these two commands.

        The authors of synth are: Jens Hainmueller, Alberto Abadie and Alexis Diamond.
        Nicholas Cox is the author of tuples.

        Both of you were right, the problem was with the synth command. I was saving the results under the name of a macro. That was why the invalid syntax error popped up.

        Thanks for your help,

        Nicolas

        Comment


        • #5
          Good news, but Joseph N. Luchman is very much the leading author of tuples.

          If you have a help file that says otherwise, you should update from SSC.

          Comment


          • #6
            Just to clarify, the request to say where user-written additions come from has little to do with crediting the authors, but much more with the problem of different versions of the same programs. Thus, the preferred way is to state the location you have downloaded these command, the SSC, the Stata Journal (SJ) or somewhere else.

            Best
            Daniel

            Comment


            • #7
              Daniel is right, although crediting authors is also of merit here.

              The reasons in order of importance are

              1. To let people who answer questions understand your problem as easily and fully as possible. Even very experienced users can't be familiar with more than a few user-written programs.

              2. To let others, including all lurkers, know about programs you found useful.

              3. To give credit to the authors.

              4. To make life easier for future historians.

              5. To provide any fun or interest that might otherwise ensue.

              Comment

              Working...
              X