Announcement

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

  • Plot only interaction terms in coefplot

    Hello,

    I use coefplot from SSC.

    I have four regressions and I am trying to plot only the coefficients of the interaction terms, using coefplot.

    Code:
    sysuse auto, clear
    
    reg price c.turn##i.foreign, r
    eststo m4
    reg price c.weight##i.foreign, r
    eststo m3
    reg price c.headroom##i.foreign, r
    eststo m2
    reg price c.mpg##i.foreign, r
    eststo m1
    
    coefplot (m1,label("Mileage")) (m2,label("Headroom")) (m3,label("Weight")) (m4,label("Turn")), keep(c.turn##i.foreign c.weight##i.foreign c.headroom##i.foreign c.mpg##i.foreign) vertical
    When I run the do-file Stata stops before plotting the coefplot and types:

    coefplot (m1,label("Mileage")) (m2,label("Headroom")) (m3,label("Weight")) (m4,label("Turn")), keep(c.turn##i.foreign c.weight##i.foreign c.headroom##i.fo
    > reign c.mpg##i.foreign) vertical
    (m1: no coefficients found, all dropped, or none kept)
    (m2: no coefficients found, all dropped, or none kept)
    (m3: no coefficients found, all dropped, or none kept)
    (m4: no coefficients found, all dropped, or none kept)
    (nothing to plot)
    Is there a solution or any other way to this? It works when I want to plot the independent variables (i.e. turn weight headroom mpg).

    Thanks in advance for any help.
    Last edited by Johannes Hansen; 18 Dec 2022, 03:23.

  • #2
    Thanks for the data example. You can refer to them collectively as highlighted:

    Code:
    coefplot (m1,label("Mileage")) ..., keep(*#*) vertical
    Note that the double hash adds both main effects and interactions with factor variable notation, but the interactions themselves are indicated with a single hash.

    Comment


    • #3
      Thank you very much Andrew. That solved my issue.

      Comment


      • #4
        Hello

        I am using coefplot command to plot the coefficients on the interaction terms.

        I am running the following code:

        reghdfe l_mkt_pen_wld_dual i.India##ib2.inc_grp##(c.L1.l_bias_dual c.l_initial_con_bias) [pweight = avg_weight_dual] if avg_weight_cum_dual <= 99, absorb(imp_fe#year exp_fe#year) vce(cluster id#year)
        estimates store m1

        coefplot (m1,label("Market Share Gains")), keep(*inc_grp#*)

        This code plots all the double as well as triple interaction terms involving the factor variable inc_grp.

        I tried running the following code:
        coefplot, keep(i.India##ib2.inc_grp#c.L1.l_con_bias_dual)
        But Stata gave me this error:
        (.: no coefficients found, all dropped, or none kept)
        (nothing to plot)
        I want to plot the triple interaction terms corresponding to i.India##ib2.inc_grp##c.L1.l_bias_dual
        I am not able to find the syntax on the help file for coefplot. Is there any way to do this?

        Thanks in advance for any help.

        Comment


        • #5
          Originally posted by Poovitha Murugasamy View Post
          I want to plot the triple interaction terms corresponding to i.India##ib2.inc_grp##c.L1.l_bias_dual
          Triple interaction terms would be identified by the highlighted:

          Code:
          coefplot, keep(*#*#*)

          Comment

          Working...
          X