Announcement

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

  • A gmm command that works in Stata 13 returns "could not evaluate equation 1" in Stata 14.1

    Dear all,
    I have just upgraded to Stata/SE 14.1. I work on the attached data file. The following gmm command which works in my colleague's Stata 13 version returns an error
    could not evaluate equation 1
    r(498);
    The command is:
    Code:
    #delimit;
    gmm (ln(marketshare)- {B0}-{xb: agri_activity extreme_activity kidsfac agri_sale food_sales guided_act seating
     access uppergalilee}+{alpha}*(ln(total_price)-{sigma}*(ln(region_ms)))),instruments(accommod extreme_activity
    agri_activity kidsfac established_attr food_sales agri_sale access guided_act atract_3region 
    activity_size  agri_work fam_work agri_fac uppergalilee)twostep winit(unadj,indep);
    Any ideas what is the problem?
    Best,
    Anat
    Attached Files

  • #2
    Are you sure this exact same code and data ran in Stata 13? I get the same error you got in Stata 13 and in Stata 14. That leads me to suspect something has been lost between your colleague's machine and your machine. Or that s/he is incorrect in saying s/he got it to run. Double check with your colleague, e.g. send your colleague your code and see if it runs.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Thank you, I will double check!

      Comment


      • #4
        Anat,

        The variable marketshare does not exist. It is ln_marketshare. This applies to the other logged variables. Unfortunately, gmm captures the error and issues its own vague message leaving you a bit clueless what the problem is. I also found that initial estimates are necessary.

        I used regress to get crude initial estimates.

        Code:
        . regress ln_marketshare agri_activity extreme_activity kidsfac ///
        >         agri_sale food_sales guided_act seating access uppergalilee ///
        >         ln_total_price ln_region_ms
        
              Source |       SS           df       MS      Number of obs   =        71
        -------------+----------------------------------   F(11, 59)       =     84.56
               Model |  232.638538        11   21.148958   Prob > F        =    0.0000
            Residual |  14.7565583        59  .250111158   R-squared       =    0.9404
        -------------+----------------------------------   Adj R-squared   =    0.9292
               Total |  247.395096        70  3.53421566   Root MSE        =    .50011
        
        ------------------------------------------------------------------------------
        ln_markets~e |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
        agri_activ~y |  -.4145576   .1466714    -2.83   0.006    -.7080464   -.1210689
        extreme_ac~y |   .2966711   .2841567     1.04   0.301    -.2719252    .8652674
             kidsfac |   .0578384   .1386673     0.42   0.678    -.2196342     .335311
           agri_sale |   .4625761   .1769551     2.61   0.011     .1084898    .8166625
          food_sales |   .2258728   .1515022     1.49   0.141    -.0772825     .529028
          guided_act |  -.1803722   .1562924    -1.15   0.253    -.4931125    .1323681
             seating |   .0015671   .0007517     2.08   0.041      .000063    .0030711
              access |   .1355426   .1178812     1.15   0.255    -.1003372    .3714224
        uppergalilee |   1.389592   .1669886     8.32   0.000     1.055448    1.723735
        ln_total_p~e |    .096056   .1117153     0.86   0.393    -.1274858    .3195978
        ln_region_ms |   .8064377   .0503264    16.02   0.000     .7057348    .9071407
               _cons |  -7.010594   .7674078    -9.14   0.000    -8.546173   -5.475014
        ------------------------------------------------------------------------------
        
        .
        . mat b = e(b)
        
        . mat li b
        
        b[1,12]
            agri_activ~y  extreme_ac~y       kidsfac     agri_sale    food_sales
        y1    -.41455764      .2966711     .05783837     .46257611     .22587279
        
              guided_act       seating        access  uppergalilee  ln_total_p~e
        y1    -.18037218     .00156709     .13554258     1.3895916     .09605602
        
            ln_region_ms         _cons
        y1     .80643774    -7.0105935
        
        . local k = colsof(b)
        
        . mat b0 = b[1,`k']
        
        . mat b1 = b[1,`--k']
        
        . mat b2 = -b[1,`--k']
        
        . mat b= b[1,1..`--k']
        
        . local stripe : colnames b
        
        . mat coleq b = xb
        
        . mat colnames b0 = B0:_cons
        
        . mat colnames b1 = alpha:_cons
        
        . mat colnames b2 = sigma:_cons
        
        . mat b = (b0,b,b2,b1)
        
        . mat li b
        
        b[1,12]
                      B0:           xb:           xb:           xb:           xb:
                   _cons  agri_activ~y  extreme_ac~y       kidsfac     agri_sale
        r1    -7.0105935    -.41455764      .2966711     .05783837     .46257611
        
                      xb:           xb:           xb:           xb:           xb:
              food_sales    guided_act       seating        access  uppergalilee
        r1     .22587279    -.18037218     .00156709     .13554258     1.3895916
        
                   sigma:        alpha:
                   _cons         _cons
        r1    -.09605602     .80643774
        
        .
        .
        . gmm (ln_marketshare - {B0}-{xb: agri_activity extreme_activity kidsfac ///
        >         agri_sale food_sales guided_act seating access uppergalilee} + ///
        >         {alpha}*(ln_total_price-{sigma}*(ln_region_ms))),            ///
        >         instruments(accommod extreme_activity agri_activity kidsfac    ///
        >         established_attr food_sales agri_sale access guided_act        ///
        >         atract_3region activity_size  agri_work fam_work agri_fac      ///
        >         uppergalilee) twostep winit(unadj,indep) quickderivatives from(b)
        (71 real changes made)
        
        Step 1
        Iteration 0:   GMM criterion Q(b) =   18.27112  
        Iteration 1:   GMM criterion Q(b) =  .18611487  
        Iteration 2:   GMM criterion Q(b) =  .18611415  
        Iteration 3:   GMM criterion Q(b) =  .18474342  
        Iteration 4:   GMM criterion Q(b) =  .18231836  
        Iteration 5:   GMM criterion Q(b) =  .17909891  
        Iteration 6:   GMM criterion Q(b) =  .17529522  
        Iteration 7:   GMM criterion Q(b) =  .17452223  
        Iteration 8:   GMM criterion Q(b) =  .17014215  
        Iteration 9:   GMM criterion Q(b) =  .16354259  
        Iteration 10:  GMM criterion Q(b) =   .1612697  
        Iteration 11:  GMM criterion Q(b) =  .14942856  
        Iteration 12:  GMM criterion Q(b) =  .13906626  
        Iteration 13:  GMM criterion Q(b) =  .11323153  
        Iteration 14:  GMM criterion Q(b) =  .04754047  
        Iteration 15:  GMM criterion Q(b) =  .04705605  
        Iteration 16:  GMM criterion Q(b) =  .04694532  
        Iteration 17:  GMM criterion Q(b) =  .04694532  
        
        Step 2
        Iteration 0:   GMM criterion Q(b) =  .09280402  
        Iteration 1:   GMM criterion Q(b) =  .07194506  
        Iteration 2:   GMM criterion Q(b) =   .0717963  
        Iteration 3:   GMM criterion Q(b) =   .0717963  
        
        GMM estimation
        
        Number of parameters =  12
        Number of moments    =  16
        Initial weight matrix: Unadjusted                 Number of obs   =         71
        GMM weight matrix:     Robust
        
        ------------------------------------------------------------------------------
                     |               Robust
                     |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
        B0           |
               _cons |   -15.2408   3.267991    -4.66   0.000    -21.64595   -8.835657
        -------------+----------------------------------------------------------------
        xb           |
        agri_activ~y |  -.0440558   .3300331    -0.13   0.894    -.6909088    .6027972
        extreme_ac~y |   .0947773   1.733157     0.05   0.956    -3.302148    3.491703
             kidsfac |   .2349969   .4291657     0.55   0.584    -.6061524    1.076146
           agri_sale |    .406263   .5941873     0.68   0.494    -.7583227    1.570849
          food_sales |   .2133124   .7378262     0.29   0.772      -1.2328    1.659425
          guided_act |  -.1470461   .3913638    -0.38   0.707    -.9141051     .620013
             seating |   .0063738   .0040694     1.57   0.117     -.001602    .0143496
              access |    .579207   .3273026     1.77   0.077    -.0622943    1.220708
        uppergalilee |   .5264446   .3828372     1.38   0.169    -.2239026    1.276792
        -------------+----------------------------------------------------------------
              /alpha |    -1.0601   1.089973    -0.97   0.331    -3.196407    1.076208
              /sigma |  -.2599064   .2663586    -0.98   0.329    -.7819596    .2621469
        ------------------------------------------------------------------------------
        Instruments for equation 1: accommod extreme_activity agri_activity kidsfac
            established_attr food_sales agri_sale access guided_act atract_3region
            activity_size agri_work fam_work agri_fac uppergalilee _cons
        I hope this helps.

        Rich

        Comment


        • #5
          Richard, thank you so much!!! it helped! I'm so happy!

          Comment


          • #6
            Great catch by Richard G. I would still check with the original source of the code and data, because if it was running before then something must have gotten zapped along the way.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

            EMAIL: [email protected]
            WWW: https://www3.nd.edu/~rwilliam

            Comment

            Working...
            X