Announcement

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

  • save results from "test" (wald test) command and combine later with others to create output

    I am running several test commands in a row and I would like to save these results and combine them later in a table.

    However, I noticed that I cannot save the results from the test; is there a way to save the outputs and to combine them thereafter?

    HTML Code:
    // select the estimation window (1,3,5)
    // Window with 1 day
    test [top_regression1_mean]d_e1_1 = [bottom_regression1_mean]d_e1_1
    estimates store Event1_1
    test [top_regression1_mean]d_e2_1 = [bottom_regression1_mean]d_e2_1
    estimates store Event2_1
    test [top_regression1_mean]d_e3_1 = [bottom_regression1_mean]d_e3_1
    estimates store Event3_1
    test [top_regression1_mean]d_e4_1 = [bottom_regression1_mean]d_e4_1
    estimates store Event4_1
    test [top_regression1_mean]d_e5_1 = [bottom_regression1_mean]d_e5_1
    estimates store Event5_1
    test [top_regression1_mean]d_e6_1 = [bottom_regression1_mean]d_e6_1
    estimates store Event6_1
    test [top_regression1_mean]d_e7_1 = [bottom_regression1_mean]d_e7_1
    estimates store Event7_1
    test [top_regression1_mean]d_e8_1 = [bottom_regression1_mean]d_e8_1
    estimates store Event8_1
    test [top_regression1_mean]d_e9_1 = [bottom_regression1_mean]d_e9_1
    estimates store Event9_1
    test [top_regression1_mean]d_e10_1 = [bottom_regression1_mean]d_e10_1
    estimates store Event10_1
    test [top_regression1_mean]d_e11_1 = [bottom_regression1_mean]d_e11_1
    estimates store Event11_1
    test [top_regression1_mean]d_e12_1 = [bottom_regression1_mean]d_e12_1
    estimates store Event12_1
    test [top_regression1_mean]d_e13_1 = [bottom_regression1_mean]d_e13_1
    estimates store Event13_1
    test [top_regression1_mean]d_e14_1 = [bottom_regression1_mean]d_e14_1
    estimates store Event14_1
    test [top_regression1_mean]d_e15_1 = [bottom_regression1_mean]d_e15_1
    estimates store Event15_1
    test [top_regression1_mean]d_e16_1 = [bottom_regression1_mean]d_e16_1
    estimates store Event16_1
    test [top_regression1_mean]d_e17_1 = [bottom_regression1_mean]d_e17_1
    estimates store Event17_1
    test [top_regression1_mean]d_e18_1 = [bottom_regression1_mean]d_e18_1
    estimates store Event18_1
    test [top_regression1_mean]d_e19_1 = [bottom_regression1_mean]d_e19_1
    estimates store Event19_1
    test ([top_regression1_mean]d_e1_1+[top_regression1_mean]d_e2_1+[top_regression1_mean]d_e3_1+[top_regression1_mean]d_e4_1+[top_regression1_mean]d_e5_1+[top_regression1_mean]d_e6_1+[top_regression1_mean]d_e7_1+[top_regression1_mean]d_e8_1+[top_regression1_mean]d_e9_1+[top_regression1_mean]d_e10_1+[top_regression1_mean]d_e11_1+[top_regression1_mean]d_e12_1+[top_regression1_mean]d_e13_1+[top_regression1_mean]d_e14_1+[top_regression1_mean]d_e15_1+[top_regression1_mean]d_e16_1+[top_regression1_mean]d_e17_1+[top_regression1_mean]d_e18_1+[top_regression1_mean]d_e19_1) = ([bottom_regression1_mean]d_e1_1+[bottom_regression1_mean]d_e2_1+[bottom_regression1_mean]d_e3_1+[bottom_regression1_mean]d_e4_1+[bottom_regression1_mean]d_e5_1+[bottom_regression1_mean]d_e6_1+[bottom_regression1_mean]d_e7_1+[bottom_regression1_mean]d_e8_1+[bottom_regression1_mean]d_e9_1+[bottom_regression1_mean]d_e10_1+[bottom_regression1_mean]d_e11_1+[bottom_regression1_mean]d_e12_1+[bottom_regression1_mean]d_e13_1+[bottom_regression1_mean]d_e14_1+[bottom_regression1_mean]d_e15_1+[bottom_regression1_mean]d_e16_1+[bottom_regression1_mean]d_e17_1+[bottom_regression1_mean]d_e18_1+[bottom_regression1_mean]d_e19_1)
    estimates store Events_1 
    
     esttab   Event1_1  Event2_1  Event3_1  Event4_1  Event5_1  Event6_1  Event7_1  Event8_1  Event9_1  Event10_1  Event11_1  Event12_1  Event13_1  Event14_1  Event15_1  Event16_1  Event17_1  Event18_1  Event19_1 

    How can I save the results and tabulate them so that I can export them after that?
    Additionally, I am testing if two coefficients from regressions on two different samples (same dummy variable) are the same. Is the wald test appropriate for this?

  • #2
    How is this different from your previous post, in which you were asked to give more information?

    You might look into -postfile- (if using Stata 14 or earlier) or -frame post-if using newer versions.

    Comment


    • #3
      Check out Ben Jann's estadd command, available from SSC.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

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

      Comment


      • #4
        This post mainly relates to the problem with saving the results from the Wald tes ("test" command), this solution was not discussed in my previous post, neither how to save the results from this test.

        the main problem i am facing now is to save the results from the test:

        Click image for larger version

Name:	Screenshot 2021-05-07 at 14.00.06.png
Views:	1
Size:	14.9 KB
ID:	1608178

        Comment


        • #5
          @richard

          I read up on the estadd command, but I don't really see how I can save the results from the "test" command.

          How would you apply this command?

          I would like to save for example the chi2 of 1.03 and the probability 0.3112
          Last edited by ties jongen; 07 May 2021, 07:12.

          Comment


          • #6
            Search the forum with the keyword "estadd" for many examples. After the test command, the statistics are stored in r(), so type

            Code:
            return list
            to access them. An example is at #2 https://www.statalist.org/forums/for...n-using-esttab

            Comment


            • #7
              Thank you for your help Andrew.
              In my case; if I would like to add only the chi2 and the p value, but should I use
              HTML Code:
              estad scalar  [top_regression1_mean]d_e1_1
              for some reason I do not get the r() to work.
              Also after using the scalar i see that an added e() is added; and my
              HTML Code:
              estimates list
              also doesnt work anymore.

              what code should I use if I want to add the chi2 and p value as a separate column to my esttab command?

              Comment


              • #8
                I think I misunderstood what you want to do, not paying attention to the earlier discussion. You want to output results from test, not including coefficients. estimates store is not suitable here. One method is to define a matrix to store a set of test results and then output the combined matrices using esttab(SSC). For your example in #1, something like:

                Code:
                test [top_regression1_mean]d_e1_1 = [bottom_regression1_mean]d_e1_1
                mat m1= (`r(chi2)', `r(p)')
                mat rowname m1= "Event1_1"
                local m m1
                forval i=2/19{
                    test [top_regression1_mean]d_e`i'_1 = [bottom_regression1_mean]d_e`i'_1
                    mat m`i'= (`r(chi2)', `r(p)')
                    mat rowname m`i'= "Event`i'_1"
                    local m `m' \m`i'  
                }
                mat m=`m'
                esttab matrix(m), collabels("Chi2" "P value") nomtitle
                Last edited by Andrew Musau; 07 May 2021, 16:02.

                Comment

                Working...
                X