Announcement

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

  • Multinomial Logit Regression (mlogit)

    I am trying to run a multinomial logit regression with a base outcome, but Stata keeps coming back with "no observations". Does anyone know why this might be? This is not my field or expertise and I am just trying to successfully complete this task - any help would be amazing. Cheers.

  • #2
    You imposed some if condition that is eliminating all the observations in the sample. For example, maybe you eliminated all persons age 65 and older in data processing. Then you tried

    Code:
    drop if age > 65
    ...
    mlogit outcome x1 x2 x3 if age > 65
    Or, more likely, you created some flag for your if condition, but you created it such that it applies to nobody. You have to trace the previous steps you took to create the flag.
    Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

    When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Comment


    • #3
      Thank you for getting back to me, and thanks for the tip on dataex. I have copied the dataex below. Ideally, I want the base outcome to be Hostile = 0.


      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input double TobinsQ str18 ROA double(LongTermBuyandHold ShortTermBuyandHold) byte Hostile
       .20694736842105263 "0"                  -2.651471489  -.064926471 1
      -29.447513812154693 ".0833757421543681"    .213369749   .193013312 0
       3.6072961373390555 "-.8795986622073579" -12.62417622   .242725111 0
        1.115435232186501 ".0752240717029449"   -.187814578   .016722107 0
        .9841160220994475 "0"                             .   .005293385 1
        3.193863072011352 ".0200777078109748"  -1.603584617   .011875185 1
        .9406994424733909 ".3324112494236975"  -3.127323329   .076464091 1
       2.2326139088729016 ".2024691358024691"  -2.429788796  -.038913159 1
        .9055923501979074 ".0556182639091174"   -.588095823  -.006035753 0
         .773882945248584 ".0247637666992506"  -3.557659304    .19461205 1
        .7911060180393317 ".0368758144564283"  -3.557659304    .19461205 0
       1.5086064875305343 ".2260363344374184"    .869904275   .227586515 0
        3.066045157079017 ".060019989836817"     .869904275   .227586515 0
       1.3524624200647788 ".1860874669797476"  -14.10461482  -.337769901 0
       1.4990053050397876 "-.0597014925373134"   .678514953 -2.327497823 1
        3.179746835443038 ".2009174311926605"  -4.147320132   .143834362 1
        .8683963738668334 "-.0359380151665018"  -.699224469   -.03650774 1
        .9557926829268293 ".1278648974668275"  -2.720838889  -.017179695 0
       1.2780748663101602 ".1150519031141869"    .299857488   .063396196 1
        .9270792645969426 ".0507734259996622"   -.650284963   .120661235 0
       1.4520335985853228 ".1106965174129353"   -.069282789  -.109473061 1
        3.200552486187845 ".04029147021003"    -1.202381063   .227433761 1
       1.1026931643958462 ".3802521008403362"    .755089265   .030658726 1
         8.21081081081081 "-.3336805555555555" -4.058997639  -.302220259 1
         1.34066985645933 ".035538752362949"      .81276546  -.094727347 1
       1.3976559229803265 "0"                    .073784819  -.161815148 1
        2.230031948881789 ".0991293061489373"     -.2498809  -.051010498 1
        .7464850615114236 "-.0022068965517241"   .894692215  -.005453766 0
        .7514683153013911 "-.0161375661375661"  -.474747293  -.041317557 1
       18.055865921787706 "-.4462809917355373" -1.392802382   .078744561 1
         8.74204834605598 "-.2630225080385852" -1.392802382   .078744561 1
       .38534460671278503 ".0256858291106063"             .            . 0
        .8608725059181602 ".1796075717886621"  -1.065752069  -.192838383 1
        .9989527082310589 ".0352708580466588"             .  -.118500776 1
        .7893660531697341 ".1237373737373737"   -.132134841  -.029086718 0
        1.259129827013804 ".0965179774484079"             .  -.002543318 1
       3.1198916789758737 ".1689599352488871"    .314001293   .112795505 0
                    1.112 "-.0015584415584416"   .447171241  -.310404299 1
        3.635477582846004 "-.0803921568627451"   .075408056  -.069443033 1
        .6113770250368189 ".0384875084402431"  -62.20611596    .00651591 1
        .6113770250368189 ".0384875084402431"  -62.20611596    .00651591 0
       10.330396475770925 "-"                  -2.950152232  -.046817581 1
       1.0243248814677386 ".0886138613861386"    .511297892  -.011952607 0
       1.1730142323288542 ".1041001064962726"    .511297892  -.011952607 0
        .6428280081577158 ".0496725440806045"  -2.506987484   .274898911 0
        .8645621181262728 "0"                  -16.24721071   .043844657 1
         1.05407739413798 ".0804880920839589"    .869904275   .227586515 0
        .8170542635658915 ".1611479028697572"  -19.18113368  -.148375353 0
      end

      Comment


      • #4
        I don't have access to Stata on a public computer, so I can't test this out, but I see that ROA is entered as a string variable. The regression commands don't recognize string variables. I have a feeling that Stata is excluding all observations because of this.

        Try this:

        Code:
        destring ROA, generate(ROA_num)
        It will either generate a numeric version of ROA, or if ROA has strings that the computer doesn't recognize as numbers, it will protest. If that's the case, you need to decide how to deal with the situation. The ignore("...", "...", "...") option will tell Stata to ignore all the specified non-numeric characters in the double quotes. Cases with those values will get treated as ROA is missing for that case (e.g. the 7th case from the end). Cases with any of the independent or dependent variables missing will get excluded from the regression. You will need to enter all the cases which are non-numeric. To handle string variables, we need to use the quotes ("") to tell Stata that they're strings, and you need to spell exactly as they're written. In your case, I assume "-" means missing, and is the only indicator for missing variables, so you could type

        Code:
        destring ROA, generate(ROA_num) ignore("-")
        There's also a force option. I think this will ignore all non-numeric characters and replace with missing. Generally, you do not want to use the force option in any Stata command barring some edge cases plus you know exactly what you are doing. However, it's possibly worth mentioning.

        Last, all the cases you presented have the dependent variable equal to 0 or 1. Perhaps your full sample has a full set of cases with more than two values of the DV, e.g. 0 means no hostile takeover, 1 means hostile takeover, 2, 3, etc mean something else (e.g. Elon Musk/Twitter, whatever the heck that situation is). Ignore if you already know this, but if you only have two outcomes, that means logistic regression - although multinomial regression will still work in that it will fit the model.
        Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

        When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

        Comment


        • #5
          Hi Weiwen,

          Thank you so much for getting back to me. Fixing ROA did the trick, and you are right that technically this would be a binary regression. I had to change the hostile variable this morning and it didn't click that there were only 2 options now. Thank you!

          Comment


          • #6
            Originally posted by Annie MacKinnon View Post
            Hi Weiwen,

            Thank you so much for getting back to me. Fixing ROA did the trick, and you are right that technically this would be a binary regression. I had to change the hostile variable this morning and it didn't click that there were only 2 options now. Thank you!
            Glad this could be resolved!
            Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

            When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

            Comment

            Working...
            X