Announcement

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

  • Marginal Effects for Multinomial logistic model with fixed effects (femlogit model)

    Hi,

    This question is about the third-party program femlogit.

    I use data from the Health and Retirement Study (HRS), and I use 5 survey waves from HRS. My dependent variable takes three values each representing a labor market outcome (full-time, part-time, retired). Hence, I estimate a multinomial logit model (mlogit).

    I recently have learned about the multinomial logit model with fixed effects employed by the femlogit third party Stata command. My question is about calculating marginal effects after femlogit is executed. I have tried using the built-in margins command but it gives me results for one outcome, so it is not clear with which outcome that is, and in fact I am not sure of that is for an outcome at all. Hence, it seems the margins command cannot be used after femlogit is executed.

    I calculate the marginal effects myself by hand after I execute the mlogit model which I present below (marginal effects presented in column “mean”). The results from hand calculation (presented below) is the same as the results from what I obtain using the built-in margins command (presented below). Therefore, I use the same approach to calculate the marginal effects after I execute the femlogit command. However, I get errors when I attempt to calculate the marginal effects.

    First error occurs when I try to calculate predicted probabilities. As in the hand calculation of marginal effects for mlogit by hand, there should be three predicted probabilities for each of the three outcomes, but Stata reports an error which is “too many variables specified”. The predict command only works if I predict for one outcome. Again, it is not clear which outcome that is. Although, that one probability might be wrongly calculated, I use this prediction to verify the validity of the remaining part of the code for hand calculation of marginal effects for femlogit.

    The second error is related to the marginal effects for each variable. In order to calculate marginal effects, three coefficient estimates (_b[1:ELA2], _b[2:ELA2], _b[3:ELA2]) need to be considered in the code (gen mee = xb*(_b[1:ELA2] -(xb*_b[1:ELA2] + xb*_b[2:ELA2] + xb*_b[3:ELA2])), where xb is the predicted probability). However, Stata reports the error that “equation 1 not found”. The code works if I replace “_b[1:ELA2], _b[2:ELA2], _b[3:ELA2]” with _b[ELA2], but the results are not the same with the results I obtain when use the margins command. And I find the value of “_b[ELA2]” is the same as the coefficient estimate of ELA2 for outcome 1 (full-time). I am wondering if there is a different way for femlogit to include those coefficient estimates to do a further calculation, such as marginal effects.

    I present below the Stata commands I use and the output they generate.

    Thank you for your comments in advance.


    *** Multinomial logit model
    mlogit lfs ELA2, base(3)
    lfs Coef. Std. Err. z P>|z| [95% Conf. Interval]
    1
    ELA2 -.1497153 .035401 -4.23 0.000 -.2191001 -.0803306
    _cons -.1087555 .0170466 -6.38 0.000 -.1421662 -.0753448
    2
    ELA2 .0609291 .0421533 1.45 0.148 -.0216898 .1435481
    _cons -.8298635 .0212711 -39.01 0.000 -.8715541 -.7881729
    3 (base outcome)

    *** Average marginal effects calculated by margins
    margins, dydx(ELA2) \\ Three sets of marginal effects
    ELA2_predict dy/dx Std. Err. z P>|z| [95% Conf. Interval]
    1 -.0394275 .0076727 -5.14 0.000 -.0544658 -.0243893
    2 .0201901 .0060533 3.34 0.001 .0083258 .0320544
    3 .0192374 .0077584 2.48 0.013 .0040313 .0344435
    *** Average marginal effects calculated by hand
    predict p1 p2 p3
    gen me1 = p1*(_b[1:ELA2] -(p1*_b[1:ELA2] + p2*_b[2:ELA2] + p3*_b[3:ELA2]))
    gen me2 = p2*(_b[2:ELA2] -(p1*_b[1:ELA2] + p2*_b[2:ELA2] + p3*_b[3:ELA2]))
    gen me3 = p3*( -(p1*_b[1:ELA2] + p2*_b[2:ELA2] + p3*_b[3:ELA2]))
    sum me* \\ A match with command margins
    Variable Obs Mean Std. Dev. Min Max
    me1 22,31 -.0394275 .0006801 -.0398086 -.0382136
    me2 22,31 .0201901 .0003046 .0200194 .0207337
    me3 22,31 .0192374 .0009847 .0174799 .0197891
    *** Multinomial logit model with fixed effects
    xtset id SQ
    femlogit lfs ELA2, base(3)
    lfs Coef. Std. Err. z P>|z| [95% Conf.
    Interval]
    _1
    ELA2 -.3949637 .0603585 -6.54 0.000 -.5132642 -.2766631
    _2
    ELA2 .0633587 .0649147 0.98 0.329 -.0638718 .1905892
    _3 (base outcome)
    *** Average marginal effects calculated by margins
    margins, dydx(ELA2) \\ One set of marginal effects
    dy/dx Std. Err. z P>|z| [95% Conf. Interval]
    ELA2 -.3949637 .0603585 -6.54 0.000 -.5132642 -.2766631
    *** Average marginal effects calculated by hand (three predicted probabilities)
    predict pm1 pm2 pm3 \\ Error: too many variables specified
    gen mem1 = pm1*(_b[1:ELA2] -(pm1*_b[1:ELA2] + pm2*_b[2:ELA2] + pm3*_b[3:ELA2]))
    gen mem2 = pm2*(_b[2:ELA2] -(pm1*_b[1:ELA2] + pm2*_b[2:ELA2] + pm3*_b[3:ELA2]))
    gen mem3 = pm3*( -(pm1*_b[1:ELA2] + pm2*_b[2:ELA2] + pm3*_b[3:ELA2]))
    sum mem* \\ Error: [1:ELA2] not found

    *** Average marginal effects calculated by hand (one predicted probability)
    predict xb
    gen mee = xb xb*(_b[1:ELA2] -(xb*_b[1:ELA2] + xb*_b[2:ELA2] + xb*_b[3:ELA2])) \\ Error: equation 1 not found
    gen men = xb*(_b[ELA2]-(xb*_b[ELA2])) \\ Not a match with command “margins”
    Variable Obs Mean Std. Dev. Min Max
    mem 22,31 .0519882 .092794 0 .2176092


  • #2
    The calculation for marginal effects in femlogit model is still not clear. Is there anyone who could help?

    Comment


    • #3
      Dear Yakun,

      I am not familiar with the command that you are using, but I do not think you can compute marginal effects after estimating a multinomial logit with fixed effects. Please see this post about the binary logit (which is a special case of the model you are interested in) for more details.

      Best wishes,

      Joao

      Comment


      • #4
        Hi Yakun,

        I am having the exact same issue on calculating the probabilities and the margins. I tried to use the same commands as the mlogit but apparently it does not allow for estimation of probabilities in that way. Were you able to get an answer on this issue?

        Thanks.

        Sam.

        Comment


        • #5
          Dear all,

          this problem is related to the other thread https://www.statalist.org/forums/for...fects-femlogit. With this class of models, you cannot estimate effects on probabilities, neither with the binary xtlogit, fe, nor the multimomianl femlogit (it is also by design impossible to etimate effects on probabilities with the proposed solution to estimate fixed effects model with ordinal dependent variables, as they also get rid of the individual intercept with a sufficient statistic). Therefore, you cannot estimate effects on differences of predicted probabilities or marginal changes of probability. The only way out without completely giving up possible dependence between alpha_i and X_i is using individual dummies or the Mundlak device (panelwise means) aka hybrid models (there is also a slightly more general solution proposed by Chamberlain, but I never saw it used). Both need large T and large N.

          Best wishes

          Klaus

          PS: To avoid further confusion: I'm not a professor, and my first name is Klaus and my last name is Pforr.

          Comment

          Working...
          X