Announcement

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

  • Gologit2 + interactions: representing AME with coeplot command

    Hi everyone, and thank you in advance for helping me with the problem i'll now briefly introduce.

    I'im running a gologit2 on a dependent variable with five ordered categories. The model is the following:

    gologit2 volunteering i.grandchildren2 i.caringchgr_nt1 age i.male i.edulevel i.socioeconclass i.work_net i.cohabiting i.municipality i.arean4, autofit lrforce

    where grandchildren2 is the main covariate and has as well three ordered categroies


    Then i calculate the AME for my main covariate:

    margins, dydx(i.grandchildren2) post;


    and i plot the using the following code:

    coefplot (, keep(*:1._predict) label("Not at all")) ///
    (, keep(*:2._predict) label("A little")) ///
    (, keep(*:3._predict) label("Moderately")) ///
    (, keep(*:4._predict) label("Quite a bit")) ///
    (, keep(*:5._predict) label("Very much")), ///
    swapnames xline(0) legend(off) ///
    grid(between glcolor(black) glpattern(dash)) ///
    ytitle() ///
    xtitle() ///
    title("") name(grafico1, replace)

    The resuly i get is fine, but the problem is when i run the same model including an interaction term:

    gologit2 volunteering i.grandchildren2##i.work_net i.caringchgr_nt1 age i.male i.edulevel i.socioeconclass i.cohabiting i.municipality i.arean4, autofit lrforce

    where grandchildren2 is the same as before and work is again an ordered with three categories.

    My problem is how to manage with plotting in a clear way the marginal effects for this interaction. I would appreciate any suggestion (feel free to make any observation also on the code i use to plot the AME from the model with no interaction)




  • #2
    A reproducible example could make it clearer what you are getting and what you don’t like about it.

    Also, if you can find an example where mlogit produced a graph like you wanted, the same code might be easily adaptable for gologit2.
    -------------------------------------------
    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
      You might look at this handout and see if it gives you any ideas for presenting results.

      https://www3.nd.edu/~rwilliam/xsoc73994/Margins05.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


      • #4


        Dear Professor Williams,
        Thank you for you immediate reply.

        I'll try to be nore specific.

        First step. Model with no interactions:
        gologit2 volunteering i.grandchildren2 i.caringchgr_nt1 age i.male i.edulevel i.socioeconclass i.work_net i.cohabiting i.municipality i.arean4, autofit lrforce
        margins, dydx(i.grandchildren2) post;

        The following is the graph that i obtain by using the command coefplot with this code:
        coefplot (, keep(*:1._predict) label("Not at all")) ///
        (, keep(*:2._predict) label("A little")) ///
        (, keep(*:3._predict) label("Moderately")) ///
        (, keep(*:4._predict) label("Quite a bit")) ///
        (, keep(*:5._predict) label("Very much")), ///
        swapnames xline(0) legend(off) ///
        grid(between glcolor(black) glpattern(dash)) ///
        ytitle() ///
        xtitle() ///
        title("") name(grafico1, replace)

        Click image for larger version

Name:	grafico1.png
Views:	2
Size:	28.9 KB
ID:	1779544

        And i find this graph useful to represent the marginal change in the probability of each outcome of the dependent variable based on the independent variable grandchildren2.

        Second step. Model with interaction:
        gologit2 volunteering i.grandchildren2##i.work_net i.caringchgr_nt1 age i.male i.edulevel i.socioeconclass i.cohabiting i.municipality i.arean4, autofit lrforce

        Here I introduce the interaction term for two ordered response categories: grandchildren2=3 categories; work_net=3 categories.
        Than i calculate the marginal effects of grandchildren2 conditioned on work_net in the following way:

        margins, dydx(grandchildren2) at(work_net=(1 2 3)) predict(outcome(1))
        margins, dydx(grandchildren2) at(work_net=(1 2 3)) predict(outcome(2))
        margins, dydx(grandchildren2) at(work_net=(1 2 3)) predict(outcome(3))
        margins, dydx(grandchildren2) at(work_net=(1 2 3)) predict(outcome(4))
        margins, dydx(grandchildren2) at(work_net=(1 2 3)) predict(outcome(5))

        Ideally, i would like to present graphically these results in a similar fashion of the above picture. The problem is that I cannot find a useful example for my purpose, and this makes me wonder whether this is a good way to treat post-estimation of a gologit2 with interaction of 2 categorical variables.
        Hoping I clarified my problem, I thank you lot in advance for any helpful suggestion


        Attached Files

        Comment


        • #5
          It would still be helpful if you provided data (it doesn’t even have to be your own) so that we could run similar analyses and see what things looked like.

          unless you have an ancient version of Stata, you shouldn’t need 5 separate margins commands. Just drop the predict code. Then everything would be available to post at the same time ( instead of in 5 separate pieces) and maybe you could get the graph you want from there.

          Sorry, I am having a hard time visualizing what you want to do. But I don’t remember anybody ever trying to do things quite this way, and you seem to be implying that you just made this up since you say you can’t find a similar example. (But remember a similar example using mlogit might work too.)

          I find things like the mtable command (see the handout I linked to earlier) very useful for comparing predicted values, e.g. how does a Black Female 30 year old compare to a White Female 30 year old? So if you can’t get the graphic you want, see if there are other ways to convey your most critical points.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

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

          Comment


          • #6
            Accidental double post
            Last edited by Richard Williams; 05 Jul 2025, 18:32.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

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

            Comment

            Working...
            X