Announcement

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

  • mlogtest

    Hello,

    I am using Stata 14.2 and installed mlogtest (spost13). I am hoping somebody may have experience with mlogtest.

    I execute my mlogit regression and then attempt mlogtest, lr/all/etc.. and get the following error message: "data has been altered since mlogit was estimated". I am able to execute mlogitgof just fine. I tried reinstalling the command and that didn't help.

    Thanks,

    Robert



  • #2
    In Stata 14.2, I can't replicate:

    Code:
    . webuse nhanes2f, clear
    
    . mlogit health weight height i.female
    
    Iteration 0:   log likelihood = -15764.397  
    Iteration 1:   log likelihood = -15493.985  
    Iteration 2:   log likelihood = -15491.005  
    Iteration 3:   log likelihood = -15491.004  
    
    Multinomial logistic regression                 Number of obs     =     10,335
                                                    LR chi2(12)       =     546.79
                                                    Prob > chi2       =     0.0000
    Log likelihood = -15491.004                     Pseudo R2         =     0.0173
    
    ------------------------------------------------------------------------------
          health |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    poor         |
          weight |   .0078795   .0029609     2.66   0.008     .0020763    .0136826
          height |  -.0362365   .0064367    -5.63   0.000    -.0488521   -.0236208
    
    
    [Rest of output deleted]
    
    
    . mlogtest, lr
    
    LR tests for independent variables (N=10335)
    
      Ho: All coefficients associated with given variable(s) are 0
    
                     |      chi2    df   P>chi2
    -----------------+-------------------------
              weight |   171.905     4    0.000
              height |   460.599     4    0.000
            1.female |   104.950     4    0.000
    I suggest you show your code and output, using code tags like I just did. Better yet, provide a replicable example.

    Also, here is my version of mlogtest.

    Code:
    . which mlogtest
    c:\ado\plus\m\mlogtest.ado
    *! version 3.5.0 2016-10-25 | long freese | problem in Stata 14.2 smhsiao
    -------------------------------------------
    Richard Williams
    Professor Emeritus of Sociology
    University of Notre Dame
    StataNow Version: 19.5 MP (2 processor)

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

    Comment


    • #3
      In Stata 14.2, I am attempting to use mlogtest (spost13) immediately following my mlogit command. I am unable to get a result as I get a return message that the "data has been altered since mlogit was estimated."



      Code:
      . mlogit TIMINGANC c.ageM_del c.ageM_del2 ib(1).b1_01 ib(1999).b2_01 ib(1).v106 ib(1).v701 i.v501 ib(5
      > ).v190 ib(1).v714 radio c.v201 i(2).v025 [iweight=wgt] if b2_01>=1999
      
      note: 1999.b2_01 identifies no observations in the sample
      note: 2008.b2_01 omitted because of collinearity
      Iteration 0:   log likelihood = -7133.6382 
      Iteration 1:   log likelihood = -6542.1356 
      Iteration 2:   log likelihood = -6493.4262 
      Iteration 3:   log likelihood = -6491.3481 
      Iteration 4:   log likelihood = -6491.3407 
      Iteration 5:   log likelihood = -6491.3407 
      
      Multinomial logistic regression                 Number of obs     =      6,369
                                                      LR chi2(60)       =    1284.60
                                                      Prob > chi2       =     0.0000
      Log likelihood = -6491.3407                     Pseudo R2         =     0.0900
      
      --------------------------------------------------------------------------------------
                 TIMINGANC |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      ---------------------+----------------------------------------------------------------
      no_ANC               |
                  ageM_del |  -.0052072   .0029076    -1.79   0.073     -.010906    .0004917
                 ageM_del2 |   5.34e-06   3.92e-06     1.36   0.173    -2.34e-06     .000013
                           |
                     b1_01 |
                        2  |   .1358732    .128943     1.05   0.292    -.1168504    .3885968
                        3  |  -.0481839   .1272047    -0.38   0.705    -.2975005    .2011327
                        4  |  -.5314377   .1326889    -4.01   0.000     -.791503   -.2713723
                        5  |  -.1642282   .1259953    -1.30   0.192    -.4111744    .0827179
                        6  |  -.1408556   .1294425    -1.09   0.277    -.3945582    .1128471
                        7  |  -.5968642   .1361429    -4.38   0.000    -.8636995    -.330029
                        8  |  -.2778816   .1320377    -2.10   0.035    -.5366708   -.0190925
                        9  |  -.1397301   .1385683    -1.01   0.313     -.411319    .1318587
                       10  |  -.4688562   .1438285    -3.26   0.001     -.750755   -.1869575
                       11  |   -.478483   .1461263    -3.27   0.001    -.7648853   -.1920807
                       12  |  -.3625287   .1525743    -2.38   0.017    -.6615688   -.0634886
                           |
                     b2_01 |
                     1999  |          0  (empty)
                     2004  |   .4835833   .1116735     4.33   0.000     .2647072    .7024593
                     2005  |   .0571927   .1016433     0.56   0.574    -.1420246    .2564099
                     2006  |   .3193181   .0938224     3.40   0.001     .1354295    .5032067
                     2007  |   .0027357   .0880125     0.03   0.975    -.1697657    .1752371
                     2008  |          0  (omitted)
                           |
                      v106 |
             no education  |   .3711169   .0751965     4.94   0.000     .2237345    .5184993
                secondary  |  -.9216353   .2230225    -4.13   0.000    -1.358751   -.4845192
                           |
                      v701 |
             no education  |   .2082547   .0650121     3.20   0.001     .0808333    .3356761
                secondary  |  -.1095411   .1233797    -0.89   0.375    -.3513609    .1322787
                           |
                      v501 |
      living with partner  |   .5377412   .2732295     1.97   0.049     .0022212    1.073261
                           |
                      v190 |
                  poorest  |   .5206591   .1361256     3.82   0.000     .2538578    .7874603
                   poorer  |   .1537373   .1348572     1.14   0.254     -.110578    .4180526
                   middle  |  -.0392743   .1350085    -0.29   0.771     -.303886    .2253375
                   richer  |   -.088918   .1345031    -0.66   0.509    -.3525391    .1747032
                           |
                      v714 |
                       no  |   .2556752   .0677776     3.77   0.000     .1228336    .3885168
                           |
                     radio |  -.5095089   .0727285    -7.01   0.000    -.6520541   -.3669637
                      v201 |   .1178838   .0195737     6.02   0.000       .07952    .1562476
                           |
                      v025 |
                    rural  |    .792258   .1635846     4.84   0.000     .4716382    1.112878
                     _cons |  -.7273508   .5452793    -1.33   0.182    -1.796079    .3413769
      ---------------------+----------------------------------------------------------------
      early_1st_vis        |
                  ageM_del |  -.0051246   .0033835    -1.51   0.130    -.0117561    .0015069
                 ageM_del2 |   .0000105   4.71e-06     2.22   0.026     1.24e-06    .0000197
                           |
                     b1_01 |
                        2  |   .1488715   .1674503     0.89   0.374     -.179325     .477068
                        3  |   .0859704   .1663663     0.52   0.605    -.2401015    .4120424
                        4  |   .1981116   .1579686     1.25   0.210    -.1115013    .5077244
                        5  |   .2666855   .1570177     1.70   0.089    -.0410635    .5744346
                        6  |   .0631782   .1675003     0.38   0.706    -.2651164    .3914728
                        7  |   .3131532   .1612383     1.94   0.052     -.002868    .6291744
                        8  |   .2145203   .1643556     1.31   0.192    -.1076108    .5366514
                        9  |   .4846292   .1678566     2.89   0.004     .1556364     .813622
                       10  |   .1358122    .175157     0.78   0.438    -.2074892    .4791136
                       11  |   .5668669   .1696695     3.34   0.001     .2343208     .899413
                       12  |   .2968105   .1779236     1.67   0.095    -.0519132    .6455343
                           |
                     b2_01 |
                     1999  |          0  (empty)
                     2004  |  -.1587066   .1366357    -1.16   0.245    -.4265076    .1090944
                     2005  |  -.0932128   .1165017    -0.80   0.424     -.321552    .1351264
                     2006  |   .0154549   .1099811     0.14   0.888     -.200104    .2310139
                     2007  |   -.163443   .1018473    -1.60   0.109      -.36306    .0361739
                     2008  |          0  (omitted)
                           |
                      v106 |
             no education  |  -.1467074   .0865719    -1.69   0.090    -.3163852    .0229704
                secondary  |   .1314817   .1289474     1.02   0.308    -.1212505     .384214
                           |
                      v701 |
             no education  |   .1763101   .0813121     2.17   0.030     .0169413    .3356788
                secondary  |  -.0960861   .1126574    -0.85   0.394    -.3168905    .1247183
                           |
                      v501 |
      living with partner  |  -.1161659   .3191297    -0.36   0.716    -.7416485    .5093168
                           |
                      v190 |
                  poorest  |  -.2402368   .1496471    -1.61   0.108    -.5335398    .0530662
                   poorer  |  -.3298236   .1450933    -2.27   0.023    -.6142013    -.045446
                   middle  |  -.1360701   .1408515    -0.97   0.334    -.4121339    .1399938
                   richer  |  -.1927966   .1354894    -1.42   0.155    -.4583509    .0727578
                           |
                      v714 |
                       no  |   .0285673   .0754126     0.38   0.705    -.1192387    .1763733
                           |
                     radio |  -.0837297   .0769078    -1.09   0.276    -.2344662    .0670068
                      v201 |  -.1290656   .0243993    -5.29   0.000    -.1768874   -.0812438
                           |
                      v025 |
                    rural  |  -.5841399   .1325214    -4.41   0.000    -.8438771   -.3244027
                     _cons |   .7108815    .614104     1.16   0.247    -.4927402    1.914503
      ---------------------+----------------------------------------------------------------
      late_1st_vis         |  (base outcome)
      --------------------------------------------------------------------------------------
      
      .
      end of do-file
      
      . do "C:\Users\Robert\AppData\Local\Temp\STD06000000.tmp"
      
      . mlogtest, lr
      
      data has been altered since mlogit was estimated

      Comment


      • #4
        What happens if you drop iweight? Or the if? Let’s try to isolate what is causing the problem and then figure out how to solve it.
        -------------------------------------------
        Richard Williams
        Professor Emeritus of Sociology
        University of Notre Dame
        StataNow Version: 19.5 MP (2 processor)

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

        Comment


        • #5
          Why are you using iweights anyway? Pweights and fweights are much more common.
          -------------------------------------------
          Richard Williams
          Professor Emeritus of Sociology
          University of Notre Dame
          StataNow Version: 19.5 MP (2 processor)

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

          Comment


          • #6
            Thanks Richard. The issue seems to be the iweights as when I remove it I am able to get a results. I am using iweights as I am working with survey data.

            Comment


            • #7
              If you are working with survey data, you should probably use pweights or svyset the data and use the svy prefix.
              -------------------------------------------
              Richard Williams
              Professor Emeritus of Sociology
              University of Notre Dame
              StataNow Version: 19.5 MP (2 processor)

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

              Comment


              • #8
                Thanks Richard,

                I think the command cannot handle survey data. I svyset the data and used the prefit (removing the weight from the regression equation) and got:


                Code:
                . mlogtest, lr
                LR tests cannot be run with svy estimation
                Thanks anyway.

                Robert

                Comment


                • #9
                  LR definitely won't work with svy. Try the Wald option. And if it doesn't work you can do it with test commands. Long and Freese's book is pretty good at showing how different things could be done if you didn't have the spost commands. https://www.stata.com/bookstore/regr...ent-variables/
                  -------------------------------------------
                  Richard Williams
                  Professor Emeritus of Sociology
                  University of Notre Dame
                  StataNow Version: 19.5 MP (2 processor)

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

                  Comment


                  • #10
                    Ok, thanks much for the resource.

                    Comment


                    • #11
                      mlogtest seems to work, and you don't even need to specify the wald option.

                      Code:
                      webuse nhanes2f, clear
                      svy: mlogit health weight height i.female
                      mlogtest
                      Code:
                      . mlogtest
                      
                      Wald tests for independent variables (N=10335)
                      
                        Ho: All coefficients associated with given variable(s) are 0
                      
                                       |         F    df   df_r      P>F
                      -----------------+--------------------------------
                                weight |    23.317     4      4    0.000
                                height |    53.000     4      4    0.000
                              1.female |    10.297     4      4    0.000
                      -------------------------------------------
                      Richard Williams
                      Professor Emeritus of Sociology
                      University of Notre Dame
                      StataNow Version: 19.5 MP (2 processor)

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

                      Comment


                      • #12
                        Incidentally, in your earlier code you were using if to select cases. Don't do that with svy. Use subpop instead. See

                        https://stats.idre.ucla.edu/stata/fa...data-in-stata/
                        -------------------------------------------
                        Richard Williams
                        Professor Emeritus of Sociology
                        University of Notre Dame
                        StataNow Version: 19.5 MP (2 processor)

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

                        Comment


                        • #13
                          In Stata 14.2 after successfully running my mlogit command, I want to run mlogtest with some options like iia, lr, lrcomb, combine etc.
                          But, I am getting this:
                          . mlogtest, iia

                          Hausman tests of IIA assumption (N=27585)

                          Ho: Odds(Outcome-J vs Outcome-K) are independent of other alternatives
                          invalid syntax
                          _______

                          after running which mlogtest, I getting this


                          . which mlogtest
                          c:\ado\plus\m\mlogtest.ado
                          *! version 3.5.0 2016-10-25 | long freese | problem in Stata 14.2 smhsiao
                          ____

                          Where is the problem?

                          thank you

                          Comment

                          Working...
                          X