Announcement

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

  • Program like outreg2 but for t-test outputs

    Is there a useful program like outreg2 but for t-test outputs?

    I came across one way to enter every value manually but there's probably a much better program.

  • #2
    Unfortunately, there is nothing perfect available as outreg2 for ttest. For one sample ttest, a work around is to use reg command and then use outreg2. For example the following two commands give the same results
    Code:
    ttest returns==0
    reg returns
    If you are interested in two sample ttest, then you might use estpost see, http://fmwww.bc.edu/repec/bocode/e/estpost.html
    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


    • #3
      Thank you Attaullah! I'll look into -estpost-. While I'm trying to work with -estpost- I'd also appreciate other suggestions to tabulate t-test outputs

      Comment


      • #4
        Is it normal that the t-test output converts to this: http://i.imgur.com/quXoEJG.png by using estpost and esttab?

        Is there a nicer way to tabulate t-test results?

        Comment


        • #5
          I use "putexcel" for my t-test.

          Code:
          putexcel set "T-test.xlsx", sheet("t_test") replace
          putexcel A1=("Variable") B1=("Control (Mean)") C1=("Control (SD)") D1=("Treatment (Mean)") E1=("Treatment(SD)") F1=("p value")
          
          local row=2
          foreach var of varlist x1 x2 x3 x4 {
             qui ttest `var',by(treatment)
          putexcel A`row' = ("`var'")
          putexcel B`row' = (r(mu_1))
          putexcel C`row' = (r(sd_1))
          putexcel D`row' = (r(mu_2))
          putexcel E`row' = (r(sd_2))
          putexcel F`row' = (r(p))
          local ++row
          }
          ****
          Roman

          Comment


          • #6
            I still haven't figured out how to work with "putexcel" but thank you anyways for the nice suggestion.
            I've also seen that a normal regression has the same outcomes as the t-test outcome, in the case of equal variances, which isn't equal in my case.

            Does anyone know how to convert a "ttest alpha, by(gender) unequal" into a regression with the same t-value etc. So, that I can use the easy outreg2 instead of "putexcel"

            Comment


            • #7
              Putexcel is for Stata13 only and I have version 12. Does anyone have a nice suggestion?

              Comment


              • #8
                Just to update this post, I am listing asdoc as an option to report ttest results. asdoc can be installed from
                Code:
                ssc install asdoc
                and can work with almost all Stata command. The following examples are borrowed from the asdoc's help file

                Example 67 : Appending t-test results with rowappend option
                `
                Code:
                    sysuse auto, clear
                        asdoc ttest rep78==0, replace title(T-test results : mean == 0)
                        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

                Example 68 : Repeat the above tests, requesting specific statistics
                Code:
                      sysuse auto, clear
                        asdoc ttest rep78==0, replace title(T-test results : mean == 0) stat(obs mean se df t)
                        asdoc ttest price==0, rowappend stat(obs mean se df t)
                        asdoc ttest mpg==0, rowappend stat(obs mean se df t)
                        asdoc ttest turn==0, rowappend stat(obs mean se df t)
                        asdoc ttest weight==0, rowappend stat(obs mean se df t)
                        asdoc ttest length==0, rowappend stat(obs mean se df t)

                8.2 Two-sample t-test using groups i.e. with option the by()

                Example 69: Two-sample t-test using groups i.e. with the option by()
                `
                asdoc ttest mpg, by(foreign) replace


                8.3 Two-sample t-test using variables

                Example 70: Two-sample t-tes using variables
                `
                Code:
                 asdoc ttest mpg==price, replace
                And to add similar tests to the same table, we can use rowappend

                Example 71: append more tests
                `
                Code:
                       asdoc ttest trunk==price, rowappend

                8.4 Two sample test over groups

                Example 72: Two sample test over groups
                `
                Code:
                   bysort foreign: asdoc ttest mpg == price, replace
                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


                • #9
                  I have two groups by dummy variables.
                  I need to create a table with difference in means for a variable in treated and control groups and report it to outreg table.
                  In the first column you should include the means and, in parenthesis, the standard deviation of the treated and control firms respectively, corresponding to each variable.
                  The second column should include the median.
                  The third column should include the difference in the two means.
                  And the fourth column should include the t-statistic of the mean difference.


                  The table below is incorrect.
                  What I need is Mean1-Mean2 which will be TobinsQMeanfromTreatedGroup - TobinsQMeanfromControlGroup.



                  Code:
                  . bysort CUT: asdoc ttest TobinsQ == CUT, replace
                  
                  Paired t test : TobinsQ CUT 
                  obs Mean1 Mean2 dif St_Err t_value p_value
                  0 219400 8.145 8.145 0 1.44 0 1
                  1 910 1.552 1.552 0 .058 0 1
                  Last edited by Ingrid Lambert; 02 Jan 2020, 01:32.

                  Comment


                  • #10
                    I think there is some parsing issue, which I have noted and shall correct in the next update of asdoc. At the moment, please run the paired t-test separately for each group of CUT.
                    Here is an example
                    Code:
                    sysuse auto, clear  
                    asdoc ttest price = turn if foreign == 1, replace  
                    asdoc ttest price = turn if foreign == 0, rowappend
                    In your example, the variable CUT seems to have only two groups, i.e. 0 and 1, so if you are conducting ttest of TobinsQ = CUT if CUT == 0, then why not just
                    Code:
                     ttest TobinsQ, by(CUT)
                    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


                    • #11
                      The wonderful table below sadly lacks the following:

                      Originally posted by Ingrid Lambert View Post
                      and, in parenthesis, the standard deviation of the treated and control firms respectively, corresponding to each variable.
                      The second column should include the median
                      Code:
                      asdoc ttest TobinsQ,by(CUT)
                        asdoc ttest FirmSize,by(CUT) rowappend
                        asdoc ttest CFtoAssets,by(CUT) rowappend
                        asdoc ttest CashtoAssets,by(CUT) rowappend
                        asdoc ttest LTLev,by(CUT) rowappend
                        asdoc ttest Inv,by(CUT) rowappend
                      
                      Two-sample t test with equal variances   
                      obs1 obs2 Mean1 Mean2 dif St_Err t_value p_value
                      TobinsQ by CUT: 0 1 219400 910 8.145 1.563 6.583 22.351 .3 .768
                      FirmSize by CUT: 0 1 294702 1143 4.641 3.821 .82 .081 10.15 0
                      CFtoAssets by CUT:~1 253058 1115 -.713 -.009 -.705 1.933 -.35 .716
                      CashtoAssets by CU~1 272978 1142 .148 .106 .043 .006 6.85 0
                      LTLev by CUT: 0 1 292995 1142 .281 .18 .101 .34 .3 .768
                      Inv by CUT: 0 1 225241 1045 253.694 104.993 148.701 726.377 .2 .838

                      Comment


                      • #12
                        It is really hard for developers to foresee all possible variations needed by users. The formatting and contents of the ttest output from the asdoc command were really puzzling for me at the time of development.

                        Inside the help file of asdoc, you can see several options that can be used with the ttest command, specifically, read Section 8 of the help file. Still, if you want to further customize your table, you can read materials related to option row(). To get started, first read this article https://fintechprofessor.com/2018/09...stata-ms-word/

                        Then you may like to read https://fintechprofessor.com/2019/09...f-asdoc-stata/
                        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


                        • #13
                          Originally posted by Attaullah Shah View Post
                          then why not just
                          Code:
                          ttest TobinsQ, by(CUT)



                          Dear prof. Shah, I wish the life was that easy. ^_^
                          I need to report results using nice output.

                          I also have a question about asdoc. Is it possible to remove the columns I do not need? Say, obs and St_Err.
                          I need to add standard deviation of the treated and control firms and the medians instead...


                          In the first column you should include the means and, in parenthesis, the standard deviation of the treated and control firms respectively, corresponding to each variable.
                          The second column should include the median.
                          The third column should include the difference in the two means.
                          And the fourth column should include the t-statistic of the mean difference.

                          Comment


                          • #14
                            Originally posted by Attaullah Shah View Post
                            It is really hard for developers to foresee all possible variations needed by users. The formatting and contents of the ttest output from the asdoc command were really puzzling for me at the time of development.

                            Inside the help file of asdoc, you can see several options that can be used with the ttest command, specifically, read Section 8 of the help file. Still, if you want to further customize your table, you can read materials related to option row(). To get started, first read this article https://fintechprofessor.com/2018/09...stata-ms-word/

                            Then you may like to read https://fintechprofessor.com/2019/09...f-asdoc-stata/
                            Dear prof. Shah, I find asdoc to be the most comprehensive in terms of exporting the results of T Test.

                            putexcel worked for me but is it not suitable simply because I require the table to be suitable for a research paper.

                            Your comment on an option row() is indeed helpful.

                            I sincerely hope such feedback from users helps you to improve asdoc!

                            Comment


                            • #15
                              I suggested reading the help file, which I think you have not noticed. So let me copy and paste from the help file. The point is you can restrict the output to your desired statistics using option stat().

                              Code:
                              6.stat(mean se df obs t p sd dif): Without stat() option, asdoc reports the number of observations
                              (obs), mean, standard error, t-value, and p-value with t-tests. However, you can select all or a few
                              statistics using the stat option.
                              
                                  With ttest command, we can use the following options of asdoc to control asdoc behavior.  
                              (1) replace/append
                              (2) save(filename)
                              (3) title(text)
                              (4) fs(#)
                              (5) hide.
                              (6) stats()
                              (7) rowappend.
                              These options are discussed in detail in  Section 1.. Option stats and rowappend are discussed   below:
                              
                              
                                  ----+ Statistics +------------------------------------------------------
                                     n        Number of observations
                                     mean     Arithmetic mean
                                     se       Standard error
                                     df       degrees of freedom
                                     obs      Number of observations
                                     t        t-value
                                     p        p-value
                                     sd       standard deviation
                                     dif      difference in means if two-sample t-test
                               -----------------------------------------------------------------------------
                              Last edited by Attaullah Shah; 02 Jan 2020, 06:00.
                              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

                              Working...
                              X