Announcement

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

  • Graphing interaction term

    Hello,
    I have an interaction term that I would like to graph. I would like to replicate the graph below (attached). In my case instead of women/men it is son/no son and the x axis would be the different wealth quintiles.
    I have tried to replicate it using:
    Code:
    xtreg M1  dbirthstat2 i.qwealth 0.sondum2#1.qwealth 0.sondum2#2.qwealth 0.sondum2#3.qwealth 0.sondum2#4.qwealth 0.sondum2#5.qwealth , re theta
    margins qwealth#sondum2
    marginsplot, recast(scatter)
    But that doesn’t produce the graph I’m looking for. This is my data
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double Findid float sondum2 byte qwealth
    601004802 0 3
    601004802 0 3
    601005902 1 1
    601005902 1 1
    601025702 1 2
    601025702 1 3
    601037702 1 1
    601037702 1 1
    601038302 1 1
    601038302 1 1
    601054402 1 2
    601054402 0 2
    601056302 0 4
    601056302 0 4
    601058302 1 1
    601058302 0 1
    601058602 1 2
    601058602 1 2
    601059402 0 3
    601059402 0 2
    601060202 1 2
    601060202 0 2
    601060302 1 2
    601060302 1 1
    601061202 0 2
    601061202 0 2
    601061302 0 1
    601061302 0 1
    601061602 1 1
    601061602 1 1
    601061802 1 1
    601061802 0 1
    601062002 1 3
    601062002 1 2
    601062302 1 2
    601062302 0 1
    601062802 1 3
    601062802 0 2
    601063102 0 4
    601063102 0 4
    601065402 0 1
    601065402 0 1
    601067002 0 1
    601067002 0 1
    601069302 1 1
    601069302 0 1
    601070202 1 3
    601070202 0 3
    601070802 0 3
    601070802 0 1
    601071402 1 2
    601071402 1 1
    601071502 0 2
    601071502 0 1
    601071602 0 2
    601071602 0 1
    601071702 0 4
    601071702 0 2
    601072002 1 2
    601072002 0 1
    601072702 1 3
    601072702 1 4
    601072902 1 3
    601072902 0 2
    601073102 0 2
    601073102 0 1
    601074202 0 2
    601074202 0 3
    601074502 1 3
    601074502 1 2
    601075502 0 2
    601075502 0 2
    601075902 0 1
    601075902 0 3
    601077402 1 1
    601077402 0 2
    601078802 0 2
    601078802 0 1
    601079402 0 2
    601079402 0 1
    601079502 1 2
    601079502 0 2
    601080302 1 3
    601080302 0 4
    601081102 1 3
    601081102 1 1
    601082202 0 2
    601082202 0 2
    601082402 0 1
    601082402 0 1
    601083402 0 2
    601083402 0 2
    601084002 0 1
    601084002 0 3
    601084502 0 1
    601084502 0 1
    601084902 1 2
    601084902 1 1
    601085202 1 2
    601085202 0 2
    end
    label values sondum2 sondum
    label def sondum 0 "Has sons", modify
    label def sondum 1 "No son", modify
    label values qwealth qwealth
    label def qwealth 1 "Richest", modify
    label def qwealth 2 "Rich", modify
    label def qwealth 3 "Middle", modify
    label def qwealth 4 "Poor", modify
    Attached Files

  • #2
    I gather the user-written - coefplot - can do the trick.
    Best regards,

    Marcos

    Comment


    • #3
      Thank you for your quick response Marcos. I have attempted with coefplot and I get the following graph after inputing this code:

      Code:
      xtreg M1  dbirthstat2 i.qwealth 0.sondum2#1.qwealth 0.sondum2#2.qwealth 0.sondum2#3.qwealth 0.sondum2#4.qwealth 0.sondum2#5.qwealth , re theta
      est store model1
      coefplot model1, vertical  fcolor(*.5) ciopts(recast(rcap)) citop  ytitle(Linear prediction) keep (0.sondum2#1.qwealth 0.sondum2#2.qwealth 0.sondum2#3.qwealth 0.sondum2#4.qwealth 0.sondum2#5.qwealth)
      The graph created is still not exactly what I am looking for, any ideas on where I am going wrong?
      Attached Files

      Comment


      • #4
        I have tried following the advice found here: https://stackoverflow.com/questions/...ms-in-coefplot

        Code:
        xtreg D1  dbirthstat2 spercent2 totalchild i.educ qwealth#sondum2 , re theta coeflegend
        local coefinter 1.sondum2#1.qwealth 1.sondum2#2.qwealth 1.sondum2#3.qwealth 1.sondum2#4.qwealth 1.sondum2#5.qwealth 0.sondum2#1.qwealth 0.sondum2#2.qwealth 0.sondum2#3.qwealth 0.sondum2#4.qwealth 0.sondum2#5.qwealth
        coefplot, keep(`coefinter')
        However, this returns this error:
        (.: no coefficients found, all dropped, or none kept)
        (nothing to plot)

        Any help would be greatly appreciated.

        Comment


        • #5
          Hi have you found a solution to this?

          Comment


          • #6
            I've been able to plot interactions with - coefplot - without trouble.

            Going directly to the point, I believe the example in #4 was inspired in this text.

            Being this so, the example clearly shows the inclusion of the interaction term according to the order of the - regress - command, not the opposite way.

            Hopefully that helps.

            Best regards,

            Marcos

            Comment

            Working...
            X