Announcement

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

  • Plotting correct CIs with coefplot (considering the covariance between two groups )

    Dear Statalist forum,

    I am trying to plot confidence intervals of a model's interaction effects. However, I noticed that coefplot plots the CIs of the estimated coefficients as if they were independent from each other. Below a working example. Post-estimation tests confirm that the coefficients are not equal. Yet, coefplot draws the CIs in such way that it appears that they overlap. How can I adapt coefplot so that it accounts for the covariance between the two variables? Do I really need to manually extract the coefficient markers and CIs? Thanks a lot!

    Code:
    * I use the community-written package reghdfe
    ssc install regdfe
    
    ** load sample data
    sysuse auto.dta, clear
    
    * Run the reghdfe model with the interaction and test the difference
    reghdfe price c.gear##b0.foreign, noabsorb vce(cluster rep78)
    test _b[c.gear#0.foreign] = _b[c.gear#1.foreign]
    lincom c.gear - c.gear#1.foreign
    
    * Estimate marginal effects for domestic cars (foreign==0)
    reghdfe price c.gear##b0.foreign, noabsorb vce(cluster rep78)
    margins, dydx(gear) at(foreign==0) noestimcheck level(95) post
    estimates store margin_0
    
    * Estimate marginal effects for foreign cars (foreign==1)
    reghdfe price c.gear##b0.foreign, noabsorb vce(cluster rep78)
    margins, dydx(gear) at(foreign==1) noestimcheck level(95) post
    estimates store margin_1
    
    * Plot the results with coefplot
    coefplot margin_0 margin_1, xline(0, lc(maroon) lp(dash)) ///
           legend(order(2 "Domestic" 4 "Foreign") holes(1 3))  // CIs are overlapping

  • #2
    The confidence intervals are correct, but your assumption that overlapping confidence intervals indicate non-significant differences is incorrect. So there is there is nothing you need to do about that graph.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment

    Working...
    X