Announcement

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

  • Error with marginal effects after oprobit

    Dear users,

    I'm estimating an ordered probit model. My dependent variable has four categories, ranging from 0 to 3.
    I want to test if one of my independent variables (continuous) has an inverted u-shaped effect over the highest level of my dependent variable (3).
    To do so, I want to compute and plot marginal effects. But I get an error.

    Here's the oprobit regression:

    Code:
    oprobit Variety_1_Output2 ///
    c.EI_7categs##c.EI_7categs ///
    c.tertius_avg_c ///
    $controls, robust cluster(tipo_org_2)
    Then, I want to run the marginal effects for the full range of my variable:

    Code:
    qui sum c.EI_7categs, d
    margins, at(c.EI_7categs =(`r(min)'(0.1)`r(max)')) predict(outcome(3))
    But I get the following error:

    0 invalid name
    (error in option xb())


    I've been testing different alternatives but I haven't been able to figure out where's the problem.

    Many thanks in advance.


  • #2
    I just semi-cloned your example without problems. Can you post an extract of your data using dataex that reproduces the problem?
    -------------------------------------------
    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
      Yes, here it is:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(Variety_1_Output2 EI_7categs tertius_avg_c)
      1        0   .0984943
      0        .  -.7348387
      3 .7142857  1.9318278
      0        1   .5984943
      1      -.6  1.2651613
      1        1  .26516128
      0        1   .7651613
      1        0   .9318278
      0       -1  -.5681722
      1 .6666667 -1.0681722
      end
      I don't show all the control variables that I employ in the regression. But when I drop controls from the oprobit, I still get the same problem.

      I use Stata 14.0

      Comment


      • #4
        This works for me. What version of Stata do you have? Is it up to date?

        Code:
         * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(Variety_1_Output2 EI_7categs tertius_avg_c)
        1        0   .0984943
        0        .  -.7348387
        3 .7142857  1.9318278
        0        1   .5984943
        1      -.6  1.2651613
        1        1  .26516128
        0        1   .7651613
        1        0   .9318278
        0       -1  -.5681722
        1 .6666667 -1.0681722
        end
        oprobit Variety_1_Output2 ///
        c.EI_7categs##c.EI_7categs ///
        c.tertius_avg_c ///
        , robust 
        qui sum c.EI_7categs, d
        margins, at(c.EI_7categs =(`r(min)'(0.1)`r(max)')) predict(outcome(3))
        Code:
        . margins, at(c.EI_7categs =(`r(min)'(0.1)`r(max)')) predict(outcome(3))
        
        Predictive margins                              Number of obs     =          9
        Model VCE    : Robust
        
        Expression   : Pr(Variety_1_Output2==3), predict(outcome(3))
        
        1._at        : EI_7categs      =          -1
        
        2._at        : EI_7categs      =         -.9
        
        3._at        : EI_7categs      =         -.8
        
        4._at        : EI_7categs      =         -.7
        
        5._at        : EI_7categs      =         -.6
        
        6._at        : EI_7categs      =         -.5
        
        7._at        : EI_7categs      =         -.4
        
        8._at        : EI_7categs      =         -.3
        
        9._at        : EI_7categs      =         -.2
        
        10._at       : EI_7categs      =         -.1
        
        11._at       : EI_7categs      =           0
        
        12._at       : EI_7categs      =          .1
        
        13._at       : EI_7categs      =          .2
        
        14._at       : EI_7categs      =          .3
        
        15._at       : EI_7categs      =          .4
        
        16._at       : EI_7categs      =          .5
        
        17._at       : EI_7categs      =          .6
        
        18._at       : EI_7categs      =          .7
        
        19._at       : EI_7categs      =          .8
        
        20._at       : EI_7categs      =          .9
        
        21._at       : EI_7categs      =           1
        
        ------------------------------------------------------------------------------
                     |            Delta-method
                     |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 _at |
                  1  |   3.88e-15   2.14e-13     0.02   0.986    -4.16e-13    4.24e-13
                  2  |   7.25e-11   2.64e-09     0.03   0.978    -5.11e-09    5.25e-09
                  3  |   1.04e-07   2.36e-06     0.04   0.965    -4.52e-06    4.73e-06
                  4  |   .0000185   .0002469     0.08   0.940    -.0004655    .0005025
                  5  |   .0006546   .0047667     0.14   0.891     -.008688    .0099972
                  6  |   .0069615   .0263364     0.26   0.792    -.0446568    .0585799
                  7  |   .0322502   .0643065     0.50   0.616    -.0937883    .1582887
                  8  |     .08702     .10055     0.87   0.387    -.1100544    .2840944
                  9  |   .1658776   .1295816     1.28   0.201    -.0880978    .4198529
                 10  |   .2506954   .1591342     1.58   0.115    -.0612019    .5625927
                 11  |    .322385   .1896684     1.70   0.089    -.0493582    .6941283
                 12  |   .3688054   .2131961     1.73   0.084    -.0490513    .7866621
                 13  |   .3848245   .2249847     1.71   0.087    -.0561375    .8257865
                 14  |   .3692251   .2236826     1.65   0.099    -.0691847    .8076348
                 15  |   .3231888   .2083838     1.55   0.121     -.085236    .7316136
                 16  |   .2517749    .180001     1.40   0.162    -.1010206    .6045704
                 17  |    .167017   .1436743     1.16   0.245    -.1145794    .4486135
                 18  |   .0879448   .1039123     0.85   0.397    -.1157195    .2916092
                 19  |   .0327792   .0615373     0.53   0.594    -.0878317    .1533901
                 20  |   .0071391   .0240336     0.30   0.766    -.0399659    .0542441
                 21  |   .0006804   .0043282     0.16   0.875    -.0078027    .0091634
        ------------------------------------------------------------------------------
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

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

        Comment


        • #5
          I dug out Stata 11 and it runs fine there too.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

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

          Comment


          • #6
            Dear Richard,

            I just found out that the problem occurs when I specify the option "robust cluster(tipo_org_2)" in the oprobit regression.
            When I only use "robust" in the regression, it works perfectly. But if I cluster errors, it doesn't work.
            In fact, you have run the model without the option "cluster(tipo_org_2)".

            Could you check if it works for you when you cluster errors?

            Code:
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input float(Variety_1_Output2 EI_7categs tertius_avg_c) double tipo_org_2
            1         0   .0984943 3
            0         .  -.7348387 1
            3  .7142857  1.9318278 3
            0         1   .5984943 3
            1       -.6  1.2651613 3
            1         1  .26516128 3
            0         1   .7651613 3
            1         0   .9318278 1
            0        -1  -.5681722 1
            1  .6666667 -1.0681722 1
            1        .4   .4318278 1
            0        -1          . 1
            3 .14285715  .26516128 1
            0         0 -1.0681722 1
            0         1   .7651613 1
            end
            label values tipo_org_2 tipo_org_2
            label def tipo_org_2 1 "university", modify
            label def tipo_org_2 3 "public research org", modify
            Many thanks.



            Comment


            • #7
              I didn't use the cluster option because it wasn't in the earlier file. But with it, it still works fine for me, assuming I have exactly reproduced what you ran. If I haven't, show the exact command you ran with the controls dropped. Also indicate your version of Stata. I am using 15.

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input float(Variety_1_Output2 EI_7categs tertius_avg_c) double tipo_org_2
              1         0   .0984943 3
              0         .  -.7348387 1
              3  .7142857  1.9318278 3
              0         1   .5984943 3
              1       -.6  1.2651613 3
              1         1  .26516128 3
              0         1   .7651613 3
              1         0   .9318278 1
              0        -1  -.5681722 1
              1  .6666667 -1.0681722 1
              1        .4   .4318278 1
              0        -1          . 1
              3 .14285715  .26516128 1
              0         0 -1.0681722 1
              0         1   .7651613 1
              end
              label values tipo_org_2 tipo_org_2
              label def tipo_org_2 1 "university", modify
              label def tipo_org_2 3 "public research org", modify
              
              oprobit Variety_1_Output2 ///
                 c.EI_7categs##c.EI_7categs ///
                 c.tertius_avg_c ///
                 , robust cluster(tipo_org_2)
              qui sum c.EI_7categs, d
              margins, at(c.EI_7categs =(`r(min)'(0.1)`r(max)')) predict(outcome(3))
              Code:
              . margins, at(c.EI_7categs =(`r(min)'(0.1)`r(max)')) predict(outcome(3))
              
              Predictive margins                              Number of obs     =         13
              Model VCE    : Robust
              
              Expression   : Pr(Variety_1_Output2==3), predict(outcome(3))
              
              1._at        : EI_7categs      =          -1
              
              2._at        : EI_7categs      =         -.9
              
              3._at        : EI_7categs      =         -.8
              
              4._at        : EI_7categs      =         -.7
              
              5._at        : EI_7categs      =         -.6
              
              6._at        : EI_7categs      =         -.5
              
              7._at        : EI_7categs      =         -.4
              
              8._at        : EI_7categs      =         -.3
              
              9._at        : EI_7categs      =         -.2
              
              10._at       : EI_7categs      =         -.1
              
              11._at       : EI_7categs      =           0
              
              12._at       : EI_7categs      =          .1
              
              13._at       : EI_7categs      =          .2
              
              14._at       : EI_7categs      =          .3
              
              15._at       : EI_7categs      =          .4
              
              16._at       : EI_7categs      =          .5
              
              17._at       : EI_7categs      =          .6
              
              18._at       : EI_7categs      =          .7
              
              19._at       : EI_7categs      =          .8
              
              20._at       : EI_7categs      =          .9
              
              21._at       : EI_7categs      =           1
              
              ------------------------------------------------------------------------------
                           |            Delta-method
                           |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       _at |
                        1  |   9.47e-07   2.17e-06     0.44   0.662    -3.30e-06    5.20e-06
                        2  |   .0000333   .0000627     0.53   0.596    -.0000895     .000156
                        3  |   .0004755   .0007309     0.65   0.515     -.000957     .001908
                        4  |   .0033791    .004235     0.80   0.425    -.0049214    .0116796
                        5  |   .0141956   .0146377     0.97   0.332    -.0144938     .042885
                        6  |   .0404866   .0348105     1.16   0.245    -.0277406    .1087139
                        7  |    .086686    .062885     1.38   0.168    -.0365663    .2099383
                        8  |   .1495932   .0924915     1.62   0.106    -.0316867    .3308732
                        9  |   .2192219   .1170521     1.87   0.061    -.0101959    .4486398
                       10  |   .2838647   .1335963     2.12   0.034     .0220209    .5457086
                       11  |   .3344861   .1428484     2.34   0.019     .0545083    .6144639
                       12  |   .3659204   .1470744     2.49   0.013     .0776598     .654181
                       13  |   .3759237   .1481844     2.54   0.011     .0854876    .6663598
                       14  |   .3639433   .1468418     2.48   0.013     .0761387     .651748
                       15  |   .3306505   .1422547     2.32   0.020     .0518364    .6094647
                       16  |   .2784964   .1324306     2.10   0.035     .0189371    .5380557
                       17  |   .2129741   .1151502     1.85   0.064    -.0127162    .4386645
                       18  |   .1434574   .0899461     1.59   0.111    -.0328338    .3197486
                       19  |   .0817198   .0601743     1.36   0.174    -.0362196    .1996592
                       20  |   .0373136   .0325958     1.14   0.252     -.026573    .1012001
                       21  |   .0126924   .0133132     0.95   0.340     -.013401    .0387858
              ------------------------------------------------------------------------------
              -------------------------------------------
              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