Announcement

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

  • How to export a table from a ttest?

    I want to make a table for a paper from the results of an unpaired t-test with unequal variances; ttest Alfa == Beta, unpaired unequal

    I have tried googling for an answer, but I've not found a solution yet. Surely there must be a way?

  • #2
    You can do this using -estpost- and -esttab-, both of which are available via ssc. The author of the esttab command (Jann) keeps a website where he provides examples for using these commands. Follow this link: http://repec.org/bocode/e/estout/est...tml#estpost106 and once there, see the below example:

    Comment


    • #3
      John,
      This is a helpful link thank you for sharing it.
      Patrick

      Comment


      • #4
        Thank you, John!

        Comment


        • #5
          Originally posted by John Marvel View Post
          You can do this using -estpost- and -esttab-, both of which are available via ssc. The author of the esttab command (Jann) keeps a website where he provides examples for using these commands. Follow this link: http://repec.org/bocode/e/estout/est...tml#estpost106 and once there, see the below example:
          I found a video on this, ran all the ttest commands I needed to. Then went back and used eststo and everything was working fine. I accidentally ran one command twice though so I restarted. However, now it loos like this

          Code:
          . eststo: ttest GINIindexSIPOVGINI == tax_ex_sc, unpaired
          
          Two-sample t test with equal variances
          ------------------------------------------------------------------------------
          Variable |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
          ---------+--------------------------------------------------------------------
          GINIin~I |     147    39.68503    .7499371    9.092504     38.2029    41.16717
          tax_ex~c |      68    23.21283    .7369988    6.077448    21.74177    24.68388
          ---------+--------------------------------------------------------------------
          combined |     215    34.47522     .768316    11.26572    32.96078    35.98966
          ---------+--------------------------------------------------------------------
              diff |            16.47221    1.211919                14.08332     18.8611
          ------------------------------------------------------------------------------
              diff = mean(GINIindexSIPOV~I) - mean(tax_ex_sc)               t =  13.5918
          Ho: diff = 0                                     degrees of freedom =      213
          
              Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
           Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000
          
          
          last estimation results not found, nothing to store
          r(301)
          The error says

          So it runs but then does not store it. I followed your link and tried to fix my code accordingly but it doesn't work.

          The part that is annoying is, if I run

          Code:
          eststo: regress GINIindex tax_trade
          It works fine and if I run the same code for ttest above then it works. However, if I run esttab it gives me two columns that have the same values.

          Comment


          • #6
            Someone might help you with estout command. I would just present another alternative here. asdoc (from SSC) produces some quality tables with different ttest commands. Following are a few examples.

            Code:
            * Install asdoc
            ssc install asdoc
            One-sample ttests
            Code:
            sysuse auto, clear
            asdoc ttest rep78==0, replace title(T-test results : H1: mean = 0)
            
            * For appending similar test results, we can use the option rowappend
            asdoc ttest price==0, rowappend
            asdoc ttest mpg==0, rowappend
            asdoc ttest turn==0, rowappend
            asdoc ttest weight==0, rowappend
            asdoc ttest length==0, rowappend
            Click image for larger version

Name:	one sample.png
Views:	1
Size:	26.7 KB
ID:	1480058


            Two-sample tt-tests

            Code:
            asdoc ttest mpg==price, replace
            asdoc ttest trunk==price, rowappend
            Click image for larger version

Name:	two sample.png
Views:	1
Size:	19.3 KB
ID:	1480059

            Two-sample ttest over groups
            Code:
            bysort foreign: asdoc ttest mpg == price , replace
            Click image for larger version

Name:	two sample by groups.png
Views:	1
Size:	20.0 KB
ID:	1480060

            ​​​​​​
            Regards
            --------------------------------------------------
            Attaullah Shah, PhD.
            Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
            FinTechProfessor.com
            https://asdocx.com
            Check out my asdoc program, which sends outputs to MS Word.
            For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

            Comment


            • #7
              Those ttest results from asdoc do not bring back the same values.

              Comment


              • #8
                I solved the problem by doing this
                net install asdoc, from(http://fintechprofessor.com) replace

                Comment


                • #9
                  Hi Attaullah,

                  Thanks for introducing me to asdoc, which has been helpful for ttests.

                  I have 2 questions.

                  1) Is there a way of adding stars to means with significant differences?
                  2) Is there a way of renaming the column headers (i.e. treatment and control instead of Mean1 & Mean2) ?

                  After typing
                  Code:
                  help asdoc
                  I could not find an answer to either so I decided to ask here.

                  Thanks.

                  Comment


                  • #10
                    Originally posted by John Marvel View Post
                    You can do this using -estpost- and -esttab-, both of which are available via ssc. The author of the esttab command (Jann) keeps a website where he provides examples for using these commands. Follow this link: http://repec.org/bocode/e/estout/est...tml#estpost106 and once there, see the below example:
                    This was very very helpful thank you so much for sharing!

                    Comment


                    • #11
                      Adam Aberra Upon your request, I have added the cnames(Name 1, Name 2) option to asdoc. This option can be used with two sample ttest to write custom column names for the mean columns.
                      Code:
                      asdoc ttest mpg==price, replace cnames(Treatment, Control)
                      
                      asdoc ttest trunk==price, rowappend
                      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	16.2 KB
ID:	1570377


                      The new version ( Version 2.3.8.5 : Changes made on August 27, 2020) of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
                      Code:
                      net install asdoc, from(http://fintechprofessor.com) replace
                      Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.

                      asdocx is now available
                      A more powerful and flexible version of asdoc is now available. I call it asdocx. You may like to check the details here

                      https://fintechprofessor.com/asdocx


                      Please do remember to cite asdoc. To cite:

                      In-text citation
                      Tables were created using asdoc, a Stata program written by Shah (2018).

                      Bibliography
                      Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.

                      Last edited by Attaullah Shah; 27 Aug 2020, 13:58.
                      Regards
                      --------------------------------------------------
                      Attaullah Shah, PhD.
                      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                      FinTechProfessor.com
                      https://asdocx.com
                      Check out my asdoc program, which sends outputs to MS Word.
                      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                      Comment


                      • #12
                        Thanks @Attaullah Shah! Yes, I will cite.

                        Comment

                        Working...
                        X