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

  • Running margins with interactions and predicted probabilities


    I use stata 14.2

    I am working on a survey with a set of categorical variables that each have 3 possible outcomes (the man, the woman, both equally). In the following code, I will use one of these variables, called fc07n.
    I want to run a mlogit of these variables with several explanatory variables (such as income, diploma, etc). I also want to include in my model the interaction effect of two variables, namely gen & d_dipf.

    So I have:
    svyset [pweight=pondefcomp7]
    set more off
    mac def ego "c.age_07 c.revenu i.q1comp"
    mac def couple "i.d_empl i.d_dip ib5.d_dipf ib2.d_pcsf i.comprev"
    mac def background  "ib2.d_socper i.d_merfoy i.orgeo4"
    mac def family "ib1.d_enf i.d_jeunenf"
    mac def interaction "ib5.d_dipf#i.gen"
    I would like to have get the predicted probabilities for each of these variables, and the interaction, on an excel sheet.
    I thought doing :

    forvalues i=1/3 {
    svy: mlogit fc07n $ego $couple $background $family $interaction i.gen if champ==1, base(3)
    margins, dydx(*) predict(outcome(`i')) post
    outreg2 using "taches7.xls", label excel bdec(3) stat (coef) append
    would work, but I have two issues:

    1.the predicted probabilities do not appear on the excel sheet, but rather the regression coefficients, which is not what I want.

    2.the interaction effects are not showing on my spreadsheet. How so ?

    I am quite stuck with this, so I would be grateful if someone here had an solution for me !!

    Thanks a lot !
    Last edited by Mateo Acosta; 16 Jan 2020, 09:04.

  • #2
    I can answer part of this. I do not use outreg2, so I cannot tell you anything about what it does or does not show. But for your specific questions, outreg2 is not even getting this information because your preceding commands do not create it.

    1. -margins, dydx()- will not calculate predicted probabilities. It calculates only marginal effects. If you want predicted probabilities, use -margins- without the -dydx()- option.

    2. Again, because you issued a -margins, dydx()- command, you are getting as out put the marginal effects. Interaction terms do not have marginal effects!!! So you get nothing relating to them.


    • #3
      Thank you Clyde !!

      It seems to have worked. What do you use instead of outreg2 when you do similar stuff ?


      • #4
        I have nothing against -outreg2- (nor -estout-, -esttab-, -outreg- or -putexcel- or -putdocx- or similar programs.) It's just that although I do plenty of analyses like yours, I have very little use for a pretty-print back-end because:

        1. Most of the time somebody else on my team has the responsibility of transferring the Stata output into some kind of final report form. As an academic, I don't generate final reports very often. Usually I just pass my results on, in the form of Stata output, to somebody else who works it into the format the particular journal would want, or puts it into a Power Point that they will be presenting, etc.

        2. When the full Stata output is too detailed and cumbersome to include in, say, an email message where I want to discuss those results briefly with somebody, if it's just a few lines I want, I usually copy and paste them from my log file into the email. If it's more than that, but less than the whole thing, I just write some custom code to produce the particular reduced output I'm looking for, which means using postfiles or frames to hold outputs extracted from r(table) or e(b).

        If I had to do this sort of thing more often, and if there were a single standard layout that I needed to use, I would use something like -outreg2- (or, write my own version of it customized to my particular output layout), but I don't so it's not worth my time and effort.


        • #5
          I'll just add that I use esttab. It seems to have the defaults I want, and I have learned how to customize it when I want to.

          Having said that, it may be six of one and half a dozen of the other. It is often better to stick with the thing you know than to go to the trouble to learn something else that may be slightly better for some task.

          Come to think of it, I choose my statistical packages the same way. I used SPSS for around 30 years, and finally switched to Stata because I thought it was much better.

          If I had no money for software and was starting from scratch, I might use R. But since I do have money for software, I won't switch to R or even learn much R unless I see a compelling advantage to doing so.
          Richard Williams, Notre Dame Dept of Sociology
          Stata Version: 16.1MP (2 processor)

          EMAIL: rwilliam@ND.Edu