Announcement

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

  • coefplot no plotting coinfidence intervals after contrast of margins for dummy variables only

    Dear Statalist,
    I file to plot Confidence interval of margin contrast of dummy variables.
    I am using coefplot from SSC Jann, B. (2014). Plotting regression coefficients and other estimates. The Stata Journal 14(4): 708-737.
    my code looks like

    [ sysuse auto, clear
    * dummy and contrast (NOT plotting CI )
    cap drop price2
    recode price (min/10000 = 0) (10000/max = 1), gen(price2)
    qui ologit rep78 i.price2##i.foreign
    margins , dydx(price2) over(r.foreign) contrast(effect) post pr(outcome(1))
    matrix list e(b)
    matrix list e(V)][/CODE]

    Interestingly, the issue is due when I compute contrast of margins and dummy at the same time.

    When the variable is continuous I do not have this issue :
    [ * continuous and contrast
    qui ologit rep78 c.price##i.foreign
    margins , dydx(price) over(r.foreign) contrast(effect) post pr(outcome(1))
    matrix list e(b)
    matrix list e(V)
    coefplot][/CODE]

    The issue is absent also when there is no contrast
    [ * dummy and no contrast
    qui ologit rep78 i.price2##i.foreign
    margins , dydx(price2) over(foreign) post pr(outcome(1))
    matrix list e(b)
    matrix list e(V)
    coefplot][/CODE]

    Any help is really wellcome

    Cesare Riillo

  • #2
    Dear all,
    the code I am using is properly reported below.
    I am new to the feature , sorry.
    cesare riillo

    Code:
     sysuse auto, clear
    
     * dummy and contrast (NOT plotting CI )
      cap drop price2
     recode price (min/10000 = 0) (10000/max = 1), gen(price2)
      qui ologit rep78 i.price2##i.foreign
     margins , dydx(price2) over(r.foreign) contrast(effect) post pr(outcome(1))
        matrix list e(b)
      matrix list e(V)
     coefplot
    
     * I am using I am using coefplot from SSC
    *  Jann, B. (2014). Plotting regression coefficients and other estimates. The Stata Journal 14(4):      708-737.
    * Jann, B. (2013). coefplot: Stata module to plot regression coefficients and other results.   Available from http://ideas.repec.org/c/boc/bocode/s457686.html.
    
     
     
     * continuous and contrast
       qui ologit rep78 c.price##i.foreign
     margins , dydx(price) over(r.foreign) contrast(effect) post pr(outcome(1))
         matrix list e(b)
     matrix list e(V)
     coefplot
    
     
      * dummy  and no contrast
      qui ologit rep78 i.price2##i.foreign
     margins , dydx(price2) over(foreign) post pr(outcome(1))
        matrix list e(b)
      matrix list e(V)
     coefplot

    Comment


    • #3
      Dear all,
      Ben Jann solved my issue. His email with the solution is below.

      Hi, this has to do with how margins saves the results in this case. By default, coefplot only plots the first equation, but in your first example this equation only contains a coefficient that is zero and has no variance. You can get the desired result by selecting the equation to be plotted:

      Code:
      sysuse auto, clear
      recode price (min/10000 = 0) (10000/max = 1), gen(price2) qui ologit rep78 i.price2##i.foreign margins , dydx(price2) over(r.foreign) contrast(effect) post pr(outcome(1)) matrix list e(b) matrix list e(V) coefplot, nolabel keep(1.price2:)
      (Surprising may be that coefplot does the right thing in your third example, because also in this example the first equation only contains coefficients that are zero. The reason is that coefplot also checks for omitted coefficients and if all coefficients in an equation are flagged as omitted, it moves to the next equation. For some reason, margins flags the coefficients as omitted only in the third example, but not in the first.)

      ben

      Comment

      Working...
      X