Announcement

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

  • Coefficient labels for interaction terms?

    I would like to rename coefficient labels for the interaction term i.industry#c.new_Surprise. I want each label to be only the industry name, instead of the interaction (eg. only nodur, or even better "nondurables", instead of nodur # new_Surprise). i.industry takes on values 1-11 and is named after 11 industries. My line of code for coeflabels does not work. I've attached my data. Also, market # new_Surprise doesn't show up on the coefplot, but it should. It shows up with a coefficient in the regression. Thank you in advance.


    Code:
    reg return i.industry#(c.new_Expected c.new_Surprise) i.industry if ScheduledMeeting == 1
    coefplot, xline(0) keep(*rise) coeflabels(nodur # new_Surprise = "Nondurable" durbl # new_Surprise = "Durables")
    Click image for larger version

Name:	Screenshot 2024-03-29 at 2.30.24 PM.png
Views:	1
Size:	899.7 KB
ID:	1748281

    Attached Files
    Last edited by Ezra Pol; 29 Mar 2024, 16:43.

  • #2
    Dear Ezra,
    Ben Jann describes all what you need to know on his web page Labelling – How to label the coefficients
    I just follow his examples to explain coefplot options that you need to use for your case.

    First, you have
    to find out how an estimation command names its coefficients you can also type matrix list e(b) after estimating the model, or replay the model with the coeflegend option:
    Code:
    reg return i.industry#(c.new_Expected c.new_Surprise) i.industry if ScheduledMeeting == 1
    reg , coeflegend noheader
    which results in:
    Code:
    -----------------------------------------------------------------------------------------
                     return | Coefficient  Legend
    ------------------------+----------------------------------------------------------------
    industry#c.new_Expected |
                    market  |   -.509298  _b[1b.industry#c.new_Expected]
                     nodur  |   .1131063  _b[2.industry#c.new_Expected]
                     durbl  |  -1.086073  _b[3.industry#c.new_Expected]
                     manuf  |  -.8412245  _b[4.industry#c.new_Expected]
                     enrgy  |  -2.409805  _b[5.industry#c.new_Expected]
                     hitec  |  -.2868292  _b[6.industry#c.new_Expected]
                     telcm  |  -.3448779  _b[7.industry#c.new_Expected]
                     shops  |  -.2218947  _b[8.industry#c.new_Expected]
                      hlth  |   .1273321  _b[9.industry#c.new_Expected]
                     utils  |   .2127291  _b[10.industry#c.new_Expected]
                     other  |  -1.242582  _b[11.industry#c.new_Expected]
                            |
    industry#c.new_Surprise |
                    market  |  -.5840829  _b[1b.industry#c.new_Surprise]
                     nodur  |   -.625602  _b[2.industry#c.new_Surprise]
                     durbl  |   .1388892  _b[3.industry#c.new_Surprise]
                     manuf  |  -1.049416  _b[4.industry#c.new_Surprise]
                     enrgy  |   .0297583  _b[5.industry#c.new_Surprise]
                     hitec  |   .1632778  _b[6.industry#c.new_Surprise]
                     telcm  |  -.3354211  _b[7.industry#c.new_Surprise]
                     shops  |  -1.100825  _b[8.industry#c.new_Surprise]
                      hlth  |  -.7161387  _b[9.industry#c.new_Surprise]
                     utils  |  -1.750246  _b[10.industry#c.new_Surprise]
                     other  |  -1.189031  _b[11.industry#c.new_Surprise]
                            |
                   industry |
                     nodur  |   -.203511  _b[2.industry]
                     durbl  |   .1462183  _b[3.industry]
                     manuf  |   .0088735  _b[4.industry]
                     enrgy  |  -.0100076  _b[5.industry]
                     hitec  |   .0854198  _b[6.industry]
                     telcm  |  -.1698198  _b[7.industry]
                     shops  |   .0136692  _b[8.industry]
                      hlth  |  -.0834221  _b[9.industry]
                     utils  |  -.1608369  _b[10.industry]
                     other  |   .0726301  _b[11.industry]
                            |
                      _cons |   .2803801  _b[_cons]
    -----------------------------------------------------------------------------------------
    From the above, I now edit your code, like:
    Code:
    coefplot, xline(0) keep(*rise) coeflabels(2.industry#c.new_Surprise = "Nondurable" 3.industry#c.new_Surprise = "Durables") name(edit, replace)
    which results in:
    Click image for larger version

Name:	Example_coefplot_edit_interaction_labels.png
Views:	1
Size:	71.2 KB
ID:	1748304

    Next, we have to include the option baselevels to request to plot base level coefficients, like:
    Code:
    coefplot, xline(0) keep(*rise) coeflabels(1b.industry#c.new_Surprise = "Market (base)" 2.industry#c.new_Surprise = "Nondurable" 3.industry#c.new_Surprise = "Durables") baselevels name(base, replace)
    which results in:
    Click image for larger version

Name:	Example_coefplot_edit_base_interaction_labels.png
Views:	1
Size:	74.7 KB
ID:	1748305


    Happy plotting!
    http://publicationslist.org/eric.melse

    Comment


    • #3
      It works! Thank you so much, Eric.

      Comment

      Working...
      X