Announcement

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

  • Graphs with mlogit command

    Dear Stata experts,

    I am running a multinomial regression with mlogit command. I am trying to represent graphically marginal effects and z-statistics according to Wiersema and Bowen (2009) study. However, I have found some problems.

    Imagine that I have a dependent variable, depvar (whose value can be 1, 2 or 3) and three independent variables: X, Z and W.

    When I follow the commands suggested by Wiersema and Bowen (2009) to graph marginal effects of X on depvar (e.g.), I find these Stata outcomes:

    mlogit depvart X Z W, baseoutcome(1) nolog cluster(id)

    Multinomial logistic regression Number of obs = 2044
    LR chi2(16) = 142.15
    Prob > chi2 = 0.0000
    Log likelihood = -728.19599 Pseudo R2 = 0.0889

    ---------------------------------------------------------------------------------
    depvar | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    ----------------+----------------------------------------------------------------
    1 | (base outcome)
    ----------------+----------------------------------------------------------------
    2 |
    X | -.2188117 .0730577 -3.00 0.003 -.3620021 -.0756212
    Z | -.1347548 .107372 -1.26 0.209 -.3452001 .0756905
    W | 1.264154 .3165777 3.99 0.000 .6436732 1.884635
    _cons | -2.864977 .3343431 -8.57 0.000 -3.520277 -2.209676
    ----------------+----------------------------------------------------------------
    3 |
    X | -.0370888 .0854292 -0.43 0.664 -.2045269 .1303493
    Z | -.1574901 .1573289 -1.00 0.317 -.4658492 .1508689
    W | .8619795 .4664669 1.85 0.065 -.0522787 1.776238
    _cons | -3.749001 .476946 -7.86 0.000 -4.683798 -2.814205
    ---------------------------------------------------------------------------------

    . predict p1 p2 p3
    (option pr assumed; predicted probabilities)

    . local vb _b[_cons] + _b[X]*X + _b[Z]*Z + _b[W]*W

    . local phat (exp(`vb')/(1+exp(`vb')))

    . predictnl meX = `phat'*(1-`phat')*_b[X], se(meX_se)
    Warning: prediction doesn't vary with respect to e(b).
    Warning: prediction constant over observations; perhaps you meant to run nlcom.

    . gen z_stat = meX/meX_se
    (2044 missing values generated)


    Missing values are generated because meX_se are 0 (from the predictnl command), but I do not understand why it happens.

    Is there a problem with data? Or these kind of commands can only been used with logit regression (not with mlogit)? If that was the case, could anybody help me to build the marginal effects graphs to better interpret results in a multinomial regress?

    I would appreciate any help.
    Thank you in advance.

  • #2
    In a multinomial logistic regression, you have multiple (3, in your case) outcomes. The expression _b[_cons] + _b[X]*X + _b[Z]*Z + _b[W]*W fails to specify which of the three outcomes' coefficients you are interested in. I believe that by default you get the first outcome's coefficients (but I'm not 100% certain of that).

    In any case, if you are interested in marginal effects, rather than computing them yourself from first principles, it is less error-prone and much easier to use the -margins- command. If you are interested in the marginal effects of each of X, Z, and W, on the probability of each outcome level, you can get them all with a one-line command:

    Code:
    margins, dydx(X Z W)
    To collect those results in a way that will enable you to work with them and graph them, you can pull them out of r() immediately after the -margins- command:

    Code:
    matrix M = r(b)
    matrix V = r(V)
    The marginal effects will be in matrix M. Matrix V will contain a covariance matrix among the marginal effects: the standard errors are then the square roots of the diagonal elements of the matrix.

    However, if you are primarily interested in graphs, look at the -marginsplot- command.

    The -margins- command is one of the most useful aspects of Stata, in my opinion. It will be well worth your time to learn to use it. The on-line manual section devoted to it is lengthy and has lots of helpful examples. But for a quick, very clear introduction, see Richard Williams'
    https://www3.nd.edu/~rwilliam/stats/Margins01.pdf, or for a somewhat more detailed version (but still shorter than the manual), http://www.stata-journal.com/sjpdf.h...iclenum=st0260.
    Last edited by Clyde Schechter; 08 Feb 2016, 08:49.

    Comment


    • #3
      By the way, for future reference, it is not a good idea to cite references as Wiersema and Bowen (2009). This is an international, interdisciplinary forum and it's a fair bet that most people have no idea what study you're referring to. In your post, you give enough information about what you're trying to do that no reference is necessary to answer your question. But if people did need to refer to the article, your citation would not enable them to find it. So please provide a full citation that includes the title of the article, the journal title, and volume and page numbers.

      Comment


      • #4
        Thank you very much for your recommendations, I will read the examples you proposed.
        Sorry, I forgot to include the reference:
        Wiersema, M. F., & Bowen, H. P. (2009). The use of limited dependent variable techniques in strategy research: issues and methods. Strategic Management Journal, 30(6), 679-692.

        Comment


        • #5
          Although I have checked prior references, I have a problem to develop my estimations. I am in the process of resubmitting a paper to a journal and the main challenge is related to the empirical part. Mainly, the AE suggested to use a multinomial regression. More importantly, the AE asked for doing the graphical representation of marginal effects that appears in Wiersema and Bowen (2009) to correctly interpret the hypotheses. At the end of the paper, in the Append section, there are the Stata commands to perform the graphs (that I have shown in the first post). However, I find the error message that I wrote in my post. Has anybody ever used these commands in a mlogit estimation? My doubt is if there is an alternative way to do it with a multinomial estimation (instead of logit command, as Wiersema and Bowen do). I do not have too clear the commands to do it properly. Thank you in advance.

          Reference:
          Wiersema, M. F., & Bowen, H. P. (2009). The use of limited dependent variable techniques in strategy research: issues and methods. Strategic Management Journal, 30(6), 679-692.

          Comment


          • #6
            Those commands won't work after -mlogit- because they refer to coefficients that do not exist after a multinomial regression. The error messages you get are, admittedly, do not explain the problem well. But the code you show in #1, which is fine after -logit-, is not compatible with -mlogit-.

            My institution does not provide me with electronic access to that journal, so I don't know exactly what results you are trying to get. In any case, with a multinomial model you're going to have to do something different from whatever was done with a logistic model. From #1, it appears that you are looking for some kind of graphical display of the results. The code that you presented in #1 would, after a logistic model, produce estimates of odds of positive outcome. So presumably you are looking to do something analogous. The default output of -margins- is the predicted probability (which, by the way, is I think much easier for readers to understand than odds) but you can get odds with the -expression(predict(pr)/(1-predict(pr)))- option. If the range of values of interest of X runs, say, from 10 through 50, you could try something like this:

            Code:
            forvalues i = 1/3 {
                 margins, at(X = (10(10)50)) expression(predict(outcome(`i'))/(1-predict(outcome(`i'))))
                 marginsplot, name(outcome`i', replace)
            }
            to get predicted odds of each outcome at various relevant values of X and graphs of those.

            Again, I think that people tend to understand probabilities better than odds, so if your reviewer will accept it, I would advise going to those. That would actually simplify the code to:

            Code:
             margins, at(X = (10(10)50))
            marginsplot
            to get all three outcomes' results at once, and plotted together.

            In any event, you are not going to be able to replicate exactly what Wiersema and Bowen did, so you need to find a reasonable approximation to it and submit that. If your reviewer is remotely reasonable, this won't be a problem.

            Comment


            • #7
              Thank you very much, Mr Schechter. I have followed your suggestion and I have calculated margins at different levels of my independent variables in terms of probabilities instead of odds (I also think that it is more intuitive). As the calculation allows to obtain z-statistics for each marginal effect, it is possible to do build a graph that mixs marginal effects and z-statistics (to know the significance of marginal effects at different levels of the independent variable). I have built the graph through Excel by taking data from Stata output. I think that this approach is close to the proposed in Wiersema and Bowen (2009). Thus, thank you very much for your time and help, it has been very useful.

              Comment

              Working...
              X