Announcement

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

  • Factor variables with mlogit

    Hi,
    First I just want to say that I am learning Stata, so forgive me if I'm missing something that is seemingly obvious.

    I am using survey data in my analysis for my dissertation, and I am trying to run the svy command with a subpop() and mlogit. Most of the variables in my model are categorical and some are continuous, so I am including the categorical variables as factor variables because I would also like to get the marginal effects for each level of these variables. However, when I try to run the mlogit, Stata acts as if it is running it, but it doesn't produce anything and doesn't give me an error, no matter how long I leave it to run. My dataset isn't huge, and most other commands run within a few seconds. What am I doing wrong? Below is the log with the code that I'm using. Stata just says that is is running mlogit on the estimation sample and then stops.

    . use "C:\Users\Jpapa\Desktop\MEPS data SAS\masterdata", clear

    .
    .
    . /*Ch 2 multinomial logistic regression*/
    .
    . svyset psuann [pweight=saqweight], strata(stratann) vce(linearized) singleunit(scaled)

    pweight: saqweight
    VCE: linearized
    Single unit: scaled
    Strata 1: stratann
    SU 1: psuann
    FPC 1: <zero>

    .
    .
    . /*mlogit for SPD*/
    . svy linearized, subpop(SPD): mlogit insstat i.yearind i.sex i.race i.hispyn i.region i.married
    > i.education i.empstat i.natstat c.pcs c.mcs i.povcat c.ftotval, baseoutcome(1)
    (running mlogit on estimation sample)



    Thanks.

  • #2
    Try running a much simpler mlogit model perhaps with just a two or three categorical independent variables and see how long it takes, then gradually add more variables.

    Comment


    • #3
      Hi William,

      Thanks for your reply. I tried the same model with one independent variable and the same issue happened...

      Comment


      • #4
        Does it work if you don’t use svy?

        what is the distribution of your dependent variable? Run a frequency that shows the number of categories and the count in each one.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

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

        Comment


        • #5
          1.) Yes, it works if I remove svy.

          2.) For this subpop I have small cell counts for the "exchange" option. I was planning on combining this with "private" but was waiting to hear back from my committee.

          3.) However, if I run the mlogit with svy and no subpop I get the same error.

          The log for items 1-3 listed below.

          1.) Log without svy (this is not the model I plan to run, just using it to figure out the bug):

          . mlogit insstat i.yearind

          Iteration 0: log likelihood = -159382.42
          Iteration 1: log likelihood = -157888.42
          Iteration 2: log likelihood = -157405.04
          Iteration 3: log likelihood = -157331.83
          Iteration 4: log likelihood = -157319.67
          Iteration 5: log likelihood = -157318.35
          Iteration 6: log likelihood = -157318.12
          Iteration 7: log likelihood = -157318.07
          Iteration 8: log likelihood = -157318.06
          Iteration 9: log likelihood = -157318.05
          Iteration 10: log likelihood = -157318.05
          Iteration 11: log likelihood = -157318.05
          Iteration 12: log likelihood = -157318.05

          Multinomial logistic regression Number of obs = 127,425
          LR chi2(19) = 4128.74
          Prob > chi2 = 0.0000
          Log likelihood = -157318.05 Pseudo R2 = 0.0130

          -----------------------------------------------------------------------------------
          insstat | Coef. Std. Err. z P>|z| [95% Conf. Interval]
          ------------------+----------------------------------------------------------------
          Private_Insurance | (base outcome)
          ------------------+----------------------------------------------------------------
          Exchange |
          yearind |
          2012 | .0234487 1684.948 0.00 1.000 -3302.414 3302.461
          2013 | .0499645 1711.317 0.00 1.000 -3354.071 3354.171
          2014 | 20.27506 1227.638 0.02 0.987 -2385.851 2426.401
          2015 | 20.74833 1227.638 0.02 0.987 -2385.377 2426.874
          2016 | 20.85385 1227.638 0.02 0.986 -2385.272 2426.979
          |
          _cons | -23.53505 1227.638 -0.02 0.985 -2429.661 2382.591
          ------------------+----------------------------------------------------------------
          Medicaid |
          yearind |
          2012 | .0355926 .0291777 1.22 0.223 -.0215946 .0927798
          2013 | .1684238 .0290931 5.79 0.000 .1114024 .2254452
          2014 | .3034336 .0290547 10.44 0.000 .2464876 .3603797
          2015 | .3584446 .0284142 12.61 0.000 .3027537 .4141355
          2016 | .3502689 .0285776 12.26 0.000 .2942578 .4062801
          |
          _cons | -1.387022 .0212799 -65.18 0.000 -1.42873 -1.345314
          ------------------+----------------------------------------------------------------
          Other_public |
          yearind |
          2012 | .0141477 .0335405 0.42 0.673 -.0515906 .0798859
          2013 | .0209275 .0342431 0.61 0.541 -.0461877 .0880428
          2014 | .0717619 .0347096 2.07 0.039 .0037323 .1397915
          2015 | .0777745 .0341681 2.28 0.023 .0108062 .1447428
          2016 | .1810327 .0336292 5.38 0.000 .1151207 .2469447
          |
          _cons | -1.715623 .0243677 -70.41 0.000 -1.763383 -1.667864
          ------------------+----------------------------------------------------------------
          Uninsured |
          yearind |
          2012 | .0779868 .0232178 3.36 0.001 .0324807 .1234929
          2013 | .1000455 .0236423 4.23 0.000 .0537075 .1463835
          2014 | -.1365182 .025278 -5.40 0.000 -.1860621 -.0869742
          2015 | -.3450069 .0259619 -13.29 0.000 -.3958913 -.2941225
          2016 | -.3989745 .026423 -15.10 0.000 -.4507626 -.3471863
          |
          _cons | -.7904161 .0170304 -46.41 0.000 -.8237952 -.7570371
          -----------------------------------------------------------------------------------


          2.) Distribution of dependent variable

          tabulate insstat if SPD==1

          Insurance Status | Freq. Percent Cum.
          ------------------+-----------------------------------
          Private Insurance | 833 21.01 21.01
          Exchange | 41 1.03 22.05
          Medicaid | 1,647 41.55 63.60
          Other public | 427 10.77 74.37
          Uninsured | 1,016 25.63 100.00
          ------------------+-----------------------------------
          Total | 3,964 100.00


          3.) svy:mlogit without subpop

          svy: mlogit insstat i.yearind
          (running mlogit on estimation sample)
          an error occurred when svy executed mlogit
          --Break--
          r(1);


          Comment


          • #6
            Jessica, your output would be much easier to read if you used code tags. See p. 12 of the statalist FAQ.

            I suspect exchange cases either have to be dropped or merged with another category. Look at how huge the standard errors are. Try dropping or merging the category cases and see if svy works then.

            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

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

            Comment


            • #7
              Hi Richard,

              It worked! Thank you so much for your help! I'm learning Stata as I go so I'm sure I will be back on this board (and perhaps emailing you, if you don't mind) with more questions. I'm already getting a similar issue with the margins command, but I want to read more about it before I throw my hands up and ask for help.

              Jessica

              Comment


              • #8
                You don't even have to ask Richard Williams for help in order to receive it.

                If you are not already familiar with his papers, you may find all you need, and more, in the nice overview of margins prepared by Richard at https://www3.nd.edu/~rwilliam/xsoc73994/Margins01.pdf with a more detailed paper in the Stata Journal at http://www.stata-journal.com/article...article=st0260. I'll also note that Margins01.pdf is followed by Margins02.pdf ... Margins05.pdf covering more specialized topics.

                And all five of these PDFs, and plenty more of use to someone learning about the analysis of categorical data, are linked to from https://www3.nd.edu/~rwilliam/xsoc73994/index.html - the material mentioned above is found in the section headed Interpreting results: Adjusted Predictions and Marginal effects.
                Last edited by William Lisowski; 07 Mar 2019, 19:11.

                Comment

                Working...
                X