Announcement

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

  • Summarized Statistics Table with t-test for difference in means

    Dear Statalisters,

    I would like to get the following table for my summarized statistics. However, I don't know the right code to get the right column with p-value for difference.

    Click image for larger version

Name:	Summarized Stats.JPG
Views:	1
Size:	51.6 KB
ID:	1519722


    I'm using the following code so far:

    Code:
    by lobby: eststo: quietly estpost tabstat lev-ceocob , stat(mean median sd) col(stat)
    eststo: quietly estpost ttest lev-ceocob, by(lobby)
    esttab, cells ("mean(fmt(3)) p50(fmt(3)) sd(fmt(3))")
    esttab using Tabel2.rtf, noobs cells("mu_2 mu_1 b(star)") label replace
    The variable lobby indicates the type of firms with a binary variable, whether it is a Lobbying or Non-Lobbying Firm.

    Is there anyone who could help me? Thanks in advance!

  • #2
    In case anyone is still searching for the solution, I found it.

    Code:
    eststo lobbying: quietly estpost summarize roa-boardshares if lobby == 0
    eststo nonlobbying: quietly estpost summarize roa-boardshares if lobby == 1
    eststo diff: quietly estpost ttest roa-boardshares, by(lobby) unequal
    esttab lobbying nonlobbying diff, cells("mean(pattern(1 1 0) fmt(3)) sd(pattern(1 1 0)) b(star pattern(0 0 1) fmt(3)) t(pattern(0 0 1) par fmt(3))") label

    Comment


    • #3
      Thank you for posting the solution! Can you also provide the codes for the Wilcoxon test?

      Comment


      • #4
        Thank you so much Sander Van Mil. Really helpful. Keep posting.

        Comment


        • #5
          Hello, thank you so much for this. Just one quick question- how can I adjust the table labels for this?

          For example, I want columns 1, 2 and 3 to read more than average > 15 days late, average < 15 days late, and p-value for difference respectively.


          -------------------------------------------------------------------------------------------------
          (1) (2) (3)

          mean sd mean sd b t
          -----------------------------------------------------------------------------------------------------
          dropna(SALES_REV_T~) 6.890e+13 9.951e+13 1.886e+13 5.637e+13 5.004e+13*** (120.815)
          dropna(CF_FREE_CAS~) 6.566e+12 1.066e+13 1.740e+12 6.111e+12 4.826e+12*** (104.206)
          dropna(BS_TOT_ASSET) 8.079e+13 1.343e+14 2.247e+13 7.247e+13 5.832e+13*** (98.052)
          dropna(PROF_MARGIN) 19.882 25.471 10.534 14.077 9.347*** (89.255)
          dropna(EBITDA) 1.955e+13 2.812e+13 6.176e+12 1.694e+13 1.337e+13*** (106.229)
          dropna(RETURN_ON_A~) 12.479 8.529 6.344 8.778 6.135*** (104.680)
          dropna(RETURN_ON_I~) 14.860 9.138 8.183 10.152 6.677*** (98.075)
          dropna(CUR_RATIO) 2.369 1.017 2.368 1.149 0.001 (0.136)
          dropna(CASH_RATIO) 1.392 0.837 1.217 1.012 0.176*** (26.906)
          dropna(TOT_DEBT_TO~) 13.894 11.467 21.680 14.329 -7.786*** (-84.745)
          dropna(TOT_DEBT_TO~) 33.189 91.355 47.728 78.787 -14.539*** (-26.635)
          dropna(SHORT_AND_L~) 4.750e+12 7.063e+12 1.838e+12 4.459e+12 2.912e+12*** (85.219)
          -----------------------------------------------------------------------------------------------------
          Observations 133256 32833 166089
          -----------------------------------------------------------------------------------------------------

          Kind regards,
          kayleigh

          Comment


          • #6
            Is it possible to relocate sd below the b coefficient to have a less-wide table?

            Comment

            Working...
            X