Announcement

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

  • Margins and mfx

    Hello,

    I have two questions:

    1) I am a bit confused about the result of these two commands( mfx vs margins). I am working with a dataset and from what I have read, if I type the command mfx, I should get the marginal effects at the means. This is what I get:

    Marginal effects after logit
    y = Pr(low) (predict)
    = .29199716
    ------------------------------------------------------------------------------
    variable | dy/dx Std. Err. z P>|z| [ 95% C.I. ] X
    ---------+--------------------------------------------------------------------
    age | -.0060635 .00697 -0.87 0.384 -.019718 .007591 23.2381
    lwt | -.0020595 .00125 -1.65 0.098 -.004501 .000382 129.815
    race | .0999547 .04172 2.40 0.017 .018182 .181727 1.84656
    smoke*| .2261239 .07997 2.83 0.005 .06938 .382868 .391534
    ------------------------------------------------------------------------------
    (*) dy/dx is for discrete change of dummy variable from 0 to 1

    However, if I do the command: margins, dydx(x) atmeans I get:

    Conditional marginal effects Number of obs = 189
    Model VCE : OIM

    Expression : Pr(low), predict()
    dy/dx w.r.t. : age lwt race smoke
    at : age = 23.2381 (mean)
    lwt = 129.8148 (mean)
    race = 1.846561 (mean)
    smoke = .3915344 (mean)

    ------------------------------------------------------------------------------
    | Delta-method
    | dy/dx Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    age | -.0060635 .0069667 -0.87 0.384 -.0197179 .007591
    lwt | -.0020595 .0012455 -1.65 0.098 -.0045006 .0003816
    race | .0999547 .0417213 2.40 0.017 .0181825 .181727
    smoke | .2191961 .0765979 2.86 0.004 .0690669 .3693253
    ------------------------------------------------------------------------------

    why that diference for smoke ?

    2) how can I get the result y = Pr(low) (predict) = .29199716 using the command margins instead of mfx ?

    thank you
    AMD

  • #2
    Hi Dedes. First, please read the FAQ, especially points 12 and 6. Using code tags will make your output much easier to read.

    Second, when posting output from post-estimation commands like mfx and margins, it helps very much to post the code (and possibly output) from the estimation command as well.

    Third, I doubt very much that you want to be treating race as continuous, but that appears to be what you are doing.

    Finally, getting to your question -- I am guessing that margins is treating smoke as continuous, while mfx is treating it as a dichotomy. See

    Code:
    help fvvarlist
    for correct setup. Specifically, for margins to get it right, you probably want the estimation command to be something like

    Code:
    logit y age lwt i.race i.smoke
    For more on correct usage of the margins command, see

    http://www3.nd.edu/~rwilliam/stats3/Margins01.pdf

    -------------------------------------------
    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
      Hello,

      thank you for the answer.

      I have another issue with mfx and margins.

      When I use the command:
      margins, dydx(*) atmean predict(pr outcome(3)) -- I obtain the answer I am looking for.

      When I use the command,

      mfx, predict(pr outcome(3)) -- I get an error from saying stata predict() expression pr outcome(1) unsuitable for marginal-effect calculation

      How can I obtain the same results that I get from using margins command with the mfx command ?

      Thank you,

      AMD

      Comment


      • #4
        mfx is in effect superseded by margins. If you are asking how to get something from a superseded command which you can get otherwise , I suspect you are out of luck but I also wonder why.

        Richard's flagging of key points in the FAQ still applies.

        Comment


        • #5
          Hello,

          thanks for the answer.

          I am using stata 12.1. And I have also read that information about mfx and margins.
          And actually it was because I read it that I am confused.
          I have run the example on the help file:


          Code:
              . mlogit rep78 mpg displ
              . mfx, predict(p outcome(2))
              . mfx, predict(p outcome(2)) at(20 400)
              . mfx, predict(p outcome(2)) varlist(mpg)
          and it worked fine. So, why is it working on one data base and not on the other ?

          thanks
          amd

          Comment


          • #6
            Like Nick said, if you can get it to work with the new and officially approved command I am not sure why you want to bother with the old one.

            And like I said, when posting output from post-estimation commands like mfx and margins, it helps very much to post the code (and possibly output) from the estimation command as well. You are only showing us bits and pieces of the code. If you showed more, it might be obvious what the problem is. You can get weird and seemingly nonsensical errors just because you omitted a space. You said you changed the data set so you probably changed the mlogit command too, and you may have also tweaked the mfx commands to reflect the nature of your new data.

            You say "mfx, predict(pr outcome(3)) -- I get an error from saying stata predict() expression pr outcome(1) unsuitable for marginal-effect calculation" . I'd be surprised if that is the exact error message because the command says outcome(3) and the error message says outcome(1). But if that is exactly what Stata says I can't explain it without seeing everything in context.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

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

            Comment


            • #7
              Hi,

              I am also estimating a dynamic probit model. My explanatory variables include a set of 2 continuous variables (ratios) and three indicator variables. I am also including year fixed effects and industry-year interactions in my specification. However, if I am trying to compute the marginal effects on probability post estimation, I am unable to do so. I am using the command

              margins, dydx(varlist )

              The error message that appears is the following: default prediction is a function of possibly stochastic quantities other than e(b)

              Please let me know how can I correct this issue?

              Thank you so much

              Comment

              Working...
              X