Announcement

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

  • Coefplot of AMEs: interaction with categorial variables

    Dear statlist users,

    I would like to display average marginal effects (AME) of a categorial variable conditioned on another interaction variable via -coefplot- after -margins, dydx() post-. I am estimating the AMEs of a categorial variable with 3 levels (rel_denom) for each level of the interaction variable with 4 levels (rel_imp) via the margins-command: all in all, there are 12 coefficients (3x4). However, coefplot only displays AMEs for the first level of the variable (rel_denom==1 vs. rel_denom==0) -- so only 4 coefficients are displayed, even though the margins-command shows all of them (see attachments).

    Here is my code:

    Code:
    xtreg depvar (i.rel_denom##i.rel_imp) if generation==0, fe vce(cluster schoolid)
    eststo m1: margins, dydx(rel_denom) over(rel_imp) post
    matrix list e(b)               // 1x16 matrix
    coefplot m1
    coefplot (m1, b(b[1,.]))   // the default: take the first row of the matrix
    The matrix e(b) is a 1x16 matrix (see attachment), and the help-file of coefplot tells me it automatically should use the estimates of the first row. I tried to play around with the coefplot-b()-option, but am not sure how to tell coefplot to use all estimated coefficents of the first row.

    With a categorial interaction variable like rel_imp, I could solve this problem estimating separate models for each level of rel_imp. However, I aime to use continuous interaction variables for rel_denom as well.

    I would be glad if someone could give me a hint with this.

    Anna
    Attached Files
    Last edited by Anna Berthold; 29 Jun 2022, 03:31.

  • #2
    coefplot is from SSC (FAQ Advice #12). Your description is sufficiently complicated not to warrant a data example. See the referenced FAQ for advice on how to provide one and the Stata manual for examples in case you are not able to use your own dataset.

    Comment


    • #3
      Thank you a lot for your comments! I am using the SSC command -coefplot- and Stata 16.1.

      I built an example with the sysuse data. My problem in short: the coefficients displayed by -margins- (in the example: 4x18 coefficients) are not fully displayed by -coefplot- (in the example: 18 coefficients). I would appreciate any help in that!

      Code:
      sysuse auto, clear
      regress price i.rep78##c.displacement
      eststo m1: margins, dydx(rep78) at(displacement=(79(20)425)) post
      coefplot m1

      Comment


      • #4
        Thanks for the reproducible example. You have a multi-equation model, so you need:

        Code:
        coefplot m1, keep(*:)

        Comment


        • #5
          Many thanks for your quick and great help! Happy to see that there is such a simple solution.
          Best,
          Anna
          Last edited by Anna Berthold; 30 Jun 2022, 01:46.

          Comment


          • #6
            .
            Last edited by Anna Berthold; 30 Jun 2022, 01:49. Reason: (double post by mistake, cant get this one deleted)

            Comment

            Working...
            X