Announcement

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

  • est tab margins

    Dear all,
    I cannot have the results I want in the est tab output using :

    Code:
    quietly probit Y i.treat##i.post X
    eststo m1: margins treat, dydx(post) noestimcheck pwcompare post
    
    
    quietly probit Y i.treat##i.post X
    eststo m2: margins treat, dydx(post) noestimcheck pwcompare post
    
    quietly probit Y i.treat##i.post X
    eststo m3: margins treat, dydx(post) noestimcheck pwcompare post
    
    quietly probit Y i.treat##i.post X
    eststo m4: margins treat, dydx(post) noestimcheck pwcompare post
            
    esttab m1 m2 m3 m4 using regS_margins.tex, replace
    It's giving me the table of the effect for each group (an estimate for 1 and an estimate for 0) and not the effect of the difference in differences (1 vs 0), i.e. as if pwcompare is not included.
    Do you have any idea what I am doing wrong.
    Thank you.

  • #2
    estout is from SSC, as you are asked to explain (FAQ Advice #12). The -pwcompare- estimates are not available in the default e(b) and e(V) matrices. Instead, they are stored in e(b_vs), e(V_vs) and r(table_vs). The following uses estadd, which should come compiled with your estout installation. If not

    Code:
    ssc install estadd, replace
    Code:
    sysuse auto, clear
    qui sum weight, d
    gen hiweight = weight>r(p50)
    probit hiweight i.foreign##c.trunk
    eststo m1: margins, dydx(c.trunk) over(foreign) pwcompare(effects) post
    estadd matrix se_vs= r(table_vs)["se", 1...]
    estadd matrix p_vs= r(table_vs)["pvalue", 1...]
    estout m1, cells(b_vs(star pvalue(p_vs) fmt(%9.3f)) se_vs(par)) ///
    starlevels(* 0.10 ** 0.05 *** 0.01) stats(N, fmt(0)) mlab(none) eqlab(none)
    Res.:

    Code:
    . eststo m1: margins, dydx(c.trunk) over(foreign) pwcompare(effects) post
    
    Pairwise comparisons of average marginal effects
    
    Model VCE    : OIM                              Number of obs     =         74
    
    Expression   : Pr(hiweight), predict()
    dy/dx w.r.t. : trunk
    over         : foreign
    
    --------------------------------------------------------------------------------------
                         |   Contrast Delta-method    Unadjusted           Unadjusted
                         |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------------+----------------------------------------------------------------
    trunk                |
                 foreign |
    Foreign vs Domestic  |  -.0402967   .0228079    -1.77   0.077    -.0849993    .0044059
    --------------------------------------------------------------------------------------
    
    
    . estout m1, cells(b_vs(star pvalue(p_vs) fmt(%9.3f)) se_vs(par)) ///
    > starlevels(* 0.10 ** 0.05 *** 0.01) stats(N, fmt(0)) mlab(none) eqlab(none)
    
    ----------------------------
                   b_vs/se_vs  
    ----------------------------
    1vs0.foreign       -0.040*  
                      (0.023)  
    ----------------------------
    N                      74  
    ----------------------------
    Last edited by Andrew Musau; 16 Jul 2021, 03:05.

    Comment


    • #3
      Thanks a lot Andrew Musau ! much appreciated.

      Comment


      • #4
        Dear Andrew Musau,
        I am having trouble with estadd
        I receive the following error message:
        Code:
        . ssc install estadd, replace
        ssc install: "estadd" not found at SSC, type -findit estadd-
        (To find all packages at SSC that start with e, type -ssc describe e-)
        r(601);

        Comment


        • #5
          estadd is part of the estout package. Like Andrew said, you probably already have it installed. If not, install estout.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://www3.nd.edu/~rwilliam

          Comment


          • #6
            Andrew Musau I think I am doing something wrong.
            I got the table with esttab, but only the coefficient of 1 vs 0 is displayed, standard error and confidence intervals are not reported, even though I included them in the command.
            I think there is a problem with this line:

            Code:
             
             estadd matrix se_vs= r(table_vs)["se", 1...] estadd matrix p_vs= r(table_vs)["pvalue", 1...]
            It does not work for me, it works if I drop ["se", 1...] and ["pvalue", 1...], otherwise, it tells me that :

            Code:
            invalid syntax
            r(198);
            What do you think I am doing wrong?

            Comment


            • #7
              You probably have an older version of Stata (before version 16). Try

              Code:
              ssc install estout, replace
              sysuse auto, clear
              qui sum weight, d
              gen hiweight = weight>r(p50)
              probit hiweight i.foreign##c.trunk
              eststo m1: margins, dydx(c.trunk) over(foreign) pwcompare(effects) post
              mat rtable_vs= r(table_vs)
              estadd matrix se_vs= rtable_vs[rownumb(rtable_vs,"se"), 1...]
              estadd matrix p_vs= rtable_vs[rownumb(rtable_vs,"pvalue"), 1...]
              estout m1, cells(b_vs(star pvalue(p_vs) fmt(%9.3f)) se_vs(par)) ///
              starlevels(* 0.10 ** 0.05 *** 0.01) stats(N, fmt(0)) mlab(none) eqlab(none)

              Comment


              • #8
                Yes I have Stata 14.1. Now it worked, thank you so much!

                Comment

                Working...
                X