Announcement

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

  • Modifying coefficient in Coefplot

    Hello, I am running this regression and want to plot the coefficients with significance star and confidence interval.

    xtreg HCR_URP c.ln_pc_nsdp_2##ib1.State Year, fe vce(robust)

    For interpretation, I must add the log_pc_nsdp2 coefficient(Base state) with each state's coefficient.
    Is it possible to plot the coefficients after adding.

    Thank You
    Attached Files

  • #2
    You can use margins to do this:

    Code:
    . webuse pig, clear
    (Longitudinal analysis of pig weights)
    
    . xtset id week
    
    Panel variable: id (strongly balanced)
     Time variable: week, 1 to 9
             Delta: 1 unit
    
    . gen group = mod(id,3)
    
    . reg weight c.week##i.group, vce(robust) // coeflegend
    
    Linear regression                               Number of obs     =        432
                                                    F(5, 426)         =    1317.15
                                                    Prob > F          =     0.0000
                                                    R-squared         =     0.9342
                                                    Root MSE          =     4.2948
    
    ------------------------------------------------------------------------------
                 |               Robust
          weight | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
            week |   6.040104   .1542765    39.15   0.000     5.736866    6.343342
                 |
           group |
              1  |  -.4053819   .8390841    -0.48   0.629    -2.054642    1.243878
              2  |   .2821181   .9709362     0.29   0.772    -1.626304     2.19054
                 |
    group#c.week |
              1  |   .1442708   .1861637     0.77   0.439     -.221643    .5101846
              2  |   .3651042   .2269421     1.61   0.108    -.0809615    .8111698
                 |
           _cons |    19.3967   .6640944    29.21   0.000     18.09139    20.70201
    ------------------------------------------------------------------------------
    
    . margins group, dydx(week)
    
    Average marginal effects                                   Number of obs = 432
    Model VCE: Robust
    
    Expression: Linear prediction, predict()
    dy/dx wrt:  week
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    week         |
           group |
              0  |   6.040104   .1542765    39.15   0.000     5.736866    6.343342
              1  |   6.184375   .1041907    59.36   0.000     5.979583    6.389167
              2  |   6.405208   .1664376    38.48   0.000     6.078067     6.73235
    ------------------------------------------------------------------------------
    
    . /* Verify By Hand */
    . lincom _b[week] + 0 
    
     ( 1)  week = 0
    
    ------------------------------------------------------------------------------
          weight | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             (1) |   6.040104   .1542765    39.15   0.000     5.736866    6.343342
    ------------------------------------------------------------------------------
    
    . lincom _b[week]+_b[1.group#c.week]
    
     ( 1)  week + 1.group#c.week = 0
    
    ------------------------------------------------------------------------------
          weight | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             (1) |   6.184375   .1041907    59.36   0.000     5.979583    6.389167
    ------------------------------------------------------------------------------
    
    . lincom _b[week]+_b[2.group#c.week]
    
     ( 1)  week + 2.group#c.week = 0
    
    ------------------------------------------------------------------------------
          weight | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             (1) |   6.405208   .1664376    38.48   0.000     6.078067     6.73235
    ------------------------------------------------------------------------------
    If you want to replicate lincom in your example, you can uncomment the coeflegend option to see how Stata names the coefficients.

    Comment


    • #3
      Thanks for sharing but this is not helping,

      Comment

      Working...
      X